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

Hibernate example source code file (Multi.hbm.xml)

This example Hibernate source code file (Multi.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

component, component, doctype, doctype, dtd, dtd, hibernate/hibernate, mapping, mapping, public

The Hibernate Multi.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 default-lazy="false">

    <class 
    	name="org.hibernate.test.legacy.Top" 
    	table="rootclass" 
    	dynamic-insert="true" 
    	dynamic-update="true"
    	select-before-update="true"
    	where="id1_ is not null">
        <!--cache-->
        <id name="id" type="long" column="id1_" unsaved-value="0">
            <generator class="native"/>
        </id>
        <version name="count" column="count_"/>
        <property name="name"/>
        <property name="address"/>
        <property name="date" column="date_"/>
        <many-to-one name="top" access="field" column="top_"/>
                
        <joined-subclass name="org.hibernate.test.legacy.TrivialClass">
        	<key column="tcid"/>
        </joined-subclass>
        
	    <joined-subclass 
	    	name="org.hibernate.test.legacy.Lower" 
	    	table="leafsubclass"
	    	dynamic-insert="true" 
    		dynamic-update="true">
	        <key column="id__"/>
	        <property name="intprop" not-null="true"/>
	        <one-to-one name="other" class="org.hibernate.test.legacy.Lower"/>
	        <many-to-one name="another" column="other1" class="org.hibernate.test.legacy.Top"/>
	        <many-to-one name="yetanother" column="other3" class="org.hibernate.test.legacy.Lower"/>
	        <property name="foo"/>
	        <set name="set" lazy="false">
	        	<key column="parent"/>
	        	<one-to-many class="org.hibernate.test.legacy.Top"/>
	        </set>
	        <bag name="bag" lazy="true" table="simple_simple">
	        	<key column="simple1"/>
	        	<many-to-many column="simple2" class="org.hibernate.test.legacy.Top"/>
	        </bag>
	        <one-to-one name="mypo"/>
	    </joined-subclass>
	    
	    <joined-subclass name="org.hibernate.test.legacy.Multi" table="nonleafsubclass">
	    	<key column="sid" on-delete="cascade"/>
	        <property name="extraProp" column="dupe"/>
	        <many-to-one name="other" column="other2" class="org.hibernate.test.legacy.Multi" />
	        <many-to-one name="po"/>
	        <property name="derived" formula="upper(dupe)"/>
	        
	        <component name="comp" class="org.hibernate.test.legacy.Multi$Component">
	        	<property name="cal"/>
	        	<property name="floaty"/>
	        </component>
	        
	        <joined-subclass name="org.hibernate.test.legacy.SubMulti" table="leafsubsubclass">
	        	<key column="sid"/>
	        	<property name="amount" column="dupe"/>
	        	<bag name="children" lazy="true" inverse="true">
	        		<key column="parent"/>
	        		<one-to-many class="org.hibernate.test.legacy.SubMulti"/>
	        	</bag>
	        	<many-to-one name="parent"/>
				<list name="moreChildren" lazy="true">
	        		<key column="another_parent"/>
	        		<index column="list_ind"/>
	        		<one-to-many class="org.hibernate.test.legacy.SubMulti"/>
	        	</list>
	        </joined-subclass>
	        
	    </joined-subclass>

    </class>
    
    <class 
    	name="org.hibernate.test.legacy.Po"
    	dynamic-insert="true">
    	<id type="long" column="id_">
    		<generator class="native"/>
    	</id>
    	<property name="value" column="value_"/>
    	<list name="list" cascade="all">
    		<key column="list_po"/>
    		<index column="i"/>
    		<one-to-many class="org.hibernate.test.legacy.SubMulti"/>
    	</list>
    	<set name="set" inverse="true" cascade="all">
    		<key column="po"/>
    		<one-to-many class="org.hibernate.test.legacy.Multi"/>
    	</set>
    	<many-to-one name="top" column="tl" insert="false" update="false"/>
    	<many-to-one name="lower" column="tl"/>
    </class>

</hibernate-mapping>

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate Multi.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.