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

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

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

cdata, cdata, doctype, dtd, end, for, hibernate/hibernate, insert, mapping, mapping, on, or, trigger, trigger

The Hibernate MyEntity.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.generatedkeys.select" default-access="field">

    <class name="MyEntity" table="my_entity">

    	<id name="id">
    		<generator class="select"/>
    	</id>
        <natural-id>
            <property name="name"/>
        </natural-id>
	</class>

    <database-object>
        <create>
            <![CDATA[CREATE OR REPLACE TRIGGER t_i_my_entity
            BEFORE INSERT ON my_entity
            FOR EACH ROW
            BEGIN
                select nvl( max(id), 0 ) + 1
                into :new.id
                from my_entity;
            END;]]>
        </create>
        <drop>
            <![CDATA[DROP TRIGGER t_i_my_entity]]>
        </drop>
        <dialect-scope name="org.hibernate.dialect.Oracle9iDialect"/>
        <dialect-scope name="org.hibernate.dialect.Oracle10gDialect"/>
    </database-object>

</hibernate-mapping>

Other Hibernate examples (source code examples)

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