The onetoone form ing is used in the structure. However, the error "detached entity passed to persist:" occurs when the master and sub-tables are saved. Solution: remove the import Org. hibernate. annotations. genericgenerator; import javax. persistence. generatedvalue; @ genericgenerator (name = "generator", strategy = "UUID") @ generatedvalue (generator = "generator. The original intention is to use hibernate UUID for automatic ID assignment. However, there seems to be a problem with hibernate 3.3. The automatic function cannot be completed. You can only use the following Code For ID replication.
-
- PublicBoolean adduserinfo (alcortuser alcoruser) throws exception {
-
- String userid = UUID. randomuuid (). tostring ();
-
- Alcoruser. setuserid (userid );
- Alcoruser. setpassword ("Password");
-
- Alcoruser. setlogincount (0 );
-
- Alcoruser. setlastlogin (NewDate ());
-
- Alcoruser. getalcortuserdetail (). setuserid (userid );
-
- /* Iterator <alcortuserdetail> userdetailiterator = alcoruser. getalcortuserdetails (). iterator ();
- Logger. debug ("contains" + alcoruser. getalcortuserdetails (). toarray (). Length + "User details ");
-
- While (userdetailiterator. hasnext ())
-
- {
-
- Userdetailiterator. Next (). setuserid (userid );
-
- // This. alcortuserdetaildao. Save (userdetailiterator. Next ());
-
- }*/
- This. Alcortuserdao. Save (alcoruser );
-
-
- Return True;
-
- }
Here, alcoruser is the primary table, alcoruserdetail is the sub table, and it is the onetoone ing.
The passed alcoruser object is passed in through LCDs through flex. It is already on the flex side. Put the object of a sub-table content into the object of the main table content. Therefore, you only need to save the primary table, and the child table will be automatically saved. This end is blocked in the middle, which is the method for processing onetoworkflow. Iterator is used. In pojo, hashset is used for definition.