alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (union-subclass.hbm.xml)

This example Hibernate source code file (union-subclass.hbm.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

customer, doctype, dtd, employee, employee, hibernate/hibernate, mapping, mapping, person, public, ucustomer, ucustomer, uemployee, uperson

The Hibernate union-subclass.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">

<hibernate-mapping package="org.hibernate.test.subclassfilter">

	<class name="Person" table="UPerson">

		<id name="id" column="person_id">
			<generator class="hilo"/>
		</id>

		<property name="name" unique="true"/>
		<property name="company"/>
		<property name="region"/>

		<union-subclass name="Employee" table="UEmployee">
			<property name="title"/>
			<property name="department" column="dept"/>
			<many-to-one name="manager" column="mgr_id" class="Employee" cascade="none"/>
			<set name="minions" inverse="true" lazy="true" cascade="all">
				<key column="mgr_id"/>
				<one-to-many class="Employee"/>
				<filter name="region" condition="region = :userRegion"/>
			</set>
		</union-subclass>

		<union-subclass name="Customer" table="UCustomer">
			<many-to-one name="contactOwner" class="Employee"/>
		</union-subclass>

		<filter name="region" condition="region = :userRegion"/>

	</class>

	<filter-def name="region">
		<filter-param name="userRegion" type="string"/>
    </filter-def>

</hibernate-mapping>

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate union-subclass.hbm.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.