|
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.typedmanytoone"> <class name="Customer" select-before-update="true" dynamic-update="true"> <id name="customerId"> <generator class="assigned"/> </id> <property name="name" not-null="true"/> <many-to-one name="billingAddress" entity-name="BillingAddress" cascade="persist,save-update,delete" fetch="join"> <column name="billingAddressId"/> <formula>'BILLING' </many-to-one> <many-to-one name="shippingAddress" entity-name="ShippingAddress" cascade="persist,save-update,delete" fetch="join"> <column name="shippingAddressId"/> <formula>'SHIPPING' </many-to-one> </class> <class name="Address" table="Address" entity-name="BillingAddress" where="add_type='BILLING'" check="add_type in ('BILLING', 'SHIPPING')" select-before-update="true" dynamic-update="true"> <composite-id name="addressId"> <key-property name="addressId"/> <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"/> </class> <class name="Address" table="Address" entity-name="ShippingAddress" where="add_type='SHIPPING'" select-before-update="true" dynamic-update="true"> <composite-id name="addressId"> <key-property name="addressId"/> <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"/> </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.