CREATE TABLE FATHER (
ID CHAR(32) NOT NULL,
NAME CHAR(32) NOT NULL,
PRIMARY KEY(id)
)
CREATE TABLE SON (
ID CHAR(32) NOT NULL,
NAME CHAR(32) NOT NULL,
FATHER_ID CHAR(32) NOT NULL,
PRIMARY KEY(id)
)
ALTER TABLE SON ADD FOREIGN KEY FATHER_ID REFERENCE FATHER(ID);
Father.hbm.xml
<set name="children" lazy="true" inverse="true">
<key>
<!-- Son.father_id -->
<column name="FATHER_ID" not-null="true" />
</key>
<one-to-many class="com.zero.demo.Son" />
</set>
Son.hbm.xml
<many-to-one column="FATHER_ID" name="father" class="com.zero.demo.Father" not-null="true" cascade="none" />
分享到:
相关推荐
In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library ...
How to do various mappings, including one-to-one mapping, many-to-one mapping, collection mapping, component mapping, and inheritance mapping How to use Hibernate Query Language (HQL) How to perform ...
5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.4.1. Generator 5.1.4.2. Hi/lo algorithm 5.1.4.3. UUID algorithm 5.1.4.4. Identity columns and sequences 5.1.4.5. Assigned identifiers 5.1.4.6. ...
i. Many-to-one 1. false 2. proxy 3. no-proxy ii. set 一对多 1. true 2. false 3. extra 根据对set容器的不同,可以产生高效的sql访问数据库 2. 批量检索:batch-size=3 a) 可以使用批量检索: b) 在内存...
<one-to-many class="OrderLine"/> </hibernate-mapping>Analogous you can implement the mappings for the Customer entity <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:...
1.1. Part 1 - The first Hibernate Application ................................................................ 1 1.1.1. Setup .............................................................................
We talk about how to handle images, design forms, gap editing and debugging, followed by a discussion on bean and data binding and using Hibernate in your application. Chapter 5: Object-Oriented ...
This book is for professional Java developers who are interested in dependency injection, modern Java coding practices and who want to tackle complexity with a simple, powerful and high-quality ...
4.3 One-to-Many Relationships . . . . . . . . . . . . . . . . 60 4.4 Collections of Simple Data Types . . . . . . . . . . . . . 62 4.5 Adding a Sponsor Class . . . . . . . . . . . . . . . . . . 64 4.6...
Hibernate Abstract With the development of the Internet, people's needs are no longer stuck in the material stage as before, a lot of people looking for spiritual sustenance and hope to have one of ...
Webview window in android used to load pages just works like browser, as well as there is only one webview running at the same time. (2)Cross-domain data interaction. Different webviews can not share...