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

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

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

child, child, doctype, doctype, dtd, hibernate/hibernate, mapping, mapping, parent, parent, public, this

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

<!--

  This mapping illustrates use of <natural-id> with a many-to-one.
  
-->

<hibernate-mapping 
	package="org.hibernate.test.naturalid.immutable"
	default-access="field">
	
	<class name="Parent" table="Parent">
		<id name="id">
			<generator class="increment"/>
		</id>
		
		<property name="name"/>
		
		<bag name="children" inverse="true" cascade="all">
			<key column="parent" />
			<one-to-many class="Child" />
		</bag>

	</class>

	<class name="Child" table="Child">
		<id name="id">
			<generator class="increment"/>
		</id>
		
		<natural-id mutable="false">
			<many-to-one name="parent" class="Parent" />
			<property name="name"/>
		</natural-id>
	</class>
	
</hibernate-mapping>

Other Hibernate examples (source code examples)

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