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

auto, carmodel, joined, joined, lazy, manufacturer, manufacturer, model, modelz, modelz, property, table, 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" 
                 version="2.0">
    <!-- no grammar specified should pass -->
    <persistence-unit-metadata>
        <persistence-unit-defaults>
            <cascade-persist/>
        </persistence-unit-defaults>
    </persistence-unit-metadata>
    <package>org.hibernate.test.annotations.xml.ejb3
    <table-generator name="generator" table="table_id"/>
    <named-query name="manufacturer.findAll">
        <query>select m from Manufacturer m
    </named-query>
    <entity class="Model" access="PROPERTY" name="ModelZ" metadata-complete="true">
        <table name="ModelZ">
        </table>
        <inheritance strategy="JOINED"/>
        <attributes>
            <id name="id">
                <column name="fld_id"/>
                <generated-value strategy="TABLE" generator="generator"/>
            </id>
            <basic name="unknownProperty"/>
            <many-to-one name="manufacturer" fetch="LAZY">
                <join-column name="manufacturer_pk"/>
            </many-to-one>
        </attributes>
    </entity>
    <entity class="CarModel" metadata-complete="true">
        <primary-key-join-column name="model_id"/>
        <inheritance strategy="JOINED"/>
        <named-query name="allModelsPerManufacturer">
            <query>from ModelZ m where m.manufacturer = :manufacturer
            <hint name="org.hibernate.timeout" value="200"/>
        </named-query>
        <exclude-default-listeners/>
        <exclude-superclass-listeners/>
        <attributes>
            <basic name="year" optional="false">
                <temporal>DATE
            </basic>
        </attributes>
    </entity>
    <entity class="Manufacturer">
        <attributes>
            <id name="id">
                <generated-value strategy="AUTO"/>
            </id>
            <one-to-many name="models" mapped-by="manufacturer"/>
        </attributes>
    </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.