|
Hibernate example source code file (Customer.hbm.xml)
The Hibernate Customer.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"> <!-- Shows how to map a one-to-many relationship in the relational schema to "typed" one-to-one associations in the object model. We map the Address class twice, with different entity names, specifying a filtering condition in each mapping. The typed associations then reference the named entities. --> <hibernate-mapping package="org.hibernate.test.typedonetoone"> <class name="Customer"> <id name="customerId"> <generator class="assigned"/> </id> <property name="name" not-null="true"/> <one-to-one name="billingAddress" entity-name="BillingAddress" property-ref="customer" cascade="persist, delete" fetch="join"/> <one-to-one name="shippingAddress" entity-name="ShippingAddress" property-ref="customer" cascade="persist, delete" fetch="join"/> </class> <class name="Address" table="Address" entity-name="BillingAddress" where="add_type='BILLING'" check="add_type in ('BILLING', 'SHIPPING')"> <composite-id name="addressId"> <key-property name="customerId"/> <key-property name="type" column="add_type"/> </composite-id> <property name="street" not-null="true"/> <property name="city" not-null="true"/> <property name="state" not-null="true"/> <property name="zip" not-null="true"/> <many-to-one name="customer" column="customerId" insert="false" update="false"/> </class> <class name="Address" table="Address" entity-name="ShippingAddress" where="add_type='SHIPPING'"> <composite-id name="addressId"> <key-property name="customerId"/> <key-property name="type" column="add_type"/> </composite-id> <property name="street" not-null="true"/> <property name="city" not-null="true"/> <property name="state" not-null="true"/> <property name="zip" not-null="true"/> <many-to-one name="customer" column="customerId" insert="false" update="false"/> </class> </hibernate-mapping> Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate Customer.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.