Hibernate study notes (1)

xiaoxiao2021-03-05  20

2005-3-3 Learning Hibernate In learning hibernate, I found that the database sub-adding field in SQL Server 2000 is used to implement: 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: 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: If it is List, you need to use 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 : role.hbm.xml file Similar to:

转载请注明原文地址:https://www.9cbs.com/read-32314.html

New Post(0)