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

Hibernate example source code file (persistence.xml)

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

jacc, jacc, regionname, regionname, resource_local, resource_local, utf-8, utf-8

The Hibernate persistence.xml source code

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">
    <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
        <jar-file>@buildDirName@/packages/externaljar.jar
        <class>org.hibernate.ejb.test.Cat
		<class>org.hibernate.ejb.test.Kitten
        <class>org.hibernate.ejb.test.Distributor
        <class>org.hibernate.ejb.test.Item
        <exclude-unlisted-classes>true
        <properties>
            <!-- custom scanner test -->
            <property name="hibernate.ejb.resource_scanner" value="org.hibernate.ejb.test.packaging.CustomScanner"/>

            <property name="hibernate.dialect" value="@db.dialect@"/>
            <property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
            <property name="hibernate.connection.username" value="@jdbc.user@"/>
            <property name="hibernate.connection.password" value="@jdbc.pass@"/>
            <property name="hibernate.connection.url" value="@jdbc.url@"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.region_prefix" value="hibernate.test"/>
            <property name="hibernate.jdbc.use_streams_for_binary" value="true"/>
            <property name="hibernate.jdbc.batch_size" value="0"/>
            <property name="hibernate.max_fetch_depth" value="3"/>
            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
            <property name="hibernate.generate_statistics" value="true"/>
			<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
            <property name="hibernate.ejb.naming_strategy" value="org.hibernate.ejb.test.MyNamingStrategy"/>
            <!-- test naming strategy and fall back to element content -->
            <!-- property name="hibernate.ejb.naming_strategy">org.hibernate.ejb.test.MyNamingStrategy

            <!-- cache configuration -->
            <property name="hibernate.ejb.classcache.org.hibernate.ejb.test.Item" value="read-write"/>
            <property name="hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors"
                      value="read-write, RegionName"/>

            <!-- event overriding -->
            <property name="hibernate.ejb.event.pre-insert" value="org.hibernate.ejb.test.NoOpListener"/>
            <!-- remove JACC and validator -->

            <!-- alternatively to  declarations, you can use a regular hibernate.cfg.xml file -->
            <!-- property name="hibernate.ejb.cfgfile" value="/org/hibernate/ejb/test/hibernate.cfg.xml"/ -->
        </properties>
    </persistence-unit>
</persistence>

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate persistence.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 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.