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

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

This example Hibernate source code file (Product.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, dtd, hibernate/hibernate, lineitem, lineitem, mapping, mapping, product, public, this

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

<!-- 

  This mapping demonstrates 

     (1) use of a derived property which performs a
         subselect against an associated table
         
     (2) use of <synchronize/> to ensure that auto-flush
         works correctly for an entity with a property
         derived from another table
         
     
-->

    <class name="Product">
    	<synchronize table="LineItem"/>
    
    	<id name="productId"
    		length="10">
    		<generator class="assigned"/>
    	</id>
    	
    	<property name="description" 
    		not-null="true" 
    		length="200"/>
    	<property name="price" length="3" column="cost"/>
    	<property name="numberAvailable"/>
    	
    	<property name="numberOrdered"
    		formula="( select sum(li.quantity) from LineItem li where li.productId = productId )"/>
	</class>

</hibernate-mapping>

Other Hibernate examples (source code examples)

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