`
louisling
  • 浏览: 140517 次
  • 性别: Icon_minigender_1
  • 来自: ZhuHai
社区版块
存档分类
最新评论

One-To-Many in Hibernate

    博客分类:
  • JPA
阅读更多
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" />
分享到:
评论

相关推荐

    hibernate-shards.jar

    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 ...

    Hibernate Recipes A Problem-Solution Approach

    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 ...

    Hibernate Reference Documentation3.1

    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. ...

    hibernate总结

    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) 在内存...

    Lazy loading - eager loading

    &lt;one-to-many class="OrderLine"/&gt; &lt;/hibernate-mapping&gt;Analogous you can implement the mappings for the Customer entity &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:...

    hibernate3.6 文档(pdf 格式)

    1.1. Part 1 - The first Hibernate Application ................................................................ 1 1.1.1. Setup .............................................................................

    mastering.java

    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 ...

    Google Guice: Agile Lightweight Dependency Injection Framework

    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 ...

    Grails A Quick-Start Guide:Dave Klein (DK)

    4.3 One-to-Many Relationships . . . . . . . . . . . . . . . . 60 4.4 Collections of Simple Data Types . . . . . . . . . . . . . 62 4.5 Adding a Sponsor Class . . . . . . . . . . . . . . . . . . 64 4.6...

    基于java的个人博客系统-毕业设计.doc

    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 ...

    工程硕士学位论文 基于Android+HTML5的移动Web项目高效开发探究

    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...

Global site tag (gtag.js) - Google Analytics