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

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

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

abstract, abstractproxy, b, bar, dtd, foo, foo, fooproxy, fooproxy, many, many, mapping, one, one

The Hibernate FooBarCopy.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" package="org.hibernate.test.legacy">

    <!-- a slightly modified copy of FooBar.hbm.xml from the legacy test package -->

    <class
		name="Foo"
		table="`foos`"
		proxy="FooProxy"
		discriminator-value="F"
		batch-size="4"
		dynamic-insert="true"
		dynamic-update="true"
		select-before-update="true">

		<id name="key" type="string">
			<column name="`foo_idcolumnname123`" length="36"/>
			<generator class="uuid.hex">
				<param name="seperator">:
			</generator>
		</id>

		<discriminator column="`foo_subclass_1234`" type="character" force="true"/>
		<version name="version"/>

		<many-to-one name="foo" class="Foo">
				<column name="foo" length="36" index="fbmtoidx"/>
		</many-to-one>

		<property name="long">
			<column name="long_" index="fbmtoidx" unique-key="abc" not-null="true"/>
		</property>
		<property name="integer">
				<column name="`integer__`" unique-key="abc" not-null="true"/>
		</property>
		<property name="float">
				<column name="float_" unique-key="abc" not-null="true" check="float_ > 0.0"/>
		</property>
		<property name="x"/>
		<property name="double" column="double_"/>

		<primitive-array name="bytes" table="foobytes">
			<key column="id"/>
			<index column="i"/>
			<element column="byte_" type="byte"/>
		</primitive-array>

		<property name="date" type="date" column="date_"/>
		<property name="timestamp" type="timestamp" column="timestamp_"/>
		<property name="boolean" column="boolean_"/>
		<property name="bool" column="bool_"/>
		<property name="null" column="null_"/>
		<property name="short" column="short_"/>
		<property name="char" column="char_"/>
		<property name="zero" column="zero_"/>
		<property name="int" column="int_"/>
		<property name="string">
            <column name="string_" length="48" index="fbstridx"/>
		</property>
		<property name="byte" column="byte_"/>
		<property name="yesno" type="yes_no"/>
		<property name="blob" type="org.hibernate.test.legacy.Foo$Struct" column="blobb_"/>
		<property name="nullBlob" type="serializable"/>
		<property name="binary" column="bin_"/>
		<property name="theLocale" access="field" column="`localeayzabc123`"/>

		<property name="formula" formula="int_/2"/>

		<property name="custom" type="org.hibernate.test.legacy.DoubleStringType" access="field">
			<column name="first_name" length="66"/>
			<column name="surname" length="66"/>
		</property>
		<component name="nullComponent">
			<property name="name" column="null_cmpnt_"/>
		</component>

		<join table="jointable">
			<key column="fooid" on-delete="cascade"/>
			<property name="joinedProp"/>
		</join>

		<subclass
			name="Trivial"
			proxy="FooProxy"
			discriminator-value="T"/>

		<subclass
			name="Abstract"
			proxy="AbstractProxy"
			discriminator-value="null">
				<set name="abstracts" batch-size="2">
					<key column="abstract_id"/>
					<one-to-many class="Abstract"/>
				</set>
				<property name="time" column="the_time"/>

				<subclass
					name="Bar"
					proxy="BarProxy"
					discriminator-value="B">
					<property name="barString">
						<column name="bar_string" length="24"/>
					</property>
					<any name="object" meta-type="character" id-type="long" cascade="all">
						<meta-value value="O" class="One"/>
						<meta-value value="M" class="Many"/>
						<column name="clazz" length="100"/>
						<column name="gen_id"/>
					</any>
					<join table="bar_join_table">
						<key column="bar_id"/>
						<property name="name" column="name_name"/>
					</join>
				</subclass>
		</subclass>
	</class>

	<class name="One" table="one">
		<id name="key" column="one_key">
			<generator class="native" />
		</id>
		<property name="x"/>
		<property column="one_value" name="value"/>
	</class>

    <class name="Many" table="many">
        <id name="key" column="many_key">
            <generator class="native" />
        </id>
        <property name="x"/>
    </class>

</hibernate-mapping>

Other Hibernate examples (source code examples)

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