Previous article hibernate from getting started to mastering (ix) A pair of multiple bidirectional association mappings we explained the relevant content of a one-to-many correlation mapping, this time we continue to multiple one-way association mappings.
Multi-pair multiple one-way association mappings
Before explaining the multiple to multiple one-way association ma
Hibernate for the operation of the database, all the use of object-oriented thinking to understand and implement. The general map of the individual table, I believe that everyone has no problem, but for some of the special relationship between tables, Hibernate provides some unique way to simplify it.
Today we'll talk about the correlation mapping for Many-to-ma
The previous article discusses a one-to-many mapping in detail, and there are a lot of problems with unidirectional mappings in a pair of mappings, so it is not recommended to use a two-way association to optimize the relationship if one-to-many mappings are to be considered, which is essentially using
one, one-way many-to-many
Still in accordance with the previous article format to discuss, first of all, the relationship between the object, a one-w
A: basic mapping: A data table corresponding to an entity class, called this mapping as the basic mappingTwo : relational mapping: It is the mapping that deals with the relationship between n related objects and n related tables on the basis of basic mappings. Mainly divided into the following types:
One-Way A
The previous article discusses a one-to-many mapping in detail, and there are a lot of problems with unidirectional mappings in a pair of mappings, so it is not recommended to use a two-way association to optimize the relationship if one-to-many mappings are to be considered, which is essentially using one, one-way many-to-manyStill in accordance with the previous article format to discuss, first of all, the relationship between the object, a one-way
Last Post hibernate from getting started to mastering (eight) One-to-many one-way correlation mapping, we explained a pair of multiple one-way mapping of the relevant content, this time we explain a pair of multiple two-way mapping related content.
One-to-many Two-Way Association mappings
One-to-many Two-Way associat
to the underlying database, but instead manipulate persisted objects in an object-oriented manner, while the ORM framework translates these object-oriented operations into the underlying SQL operations.The only function of the ORM tool is to convert the persisted object to the operation of the database by saving, deleting, modifying and so on. From then on, programmers can manipulate persisted objects in an object-oriented manner, while the ORM Framework is responsible for translating the corre
The mapping file is configured in spring Applicationcontext.xml, typically in the bean instance of The first type:As configuration files become more and more cumbersome to read and modify, and XML-based configuration can lead to input errors, you may be wasting half a day searching for errors because of a single character error.The second type:In this case, you can use the Localsessionfactorybean "Mappingdirectorylocations" property to define the
,Joincolumns, Joincolumn, InversejoincolumnXml:Bidirectional:Note: Set @manytomany (mappedby= "") on a one-way basis on the other side of the collectionXML: Also set E. Component mapping: A bean that is part of a table, not as an entity, such as a student ID as part of a student entity;Component references in entities add @embeddedUsing Note: (1) bidirectional correlation Mappedby attribute must be set, XML with Indicates that the relationship is domi
; } Public voidsetName (String name) { This. Name =name; }}@Entity Public class extends Person { privateint score; Public int Getscore () { return score; } Public void setscore (int score) { this. score = score; } } @Entity Public class extends Person { private String title; Public String GetTitle () { return title; } Public void Settitle (String title) { this. title = title; } } c) Each sub-Class A table join
Hibernet MappingCollection mappings:The property fields of the class are collections.SetMapping of Set collection propertiesName specifies the properties of the set collection to be mappedTable to which to map table collection propertiesKEY specifies the foreign key field of the collection table (t_address)element specifies other fields of the collection tableType element, be sure to specifyList--List Collection MappingsLIST-INDEX Specifies the name of the row sequence (because the list collecti
Wo rker0_. Wid=worker0_1_.id where worker0_. wid=?//parameter ID to join the Worker's table in the WID field */}Test Page test.jspResults:HQL for console printing:Hibernate:select Student_. Sid, student_1_. Name as name0_, student_1_. Sex as sex0_, student_1_. Age as age0_, Student_. Sno as Sno1_, Student_. School as school1_ from student student_ inner join person student_1_ on Student_. Sid=student_1_.id where Student_. Sid=? Hibernate:insert into who (Name, Sex, age, ID) VALUES (?,?,?,?) Hib
Student and teacher are many-to-many relationships (only 2 entity classes built)1 Public class Student {2 Private int ID; 3 Private String name; 4 Private New Hashset(); 5 }1 Public class Teacher {2 Private int ID; 3 Private String name; 4 Private New Hashset(); 5 }Many-to-many1 Package= "Entity" >2className= "Student" >34class= "Native"/>5678Table property of the label: Configure the name of the relationship table9Column property of the Label: foreign key field nam
Describes the role of each node in ActionName.hbm.xml: Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. Hibernate Mapping Table Detailed
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.