|
Hibernate example source code file (Person.hbm.xml)
The Hibernate Person.hbm.xml source code<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- Demonstrates the use of property-ref to map legacy data where foreign keys reference something other than the primary key of the associated entity. Here we show: (1) A one-to-one foreign key association (prefer primary key associations) (2) A bidirectional one-to-many association on a key that is not the primary key (prefer associations from foreign keys to primary keys) --> <hibernate-mapping package="org.hibernate.test.propertyref.basic"> <class name="Person" table="PROPREF_PERS"> <id name="id"> <generator class="hilo"/> </id> <property name="name" length="100"/> <property name="userId" column="person_userid" length="8" unique="true"/> <one-to-one name="address" property-ref="person" cascade="all" fetch="join"/> <set name="accounts" inverse="true"> <key column="userId" property-ref="userId"/> <one-to-many class="Account"/> </set> <bag name="systems" table="USER_SYSTEM" lazy="true" inverse="false" cascade="all"> <key column="USER_ID" property-ref="userId" /> <element type="string" column="SYSTEM" /> </bag> </class> <class name="Address" table="PROPREF_ADDR"> <id name="id"> <generator class="hilo"/> </id> <property name="address" length="300"/> <property name="zip" length="5"/> <property name="country" length="25"/> <many-to-one name="person" unique="true" not-null="true"/> </class> <class name="Account" table="PROPREF_ACCT"> <id name="accountId" length="32"> <generator class="uuid.hex"/> </id> <many-to-one name="user" column="userId" property-ref="userId"/> <property name="type" column="`type`" not-null="true"/> </class> <class name="Group" table="PROPREF_GRP"> <id name="name"/> <set name="users" table="PROPREF_USERGROUP" cascade="save-update"> <key column="groupName"/> <many-to-many column="userId" class="Person" property-ref="userId"/> </set> </class> </hibernate-mapping> Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate Person.hbm.xml source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.