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

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

This example Hibernate source code file (Parent.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, dtd, hibernate/hibernate, mapping, mapping, parent, parent, parentchild, parentchild, public, this

The Hibernate Parent.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 demonstrates how to use a composite
  element mapping to model a parent/child association.
     
-->

<hibernate-mapping 
	package="org.hibernate.test.compositeelement">
	
	<import class="Child"/>

	<class name="Parent">
		<id name="id" 
			column="parent_id">
			<generator class="increment"/>
		</id>
		<property name="name"/>
		<set name="children" table="ParentChild">
			<key column="parent_id"/>
			<composite-element class="Child">
				<parent name="parent"/>
				<property name="name" not-null="true"/>
				<property name="bio"/>
				<property name="bioLength" formula="length(bio)"/>
				<property name="position">
					<column name="child_position"
						not-null="true"
						read="child_position + 1"
						write="? - 1"/>
				</property>				
			</composite-element>
		</set>
	</class>
	

</hibernate-mapping>

Other Hibernate examples (source code examples)

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