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

between, between, cat_id, cat_id, category, doctype, lineitem, prod_cat, prod_id, prod_id, product, product, stock_num, system

The Hibernate Product.hbm.xml source code

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
        SYSTEM
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="org.hibernate.test.filter">

    <class name="Product" table="PRODUCT">
    	<id name="id" column="PROD_ID" >
    		<generator class="native"/>
    	</id>

    	<property name="name" type="string"/>
	    <property name="stockNumber" column="STOCK_NUM" type="int"/>
	    <property name="weightPounds">
	    	<column name="weight_kg" 
	    		not-null="true" 
	    		write="0.453E0 * ?"
	    		read="weight_kg / 0.453E0"/>
	    </property>

	    <property name="effectiveStartDate" column="eff_start_dt" type="java.util.Date"/>
	    <property name="effectiveEndDate" column="eff_end_dt" type="java.util.Date"/>

	    <set cascade="none" inverse="true" name="orderLineItems">
		    <key column="PROD_ID"/>
		    <one-to-many class="LineItem"/>
	    </set>

	    <set cascade="all" inverse="false" name="categories" fetch="join" table="PROD_CAT" >
		    <key column="PROD_ID"/>
		    <many-to-many class="Category" column="CAT_ID" fetch="join" >
	            <filter name="effectiveDate" condition=":asOfDate BETWEEN eff_start_dt and eff_end_dt"/>
			    <filter name="cat" condition="CAT_ID = :catId"/> 
            </many-to-many>
	    </set>

	    <filter name="effectiveDate" condition=":asOfDate BETWEEN eff_start_dt and eff_end_dt"/>
	    <filter name="heavyProducts" condition=":weightKilograms < weight_kg"/>

	</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.