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

Hibernate example source code file (orm.xml)

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

administration, joined, lazy, loglistener, loglistener, match, match, sequence, sequence, socialsecurityphysicalaccount, tennismatch, utf-8, utf-8

The Hibernate orm.xml source code

<?xml version="1.0" encoding="UTF-8"?>

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
                 version="2.0"
        >
    <persistence-unit-metadata>
        <persistence-unit-defaults>
            <schema>myschema
            <catalog>mycatalog
            <cascade-persist/>
            <entity-listeners>
                <entity-listener class="org.hibernate.test.annotations.reflection.OtherLogListener">
                    <post-update method-name="log"/>
                </entity-listener>
            </entity-listeners>
        </persistence-unit-defaults>
    </persistence-unit-metadata>
    <package>org.hibernate.test.annotations.reflection
    <entity class="Administration">
        <table name="tbl_admin">
            <unique-constraint>
                <column-name>firstname
                <column-name>lastname
            </unique-constraint>
        </table>
        <secondary-table name="admin2">
            <primary-key-join-column name="admin_id" referenced-column-name="id"/>
            <unique-constraint>
                <column-name>address
            </unique-constraint>
        </secondary-table>
        <sequence-generator name="seqhilo" sequence-name="seqhilo"/>
        <table-generator name="table" table="tablehilo"/>
        <entity-listeners>
            <entity-listener class="LogListener">
                <pre-persist method-name="log"/>
                <post-load method-name="noLog"/>
            </entity-listener>
        </entity-listeners>
        <pre-persist method-name="calculate"/>
        <attributes>
            <id name="id">
                <column name="fld_id"/>
                <generated-value generator="generator" strategy="SEQUENCE"/>
                <temporal>DATE
                <sequence-generator name="generator" sequence-name="seq"/>
            </id>
            <version name="version"/>
            <one-to-one name="defaultBusTrip" fetch="LAZY" mapped-by="test">
                <primary-key-join-column name="pk"/>
                <cascade>
                    <cascade-all/>
                    <cascade-persist/>
                    <cascade-merge/>
                    <cascade-remove/>
                    <cascade-refresh/>
                </cascade>
            </one-to-one>
            <transient name="transientField"/>
        </attributes>
    </entity>
    <entity class="Match">
        <inheritance strategy="JOINED"/>
        <named-query name="allmatches">
            <query>select m from Match m
            <hint name="org.hibernate.timeout" value="200"/>
        </named-query>
        <named-query name="matchbyid">
            <query>select m from Match m where m.id = :id
            <hint name="org.hibernate.timeout" value="200"/>
        </named-query>
        <named-native-query name="allmatches" result-set-mapping="matchrs">
            <query>select m from Match m
            <hint name="org.hibernate.timeout" value="200"/>
        </named-native-query>
        <named-native-query name="matchbyid" result-set-mapping="matchrs">
            <query>select m from Match m where m.id = :id
            <hint name="org.hibernate.timeout" value="200"/>
        </named-native-query>
        <sql-result-set-mapping name="matchrs">
            <entity-result entity-class="org.hibernate.test.annotations.reflection.Match">
                <field-result name="competitor1Point" column="competitor1Point"/>
            </entity-result>
            <column-result name="competitor1Point"/>
        </sql-result-set-mapping>
        <exclude-default-listeners/>
        <exclude-superclass-listeners/>
        <entity-listeners>
            <entity-listener class="LogListener">
                <pre-persist method-name="log"/>
                <post-load method-name="noLog"/>
            </entity-listener>
        </entity-listeners>
        <attributes>
            <embedded name="playerASSN"/>
        </attributes>
    </entity>
    <entity class="TennisMatch">
        <primary-key-join-column name="id"/>
        <attribute-override name="net">
            <column name="fld_net"/>
        </attribute-override>
        <attribute-override name="ground">
            <column name="fld_ground" unique="true" scale="2"/>
        </attribute-override>
        <association-override name="referer">
            <join-column name="referer_id" referenced-column-name="id"/>
        </association-override>
    </entity>
    <entity class="SocialSecurityPhysicalAccount">
        <id-class class="org.hibernate.test.annotations.reflection.SocialSecurityNumber"/>
        <discriminator-value>Physical
        <discriminator-column length="34"/>
    </entity>
</entity-mappings>

Other Hibernate examples (source code examples)

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