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

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

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

doctype, doctype, dtd, e, hhh-6551, hhh-6551, hibernate/hibernate, mapping, mapping, p, parttimeemployee, parttimeemployee, person, type

The Hibernate SimpleInheritance.hbm.xml source code

<?xml version="1.0"?>
<hibernate-mapping package="org.hibernate.test.discriminator" default-access="field"
                   xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
                   xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!--
<!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.discriminator"
	default-access="field">
-->
<!--

  This mapping demonstrates a simple table-per-hierarchy mapping strategy;
  each subclass has simple properties

-->

	<class name="Person"
		discriminator-value="P">
		
		<id name="id" 
			column="person_id" 
			unsaved-value="0">
			<generator class="assigned"/>
		</id>
		
        <discriminator column="TYPE" type="character"/>

		<property name="name"
			not-null="true"
			length="80"/>

		<property name="sex"
			not-null="true"
			update="false"/>
		
		<subclass name="Employee"
			discriminator-value="E">
				<property name="title" length="20"/>
				<property name="salary" />
            <!-- commented out until HHH-6551 is fixed
			<subclass name="PartTimeEmployee" discriminator-value="M">
				<property name="percent"/>
			</subclass>
			-->
   		</subclass>
		
		<subclass name="Customer" 
			discriminator-value="C">
				<property name="comments"/>
		</subclass>
		
	</class>
	

</hibernate-mapping>

Other Hibernate examples (source code examples)

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