2005-3-3 Learning Hibernate In learning hibernate, I found that the database sub-adding field in SQL Server 2000 is used to implement: id> Here mainly: Identity: The representative provides subharmonic fields by the SQL Server2000 database. If you want hibernate to provide it, use the increment keyword to implement
If the primary key in the table is string type: The primary key can be implemented by Hibernate itself: id> UUID.HEX policies
Important knowledge points: 1. If there are departmental tables, there are employee tables, DEP_ID in the employee table, and the formal class and employee are one-to-portrative relationship: (Use: (using the following in departmental service) Department class: / ** All employees of the department * / private set staffs = new treset (); XML file: set> If it is List, you need to use index index>, the specifics of the meaning, not very well. Start research 2. If the department must have a responsible There is a field in the department (TB_Department): STAFF_ID. Then the relationship between the department and the person in charge is the relationship between MANY-TO-One Department: / ** Department leader id * / private staff staff; XML File 2005-3-4 Learning Hibernate 3. Multi-to-many relationships, usually we are doing a middle Association Table. I use roles and permissions to do an example, Right (ID, name) Role (ID, name) intermediate table: TB_Role_Right (role_id, right_id) Right class has a collection of role: private set roles = new Treeset The Role class also has a collection of Right: private set rights = new treseT (); then the two are obvious multi-relationships. Using MANY-TO-MANY to implement; XML files Right.hbm.xml: as follows : set> role.hbm.xml file Similar to: Set>