Hibernate SVN: r19809 - in core/branches/gradle2/hibernate-entitymanager: src and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-06-23 23:59:36 -0400 (Wed, 23 Jun 2010)
New Revision: 19809
Added:
core/branches/gradle2/hibernate-entitymanager/src/intgTest/
Removed:
core/branches/gradle2/hibernate-entitymanager/.cvsignore
core/branches/gradle2/hibernate-entitymanager/build.xml
core/branches/gradle2/hibernate-entitymanager/pom.xml
core/branches/gradle2/hibernate-entitymanager/src/test/
Modified:
core/branches/gradle2/hibernate-entitymanager/hibernate-entitymanager.gradle
Log:
semi working entitymanager module (see note in .gradle)
Deleted: core/branches/gradle2/hibernate-entitymanager/.cvsignore
===================================================================
--- core/branches/gradle2/hibernate-entitymanager/.cvsignore 2010-06-24 03:45:23 UTC (rev 19808)
+++ core/branches/gradle2/hibernate-entitymanager/.cvsignore 2010-06-24 03:59:36 UTC (rev 19809)
@@ -1,4 +0,0 @@
-build.properties
-build
-target
-test_output
Deleted: core/branches/gradle2/hibernate-entitymanager/build.xml
===================================================================
--- core/branches/gradle2/hibernate-entitymanager/build.xml 2010-06-24 03:45:23 UTC (rev 19808)
+++ core/branches/gradle2/hibernate-entitymanager/build.xml 2010-06-24 03:59:36 UTC (rev 19809)
@@ -1,29 +0,0 @@
-<!-- $Id: build.xml 15105 2008-08-18 19:20:37Z hardy.ferentschik $ -->
-<!--
- Hibernate Entity Manager ANT build script.
--->
-
-<project name="HibernateEntityManager" basedir=".">
-
- <target name="generate-metamodel" depends="uptodate.check" unless="metamodel.build.notRequired">
- <echo>Processing JPA annotations for metamodel generation</echo>
- <mkdir dir="${target.dir}"/>
- <javac srcdir="${src.dir}"
- destdir="${target.dir}"
- failonerror="false"
- fork="true"
- executable="${jdk16_home}/bin/javac"
- target="1.5"
- classpath="${classpath}">
- <compilerarg value="-proc:only"/>
- </javac>
- <touch file="${target.dir}/.staleflag"/>
- </target>
-
- <target name="uptodate.check">
- <uptodate property="metamodel.build.notRequired" targetfile="${target.dir}/.staleflag">
- <srcfiles dir="${src.dir}" includes="**/*.java"/>
- </uptodate>
- </target>
-
-</project>
Modified: core/branches/gradle2/hibernate-entitymanager/hibernate-entitymanager.gradle
===================================================================
--- core/branches/gradle2/hibernate-entitymanager/hibernate-entitymanager.gradle 2010-06-24 03:45:23 UTC (rev 19808)
+++ core/branches/gradle2/hibernate-entitymanager/hibernate-entitymanager.gradle 2010-06-24 03:59:36 UTC (rev 19809)
@@ -1,67 +1,64 @@
+apply plugin: 'java'
+apply plugin: org.hibernate.gradle.util.IntegrationTestPlugin
+
+// todo : there are test failures due to issues with how 'bundles' are handled.
+// My guess is using TCCL as the tests try to is not valid in Gradle.
+
+buildscript {
+ repositories {
+ mavenRepo name: 'jboss-nexus', urls: "https://repository.jboss.org/nexus/content/groups/public/"
+ mavenRepo urls: "file://" + System.getProperty('user.home') + "/.m2/repository/"
+ }
+ dependencies {
+ classpath libraries.jpa_modelgen
+ }
+}
+
dependencies {
shrinkwrapVersion = '1.0.0-alpha-6'
- compile(
- project(':hibernate-core'),
- project(':hibernate-annotations'),
- [group: 'dom4j', name: 'dom4j', version: dom4jVersion],
- [group: 'org.hibernate', name: 'hibernate-commons-annotations', version: annotationsCommonsVersion],
- [group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.0-api', version: jpaVersion],
- [group: 'javax.transaction', name: 'jta', version: jtaVersion],
- [group: 'javassist', name: 'javassist', version: javassistVersion]
- )
- testCompile(
- project(':hibernate-testing'),
- [group: 'cglib', name: 'cglib', version: cglibVersion],
- [group: 'org.hibernate', name: 'hibernate-jpamodelgen', version: '1.0.0.Final'],
- [group: 'org.jboss.shrinkwrap', name: 'shrinkwrap-api', version: shrinkwrapVersion],
- [group: 'org.jboss.shrinkwrap', name: 'shrinkwrap-impl-base', version: shrinkwrapVersion],
- [group: 'javax.validation', name: 'validation-api', version: javaxValidationVersion],
- [group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion]
- )
- testRuntime(
- [group: 'org.hibernate', name: 'hibernate-validator', version: hibernateValidatorVersion]
- )
+ compile( project(':hibernate-core') )
+ compile( project(':hibernate-annotations') )
+ compile( libraries.dom4j )
+ compile( libraries.commons_annotations )
+ compile( libraries.jpa )
+ compile( libraries.jta )
+ compile( libraries.javassist )
+ intgTestCompile( project(':hibernate-core').sourceSets.intgTest.classes )
+ intgTestCompile( libraries.junit )
+ intgTestCompile( libraries.jpa_modelgen )
+ intgTestCompile( libraries.shrinkwrap_api )
+ intgTestCompile( libraries.shrinkwrap )
+ intgTestCompile( libraries.validation )
+ intgTestCompile( libraries.slf4j_api )
+ intgTestRuntime( libraries.validator )
}
-processTestResources.doLast(
- {
- copy {
- from(sourceSets.test.java.srcDirs) {
- include '**/*.properties'
- include '**/*.xml'
- }
- into sourceSets.test.classesDir
- }
- }
-)
+procTargetDirName = buildDirName + "/generated-src/jpamodelgen"
+procTargetDir = dir( procTargetDirName )
+compileIntgTestJava {
+ configure( options ) {
+ fork( executable: java6Home.getJavacExecutable() )
+ compilerArgs = [ "-s", "$procTargetDir.dir.absolutePath" ]
+ }
+}
+compileIntgTestJava.dependsOn procTargetDir
+sourceSets.intgTest.java.srcDir procTargetDirName
-procTargetDir = dir(buildDirName + "/generated-src/jpamodelgen")
-if (hasProperty('jdk16_home')) {
- task generateTestStaticMetamodelClasses(dependsOn: procTargetDir) << {
- ant.javac(
- srcdir: file('src/test/java'),
- destdir: procTargetDir.dir,
- failonerror: false,
- fork: true,
- executable: "$jdk16_home/bin/javac",
- target: '1.5'
- ) {
- compilerArg(value: "-proc:only")
- sourceSets.test.runtimeClasspath.addToAntBuilder(ant, 'classpath')
- }
-
- sourceSets.test.java.srcDir(procTargetDir.dir);
+bundlesTargetDirName = "$buildDirName/bundles"
+bundlesTargetDir = dir( bundlesTargetDirName )
+task processIntgTestBundles {
+ copy {
+ from 'src/intgTest/bundles'
+ into bundlesTargetDir.dir
}
-
- compileTestJava.dependsOn generateTestStaticMetamodelClasses
-} else {
- test.enabled = false
- compileTestJava.enabled = false
}
+processIntgTestBundles.dependsOn bundlesTargetDir
+processIntgTestResources.dependsOn processIntgTestBundles
+
ideaModule {
- testSourceDirs.add(file('target/generated-src/jpamodelgen'))
+ testSourceDirs.add( file( procTargetDirName ) )
}
Deleted: core/branches/gradle2/hibernate-entitymanager/pom.xml
===================================================================
--- core/branches/gradle2/hibernate-entitymanager/pom.xml 2010-06-24 03:45:23 UTC (rev 19808)
+++ core/branches/gradle2/hibernate-entitymanager/pom.xml 2010-06-24 03:59:36 UTC (rev 19809)
@@ -1,202 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.6.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate Entity Manager</name>
- <description>Hibernate Entity Manager</description>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.0-api</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-testing</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.shrinkwrap</groupId>
- <artifactId>shrinkwrap-api</artifactId>
- <version>1.0.0-alpha-6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.shrinkwrap</groupId>
- <artifactId>shrinkwrap-impl-base</artifactId>
- <version>1.0.0-alpha-6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!--
- Only really needed for the antrun plugin defined below (which in turn is only really needed
- to work around a missing feature on the compile plugin; lovely no?). However I have not
- found a way to declare this dependency local to the antrun plugin and then reference it
- from the <javac />'s <classpath /> :(
- -->
- <groupId>${project.groupId}</groupId>
- <artifactId>hibernate-jpamodelgen</artifactId>
- <version>1.0.0.Final</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <!-- Use the jpa-api defined here, crossing fingers they match up signature-wise -->
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.0-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <filtering>true</filtering>
- <directory>src/test/resources</directory>
- </testResource>
- <testResource>
- <filtering>true</filtering>
- <directory>src/test/bundles</directory>
- <targetPath>../bundles</targetPath>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <groupId>org.jboss.maven.plugins</groupId>
- <artifactId>maven-injection-plugin</artifactId>
- <configuration>
- <bytecodeInjections>
- <bytecodeInjection>
- <expression>${pom.version}</expression>
- <targetMembers>
- <methodBodyReturn>
- <className>org.hibernate.ejb.Version</className>
- <methodName>getVersionString</methodName>
- </methodBodyReturn>
- </targetMembers>
- </bytecodeInjection>
- </bytecodeInjections>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <!-- Define one configuration outside executions and without a phase in order to allow 'mvn antrun:run' -->
- <configuration>
- <tasks>
- <property name="target.dir" value="${project.build.directory}/generated-src/jpamodelgen" />
- <property name="src.dir" value="${project.build.testSourceDirectory}" />
- <property name="jdk16_home" value="${jdk16_home}" />
- <property name="classpath" refid="maven.test.classpath" />
- <ant antfile="${basedir}/build.xml">
- <target name="generate-metamodel" />
- </ant>
- </tasks>
- </configuration>
- <executions>
- <execution>
- <id>process_annotations</id>
- <phase>process-test-sources</phase>
- <configuration>
- <!-- No additional configuration needed. Unbound configuration gets inherited. (Feels wrong, but that's how it is) -->
- <testSourceRoot>${project.build.directory}/generated-src/jpamodelgen</testSourceRoot>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/*TestCase.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>doc</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.jboss.maven.plugins</groupId>
- <artifactId>maven-jdocbook-plugin</artifactId>
- <configuration>
- <sourceDocumentName>master.xml</sourceDocumentName>
- <sourceDirectory>${basedir}/src/main/docbook</sourceDirectory>
- <masterTranslation>en</masterTranslation>
- <imageResource>
- <directory>${basedir}/src/main/docbook/en/images</directory>
- </imageResource>
- </configuration>
- <executions>
- <execution>
- <id>make-doc</id>
- <phase>package</phase>
- <goals>
- <goal>resources</goal>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
Copied: core/branches/gradle2/hibernate-entitymanager/src/intgTest (from rev 19681, core/branches/gradle2/hibernate-entitymanager/src/test)
13 years, 10 months
Hibernate SVN: r19808 - in core/branches/gradle2/hibernate-ehcache: src and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-06-23 23:45:23 -0400 (Wed, 23 Jun 2010)
New Revision: 19808
Added:
core/branches/gradle2/hibernate-ehcache/src/intgTest/
Removed:
core/branches/gradle2/hibernate-ehcache/pom.xml
core/branches/gradle2/hibernate-ehcache/src/test/
Modified:
core/branches/gradle2/hibernate-ehcache/hibernate-ehcache.gradle
core/branches/gradle2/hibernate-ehcache/src/intgTest/java/org/hibernate/cache/EhCacheTest.java
Log:
working ehcache module (see todo in .gradle)
Modified: core/branches/gradle2/hibernate-ehcache/hibernate-ehcache.gradle
===================================================================
--- core/branches/gradle2/hibernate-ehcache/hibernate-ehcache.gradle 2010-06-24 03:40:53 UTC (rev 19807)
+++ core/branches/gradle2/hibernate-ehcache/hibernate-ehcache.gradle 2010-06-24 03:45:23 UTC (rev 19808)
@@ -1,15 +1,10 @@
-dependencies {
- ehcacheVersion = '1.5.0'
+apply plugin: 'java'
+apply plugin: org.hibernate.gradle.util.IntegrationTestPlugin
- compile (
- project(':hibernate-core'),
- [group: 'net.sf.ehcache', name: 'ehcache', version: ehcacheVersion]
- )
- testCompile (
- project(':hibernate-testing')
- )
- testRuntime (
- [group: 'javassist', name: 'javassist', version: javassistVersion],
- [group: 'cglib', name: 'cglib', version: cglibVersion]
- )
+// todo : does this single test really need to be run against ever database in the matrix?
+
+dependencies {
+ compile( project( ':hibernate-core' ) )
+ compile( [group: 'net.sf.ehcache', name: 'ehcache', version: '1.5.0'] )
+ intgTestCompile( project(':hibernate-core').sourceSets.intgTest.classes )
}
\ No newline at end of file
Deleted: core/branches/gradle2/hibernate-ehcache/pom.xml
===================================================================
--- core/branches/gradle2/hibernate-ehcache/pom.xml 2010-06-24 03:40:53 UTC (rev 19807)
+++ core/branches/gradle2/hibernate-ehcache/pom.xml 2010-06-24 03:45:23 UTC (rev 19808)
@@ -1,54 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.6.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-ehcache</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate Ehcache Integration</name>
- <description>Integration of Hibernate with Ehcache</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-testing</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
Copied: core/branches/gradle2/hibernate-ehcache/src/intgTest (from rev 19683, core/branches/gradle2/hibernate-ehcache/src/test)
Modified: core/branches/gradle2/hibernate-ehcache/src/intgTest/java/org/hibernate/cache/EhCacheTest.java
===================================================================
--- core/branches/gradle2/hibernate-ehcache/src/test/java/org/hibernate/cache/EhCacheTest.java 2010-06-02 21:38:28 UTC (rev 19683)
+++ core/branches/gradle2/hibernate-ehcache/src/intgTest/java/org/hibernate/cache/EhCacheTest.java 2010-06-24 03:45:23 UTC (rev 19808)
@@ -26,8 +26,8 @@
import junit.framework.Test;
import org.hibernate.cfg.Environment;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import org.hibernate.test.cache.BaseCacheProviderTestCase;
+import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.testing.cache.BaseCacheProviderTestCase;
/**
* @author Emmanuel Bernard
13 years, 10 months
Hibernate SVN: r19807 - core/branches/gradle2/hibernate-c3p0.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-06-23 23:40:53 -0400 (Wed, 23 Jun 2010)
New Revision: 19807
Removed:
core/branches/gradle2/hibernate-c3p0/pom.xml
Modified:
core/branches/gradle2/hibernate-c3p0/hibernate-c3p0.gradle
Log:
working c3p0 module
Modified: core/branches/gradle2/hibernate-c3p0/hibernate-c3p0.gradle
===================================================================
--- core/branches/gradle2/hibernate-c3p0/hibernate-c3p0.gradle 2010-06-23 22:33:43 UTC (rev 19806)
+++ core/branches/gradle2/hibernate-c3p0/hibernate-c3p0.gradle 2010-06-24 03:40:53 UTC (rev 19807)
@@ -1,8 +1,6 @@
-dependencies {
- c3p0Version = '0.9.1'
+apply plugin: 'java'
- compile (
- project(':hibernate-core'),
- [group: 'c3p0', name: 'c3p0', version: c3p0Version]
- )
+dependencies {
+ compile( project( ':hibernate-core' ) )
+ compile( [group: 'c3p0', name: 'c3p0', version: '0.9.1'] )
}
\ No newline at end of file
Deleted: core/branches/gradle2/hibernate-c3p0/pom.xml
===================================================================
--- core/branches/gradle2/hibernate-c3p0/pom.xml 2010-06-23 22:33:43 UTC (rev 19806)
+++ core/branches/gradle2/hibernate-c3p0/pom.xml 2010-06-24 03:40:53 UTC (rev 19807)
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.6.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-c3p0</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate C3P0 ConnectionProvider</name>
- <description>C3P0-based implementation of the Hibernate ConnectionProvder contract</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>c3p0</groupId>
- <artifactId>c3p0</artifactId>
- <version>0.9.1</version>
- </dependency>
- </dependencies>
-</project>
13 years, 10 months
Hibernate SVN: r19806 - core/trunk/core/src/main/java/org/hibernate/cfg.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-23 18:33:43 -0400 (Wed, 23 Jun 2010)
New Revision: 19806
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java
Log:
Clean import statements
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java 2010-06-23 22:33:24 UTC (rev 19805)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java 2010-06-23 22:33:43 UTC (rev 19806)
@@ -28,19 +28,18 @@
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.EntityMode;
-import org.hibernate.engine.jdbc.JdbcSupport;
-import org.hibernate.tuple.entity.EntityTuplizerFactory;
-import org.hibernate.tuple.component.ComponentTuplizerFactory;
import org.hibernate.cache.QueryCacheFactory;
import org.hibernate.cache.RegionFactory;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.dialect.Dialect;
+import org.hibernate.engine.jdbc.JdbcSupport;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.jdbc.BatcherFactory;
import org.hibernate.jdbc.util.SQLStatementLogger;
import org.hibernate.transaction.TransactionFactory;
import org.hibernate.transaction.TransactionManagerLookup;
+import org.hibernate.tuple.entity.EntityTuplizerFactory;
/**
* Settings that affect the behaviour of Hibernate at runtime.
13 years, 10 months
Hibernate SVN: r19805 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-23 18:33:24 -0400 (Wed, 23 Jun 2010)
New Revision: 19805
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml
Log:
HHH-5337 Documentation for hibernate.hbm2ddl.import_files
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml 2010-06-23 22:33:00 UTC (rev 19804)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml 2010-06-23 22:33:24 UTC (rev 19805)
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
@@ -22,1746 +22,1663 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "../HIBERNATE_-_Relational_Persistence_for_Idiomatic_Java.ent">
%BOOK_ENTITIES;
-
]>
-
<chapter id="session-configuration" revision="1">
- <title>Configuration</title>
-
- <para>
- Hibernate is designed to operate in many different environments and, as such, there
- is a broad range of configuration parameters. Fortunately, most have sensible
- default values and Hibernate is distributed with an example
- <literal>hibernate.properties</literal> file in <literal>etc/</literal> that displays
- the various options. Simply put the example file in your classpath and customize it to suit your needs.
- </para>
+ <title>Configuration</title>
- <section id="configuration-programmatic" revision="1">
- <title>Programmatic configuration</title>
+ <para>Hibernate is designed to operate in many different environments and,
+ as such, there is a broad range of configuration parameters. Fortunately,
+ most have sensible default values and Hibernate is distributed with an
+ example <literal>hibernate.properties</literal> file in
+ <literal>etc/</literal> that displays the various options. Simply put the
+ example file in your classpath and customize it to suit your needs.</para>
- <para>
- An instance of <classname>org.hibernate.cfg.Configuration</classname> represents an entire set of mappings
- of an application's Java types to an SQL database. The <classname>org.hibernate.cfg.Configuration</classname>
- is used to build an immutable <interfacename>org.hibernate.SessionFactory</interfacename>. The mappings
- are compiled from various XML mapping files.
- </para>
+ <section id="configuration-programmatic" revision="1">
+ <title>Programmatic configuration</title>
- <para>
- You can obtain a <classname>org.hibernate.cfg.Configuration</classname> instance by instantiating
- it directly and specifying XML mapping documents. If the mapping files are in the classpath,
- use <literal>addResource()</literal>. For example:
- </para>
+ <para>An instance of
+ <classname>org.hibernate.cfg.Configuration</classname> represents an
+ entire set of mappings of an application's Java types to an SQL database.
+ The <classname>org.hibernate.cfg.Configuration</classname> is used to
+ build an immutable
+ <interfacename>org.hibernate.SessionFactory</interfacename>. The mappings
+ are compiled from various XML mapping files.</para>
- <programlisting role="JAVA"><![CDATA[Configuration cfg = new Configuration()
+ <para>You can obtain a
+ <classname>org.hibernate.cfg.Configuration</classname> instance by
+ instantiating it directly and specifying XML mapping documents. If the
+ mapping files are in the classpath, use <literal>addResource()</literal>.
+ For example:</para>
+
+ <programlisting role="JAVA">Configuration cfg = new Configuration()
.addResource("Item.hbm.xml")
- .addResource("Bid.hbm.xml");]]></programlisting>
+ .addResource("Bid.hbm.xml");</programlisting>
- <para>
- An alternative way is to specify the mapped class and
- allow Hibernate to find the mapping document for you:
- </para>
+ <para>An alternative way is to specify the mapped class and allow
+ Hibernate to find the mapping document for you:</para>
- <programlisting role="JAVA"><![CDATA[Configuration cfg = new Configuration()
+ <programlisting role="JAVA">Configuration cfg = new Configuration()
.addClass(org.hibernate.auction.Item.class)
- .addClass(org.hibernate.auction.Bid.class);]]></programlisting>
+ .addClass(org.hibernate.auction.Bid.class);</programlisting>
- <para>
- Hibernate will then search for mapping files named <filename>/org/hibernate/auction/Item.hbm.xml</filename>
- and <filename>/org/hibernate/auction/Bid.hbm.xml</filename> in the classpath. This approach eliminates any
- hardcoded filenames.
- </para>
-
- <para>
- A <classname>org.hibernate.cfg.Configuration</classname> also allows you to specify configuration
- properties. For example:
- </para>
+ <para>Hibernate will then search for mapping files named
+ <filename>/org/hibernate/auction/Item.hbm.xml</filename> and
+ <filename>/org/hibernate/auction/Bid.hbm.xml</filename> in the classpath.
+ This approach eliminates any hardcoded filenames.</para>
- <programlisting role="JAVA"><![CDATA[Configuration cfg = new Configuration()
+ <para>A <classname>org.hibernate.cfg.Configuration</classname> also allows
+ you to specify configuration properties. For example:</para>
+
+ <programlisting role="JAVA">Configuration cfg = new Configuration()
.addClass(org.hibernate.auction.Item.class)
.addClass(org.hibernate.auction.Bid.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
.setProperty("hibernate.connection.datasource", "java:comp/env/jdbc/test")
- .setProperty("hibernate.order_updates", "true");]]></programlisting>
-
- <para>
- This is not the only way to pass configuration properties to Hibernate.
- Some alternative options include:
- </para>
+ .setProperty("hibernate.order_updates", "true");</programlisting>
- <orderedlist spacing="compact">
- <listitem>
- <para>
- Pass an instance of <classname>java.util.Properties</classname> to
- <literal>Configuration.setProperties()</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- Place a file named <filename>hibernate.properties</filename> in a root directory of the classpath.
- </para>
- </listitem>
- <listitem>
- <para>
- Set <literal>System</literal> properties using <literal>java -Dproperty=value</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- Include <literal><property></literal> elements in
- <literal>hibernate.cfg.xml</literal> (this is discussed later).
- </para>
- </listitem>
- </orderedlist>
+ <para>This is not the only way to pass configuration properties to
+ Hibernate. Some alternative options include:</para>
- <para>
- If you want to get started quickly<filename>hibernate.properties</filename> is the easiest approach.
- </para>
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>Pass an instance of <classname>java.util.Properties</classname>
+ to <literal>Configuration.setProperties()</literal>.</para>
+ </listitem>
- <para>
- The <classname>org.hibernate.cfg.Configuration</classname> is intended as a startup-time object that will
- be discarded once a <literal>SessionFactory</literal> is created.
- </para>
+ <listitem>
+ <para>Place a file named <filename>hibernate.properties</filename> in
+ a root directory of the classpath.</para>
+ </listitem>
- </section>
-
- <section id="configuration-sessionfactory">
- <title>Obtaining a SessionFactory</title>
+ <listitem>
+ <para>Set <literal>System</literal> properties using <literal>java
+ -Dproperty=value</literal>.</para>
+ </listitem>
- <para>
- When all mappings have been parsed by the <classname>org.hibernate.cfg.Configuration</classname>,
- the application must obtain a factory for <interfacename>org.hibernate.Session</interfacename> instances.
- This factory is intended to be shared by all application threads:
- </para>
+ <listitem>
+ <para>Include <literal><property></literal> elements in
+ <literal>hibernate.cfg.xml</literal> (this is discussed later).</para>
+ </listitem>
+ </orderedlist>
- <programlisting role="JAVA"><![CDATA[SessionFactory sessions = cfg.buildSessionFactory();]]></programlisting>
+ <para>If you want to get started
+ quickly<filename>hibernate.properties</filename> is the easiest
+ approach.</para>
- <para>
- Hibernate does allow your application to instantiate more than one
- <interfacename>org.hibernate.SessionFactory</interfacename>. This is useful if you are using more than
- one database.
- </para>
+ <para>The <classname>org.hibernate.cfg.Configuration</classname> is
+ intended as a startup-time object that will be discarded once a
+ <literal>SessionFactory</literal> is created.</para>
+ </section>
- </section>
+ <section id="configuration-sessionfactory">
+ <title>Obtaining a SessionFactory</title>
- <section id="configuration-hibernatejdbc" revision="1">
- <title>JDBC connections</title>
+ <para>When all mappings have been parsed by the
+ <classname>org.hibernate.cfg.Configuration</classname>, the application
+ must obtain a factory for
+ <interfacename>org.hibernate.Session</interfacename> instances. This
+ factory is intended to be shared by all application threads:</para>
- <para>
- It is advisable to have the <interfacename>org.hibernate.SessionFactory</interfacename> create and pool
- JDBC connections for you. If you take this approach, opening a <interfacename>org.hibernate.Session</interfacename>
- is as simple as:
- </para>
+ <programlisting role="JAVA">SessionFactory sessions = cfg.buildSessionFactory();</programlisting>
- <programlisting role="JAVA"><![CDATA[Session session = sessions.openSession(); // open a new Session]]></programlisting>
-
- <para>
- Once you start a task that requires access to the database, a JDBC connection will be obtained from
- the pool.
- </para>
+ <para>Hibernate does allow your application to instantiate more than one
+ <interfacename>org.hibernate.SessionFactory</interfacename>. This is
+ useful if you are using more than one database.</para>
+ </section>
- <para>
- Before you can do this, you first need to pass some JDBC connection properties to Hibernate. All Hibernate property
- names and semantics are defined on the class <classname>org.hibernate.cfg.Environment</classname>.
- The most important settings for JDBC connection configuration are outlined below.
- </para>
+ <section id="configuration-hibernatejdbc" revision="1">
+ <title>JDBC connections</title>
- <para>
- Hibernate will obtain and pool connections using <classname>java.sql.DriverManager</classname>
- if you set the following properties:
- </para>
+ <para>It is advisable to have the
+ <interfacename>org.hibernate.SessionFactory</interfacename> create and
+ pool JDBC connections for you. If you take this approach, opening a
+ <interfacename>org.hibernate.Session</interfacename> is as simple
+ as:</para>
- <table frame="topbot">
- <title>Hibernate JDBC Properties</title>
- <tgroup cols="2">
+ <programlisting role="JAVA">Session session = sessions.openSession(); // open a new Session</programlisting>
+
+ <para>Once you start a task that requires access to the database, a JDBC
+ connection will be obtained from the pool.</para>
+
+ <para>Before you can do this, you first need to pass some JDBC connection
+ properties to Hibernate. All Hibernate property names and semantics are
+ defined on the class <classname>org.hibernate.cfg.Environment</classname>.
+ The most important settings for JDBC connection configuration are outlined
+ below.</para>
+
+ <para>Hibernate will obtain and pool connections using
+ <classname>java.sql.DriverManager</classname> if you set the following
+ properties:</para>
+
+ <table frame="topbot">
+ <title>Hibernate JDBC Properties</title>
+
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*" />
+
+ <colspec colname="c2" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry>Property name</entry>
+
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><property>hibernate.connection.driver_class</property></entry>
+
+ <entry><emphasis>JDBC driver class</emphasis></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.url</property></entry>
+
+ <entry><emphasis>JDBC URL</emphasis></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.username</property></entry>
+
+ <entry><emphasis>database user</emphasis></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.password</property></entry>
+
+ <entry><emphasis>database user password</emphasis></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.pool_size</property></entry>
+
+ <entry><emphasis>maximum number of pooled
+ connections</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>Hibernate's own connection pooling algorithm is, however, quite
+ rudimentary. It is intended to help you get started and is <emphasis>not
+ intended for use in a production system</emphasis>, or even for
+ performance testing. You should use a third party pool for best
+ performance and stability. Just replace the
+ <property>hibernate.connection.pool_size</property> property with
+ connection pool specific settings. This will turn off Hibernate's internal
+ pool. For example, you might like to use c3p0.</para>
+
+ <para>C3P0 is an open source JDBC connection pool distributed along with
+ Hibernate in the <filename>lib</filename> directory. Hibernate will use
+ its <classname>org.hibernate.connection.C3P0ConnectionProvider</classname>
+ for connection pooling if you set <property>hibernate.c3p0.*</property>
+ properties. If you would like to use Proxool, refer to the packaged
+ <filename>hibernate.properties</filename> and the Hibernate web site for
+ more information.</para>
+
+ <para>The following is an example
+ <filename>hibernate.properties</filename> file for c3p0:</para>
+
+ <programlisting>hibernate.connection.driver_class = org.postgresql.Driver
+hibernate.connection.url = jdbc:postgresql://localhost/mydatabase
+hibernate.connection.username = myuser
+hibernate.connection.password = secret
+hibernate.c3p0.min_size=5
+hibernate.c3p0.max_size=20
+hibernate.c3p0.timeout=1800
+hibernate.c3p0.max_statements=50
+hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
+
+ <para>For use inside an application server, you should almost always
+ configure Hibernate to obtain connections from an application server
+ <interfacename>javax.sql.Datasource</interfacename> registered in JNDI.
+ You will need to set at least one of the following properties:</para>
+
+ <table frame="topbot">
+ <title>Hibernate Datasource Properties</title>
+
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*" />
+
+ <colspec colname="c2" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry>Property name</entry>
+
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><property>hibernate.connection.datasource</property></entry>
+
+ <entry><emphasis>datasource JNDI name</emphasis></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jndi.url</property></entry>
+
+ <entry><emphasis>URL of the JNDI provider</emphasis>
+ (optional)</entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jndi.class</property></entry>
+
+ <entry><emphasis>class of the JNDI
+ <literal>InitialContextFactory</literal></emphasis>
+ (optional)</entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.username</property></entry>
+
+ <entry><emphasis>database user</emphasis> (optional)</entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.password</property></entry>
+
+ <entry><emphasis>database user password</emphasis>
+ (optional)</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>Here is an example <filename>hibernate.properties</filename> file
+ for an application server provided JNDI datasource:</para>
+
+ <programlisting>hibernate.connection.datasource = java:/comp/env/jdbc/test
+hibernate.transaction.factory_class = \
+ org.hibernate.transaction.JTATransactionFactory
+hibernate.transaction.manager_lookup_class = \
+ org.hibernate.transaction.JBossTransactionManagerLookup
+hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
+
+ <para>JDBC connections obtained from a JNDI datasource will automatically
+ participate in the container-managed transactions of the application
+ server.</para>
+
+ <para>Arbitrary connection properties can be given by prepending
+ "<literal>hibernate.connection</literal>" to the connection property name.
+ For example, you can specify a <property>charSet</property> connection
+ property using <property>hibernate.connection.charSet</property>.</para>
+
+ <para>You can define your own plugin strategy for obtaining JDBC
+ connections by implementing the interface
+ <interfacename>org.hibernate.connection.ConnectionProvider</interfacename>,
+ and specifying your custom implementation via the
+ <property>hibernate.connection.provider_class</property> property.</para>
+ </section>
+
+ <section id="configuration-optional" revision="1">
+ <title>Optional configuration properties</title>
+
+ <para>There are a number of other properties that control the behavior of
+ Hibernate at runtime. All are optional and have reasonable default
+ values.</para>
+
+ <para><warning>
+ <para><emphasis>Some of these properties are "system-level"
+ only.</emphasis> System-level properties can be set only via
+ <literal>java -Dproperty=value</literal> or
+ <filename>hibernate.properties</filename>. They
+ <emphasis>cannot</emphasis> be set by the other techniques described
+ above.</para>
+ </warning></para>
+
+ <table frame="topbot" id="configuration-optional-properties" revision="8">
+ <title>Hibernate Configuration Properties</title>
+
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*" />
+
+ <colspec colname="c2" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry>Property name</entry>
+
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><property>hibernate.dialect</property></entry>
+
+ <entry>The classname of a Hibernate
+ <classname>org.hibernate.dialect.Dialect</classname> which allows
+ Hibernate to generate SQL optimized for a particular relational
+ database. <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>full.classname.of.Dialect</literal> </para> <para> In
+ most cases Hibernate will actually be able to choose the correct
+ <classname>org.hibernate.dialect.Dialect</classname>
+ implementation based on the <literal>JDBC metadata</literal>
+ returned by the JDBC driver. </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.show_sql</property></entry>
+
+ <entry>Write all SQL statements to console. This is an alternative
+ to setting the log category <literal>org.hibernate.SQL</literal>
+ to <literal>debug</literal>. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.format_sql</property></entry>
+
+ <entry>Pretty print the SQL in the log and console. <para>
+ <emphasis role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.default_schema</property></entry>
+
+ <entry>Qualify unqualified table names with the given
+ schema/tablespace in generated SQL. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>SCHEMA_NAME</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.default_catalog</property></entry>
+
+ <entry>Qualifies unqualified table names with the given catalog in
+ generated SQL. <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>CATALOG_NAME</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.session_factory_name</property></entry>
+
+ <entry>The
+ <interfacename>org.hibernate.SessionFactory</interfacename> will
+ be automatically bound to this name in JNDI after it has been
+ created. <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>jndi/composite/name</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.max_fetch_depth</property></entry>
+
+ <entry>Sets a maximum "depth" for the outer join fetch tree for
+ single-ended associations (one-to-one, many-to-one). A
+ <literal>0</literal> disables default outer join fetching. <para>
+ <emphasis role="strong">e.g.</emphasis> recommended values between
+ <literal>0</literal> and <literal>3</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.default_batch_fetch_size</property></entry>
+
+ <entry>Sets a default size for Hibernate batch fetching of
+ associations. <para> <emphasis role="strong">e.g.</emphasis>
+ recommended values <literal>4</literal>, <literal>8</literal>,
+ <literal>16</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.default_entity_mode</property></entry>
+
+ <entry>Sets a default mode for entity representation for all
+ sessions opened from this <literal>SessionFactory</literal> <para>
+ <literal>dynamic-map</literal>, <literal>dom4j</literal>,
+ <literal>pojo</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.order_updates</property></entry>
+
+ <entry>Forces Hibernate to order SQL updates by the primary key
+ value of the items being updated. This will result in fewer
+ transaction deadlocks in highly concurrent systems. <para>
+ <emphasis role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.generate_statistics</property></entry>
+
+ <entry>If enabled, Hibernate will collect statistics useful for
+ performance tuning. <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>true</literal> | <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.use_identifier_rollback</property></entry>
+
+ <entry>If enabled, generated identifier properties will be reset
+ to default values when objects are deleted. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.use_sql_comments</property></entry>
+
+ <entry>If turned on, Hibernate will generate comments inside the
+ SQL, for easier debugging, defaults to <literal>false</literal>.
+ <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>true</literal> | <literal>false</literal> </para></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-jdbc-properties" revision="8">
+ <title>Hibernate JDBC and Connection Properties</title>
+
+ <tgroup cols="2">
+ <!--
<colspec colname="c1" colwidth="1*"/>
<colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
+-->
+
+ <thead>
+ <row>
+ <entry>Property name</entry>
+
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><property>hibernate.jdbc.fetch_size</property></entry>
+
+ <entry>A non-zero value determines the JDBC fetch size (calls
+ <literal>Statement.setFetchSize()</literal>).</entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jdbc.batch_size</property></entry>
+
+ <entry>A non-zero value enables use of JDBC2 batch updates by
+ Hibernate. <para> <emphasis role="strong">e.g.</emphasis>
+ recommended values between <literal>5</literal> and
+ <literal>30</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jdbc.batch_versioned_data</property></entry>
+
+ <entry>Set this property to <literal>true</literal> if your JDBC
+ driver returns correct row counts from
+ <literal>executeBatch()</literal>. Iit is usually safe to turn
+ this option on. Hibernate will then use batched DML for
+ automatically versioned data. Defaults to
+ <literal>false</literal>. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jdbc.factory_class</property></entry>
+
+ <entry>Select a custom
+ <interfacename>org.hibernate.jdbc.Batcher</interfacename>. Most
+ applications will not need this configuration property. <para>
+ <emphasis role="strong">e.g.</emphasis>
+ <literal>classname.of.BatcherFactory</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jdbc.use_scrollable_resultset</property></entry>
+
+ <entry>Enables use of JDBC2 scrollable resultsets by Hibernate.
+ This property is only necessary when using user-supplied JDBC
+ connections. Hibernate uses connection metadata otherwise. <para>
+ <emphasis role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jdbc.use_streams_for_binary</property></entry>
+
+ <entry>Use streams when writing/reading <literal>binary</literal>
+ or <literal>serializable</literal> types to/from JDBC.
+ <emphasis>*system-level property*</emphasis> <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jdbc.use_get_generated_keys</property></entry>
+
+ <entry>Enables use of JDBC3
+ <literal>PreparedStatement.getGeneratedKeys()</literal> to
+ retrieve natively generated keys after insert. Requires JDBC3+
+ driver and JRE1.4+, set to false if your driver has problems with
+ the Hibernate identifier generators. By default, it tries to
+ determine the driver capabilities using connection metadata.
+ <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>true|false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.provider_class</property></entry>
+
+ <entry>The classname of a custom
+ <interfacename>org.hibernate.connection.ConnectionProvider</interfacename>
+ which provides JDBC connections to Hibernate. <para> <emphasis
+ role="strong">e.g.</emphasis>
+ <literal>classname.of.ConnectionProvider</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.isolation</property></entry>
+
+ <entry>Sets the JDBC transaction isolation level. Check
+ <interfacename>java.sql.Connection</interfacename> for meaningful
+ values, but note that most databases do not support all isolation
+ levels and some define additional, non-standard isolations. <para>
+ <emphasis role="strong">e.g.</emphasis> <literal>1, 2, 4,
+ 8</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.autocommit</property></entry>
+
+ <entry>Enables autocommit for JDBC pooled connections (it is not
+ recommended). <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>true</literal> | <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.release_mode</property></entry>
+
+ <entry>Specifies when Hibernate should release JDBC connections.
+ By default, a JDBC connection is held until the session is
+ explicitly closed or disconnected. For an application server JTA
+ datasource, use <literal>after_statement</literal> to aggressively
+ release connections after every JDBC call. For a non-JTA
+ connection, it often makes sense to release the connection at the
+ end of each transaction, by using
+ <literal>after_transaction</literal>. <literal>auto</literal> will
+ choose <literal>after_statement</literal> for the JTA and CMT
+ transaction strategies and <literal>after_transaction</literal>
+ for the JDBC transaction strategy. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>auto</literal> (default) |
+ <literal>on_close</literal> | <literal>after_transaction</literal>
+ | <literal>after_statement</literal> </para> <para> This setting
+ only affects <literal>Session</literal>s returned from
+ <literal>SessionFactory.openSession</literal>. For
+ <literal>Session</literal>s obtained through
+ <literal>SessionFactory.getCurrentSession</literal>, the
+ <literal>CurrentSessionContext</literal> implementation configured
+ for use controls the connection release mode for those
+ <literal>Session</literal>s. See <xref
+ linkend="architecture-current-session" /> </para></entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.connection.</property><emphasis><propertyName></emphasis></entry>
+
+ <entry>Pass the JDBC property
+ <emphasis><propertyName></emphasis> to
+ <literal>DriverManager.getConnection()</literal>.</entry>
+ </row>
+
+ <row>
+ <entry><property>hibernate.jndi.</property><emphasis><propertyName></emphasis></entry>
+
+ <entry>Pass the property <emphasis><propertyName></emphasis>
+ to the JNDI <literal>InitialContextFactory</literal>.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-cache-properties" revision="7">
+ <title>Hibernate Cache Properties</title>
+
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*" />
+
+ <colspec colname="c2" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry>Property name</entry>
+
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>hibernate.cache.provider_class</literal></entry>
+
+ <entry>The classname of a custom <literal>CacheProvider</literal>.
+ <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>classname.of.CacheProvider</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.cache.use_minimal_puts</literal></entry>
+
+ <entry>Optimizes second-level cache operation to minimize writes,
+ at the cost of more frequent reads. This setting is most useful
+ for clustered caches and, in Hibernate3, is enabled by default for
+ clustered cache implementations. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true|false</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.cache.use_query_cache</literal></entry>
+
+ <entry>Enables the query cache. Individual queries still have to
+ be set cachable. <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>true|false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.cache.use_second_level_cache</literal></entry>
+
+ <entry>Can be used to completely disable the second level cache,
+ which is enabled by default for classes which specify a
+ <literal><cache></literal> mapping. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true|false</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.cache.query_cache_factory</literal></entry>
+
+ <entry>The classname of a custom <literal>QueryCache</literal>
+ interface, defaults to the built-in
+ <literal>StandardQueryCache</literal>. <para> <emphasis
+ role="strong">e.g.</emphasis>
+ <literal>classname.of.QueryCache</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.cache.region_prefix</literal></entry>
+
+ <entry>A prefix to use for second-level cache region names. <para>
+ <emphasis role="strong">e.g.</emphasis> <literal>prefix</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.cache.use_structured_entries</literal></entry>
+
+ <entry>Forces Hibernate to store data in the second-level cache in
+ a more human-friendly format. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true|false</literal>
+ </para></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-transaction-properties"
+ revision="9">
+ <title>Hibernate Transaction Properties</title>
+
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*" />
+
+ <colspec colname="c2" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry>Property name</entry>
+
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>hibernate.transaction.factory_class</literal></entry>
+
+ <entry>The classname of a <literal>TransactionFactory</literal> to
+ use with Hibernate <literal>Transaction</literal> API (defaults to
+ <literal>JDBCTransactionFactory</literal>). <para> <emphasis
+ role="strong">e.g.</emphasis>
+ <literal>classname.of.TransactionFactory</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>jta.UserTransaction</literal></entry>
+
+ <entry>A JNDI name used by
+ <literal>JTATransactionFactory</literal> to obtain the JTA
+ <literal>UserTransaction</literal> from the application server.
+ <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>jndi/composite/name</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.transaction.manager_lookup_class</literal></entry>
+
+ <entry>The classname of a
+ <literal>TransactionManagerLookup</literal>. It is required when
+ JVM-level caching is enabled or when using hilo generator in a JTA
+ environment. <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>classname.of.TransactionManagerLookup</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.transaction.flush_before_completion</literal></entry>
+
+ <entry>If enabled, the session will be automatically flushed
+ during the before completion phase of the transaction. Built-in
+ and automatic session context management is preferred, see <xref
+ linkend="architecture-current-session" />. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.transaction.auto_close_session</literal></entry>
+
+ <entry>If enabled, the session will be automatically closed during
+ the after completion phase of the transaction. Built-in and
+ automatic session context management is preferred, see <xref
+ linkend="architecture-current-session" />. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-misc-properties" revision="10">
+ <title>Miscellaneous Properties</title>
+
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*" />
+
+ <colspec colname="c2" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry>Property name</entry>
+
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>hibernate.current_session_context_class</literal></entry>
+
+ <entry>Supply a custom strategy for the scoping of the "current"
+ <literal>Session</literal>. See <xref
+ linkend="architecture-current-session" /> for more information
+ about the built-in strategies. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>jta</literal> |
+ <literal>thread</literal> | <literal>managed</literal> |
+ <literal>custom.Class</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.query.factory_class</literal></entry>
+
+ <entry>Chooses the HQL parser implementation. <para> <emphasis
+ role="strong">e.g.</emphasis>
+ <literal>org.hibernate.hql.ast.ASTQueryTranslatorFactory</literal>
+ or
+ <literal>org.hibernate.hql.classic.ClassicQueryTranslatorFactory</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.query.substitutions</literal></entry>
+
+ <entry>Is used to map from tokens in Hibernate queries to SQL
+ tokens (tokens might be function or literal names, for example).
+ <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.hbm2ddl.auto</literal></entry>
+
+ <entry>Automatically validates or exports schema DDL to the
+ database when the <literal>SessionFactory</literal> is created.
+ With <literal>create-drop</literal>, the database schema will be
+ dropped when the <literal>SessionFactory</literal> is closed
+ explicitly. <para> <emphasis role="strong">e.g.</emphasis>
+ <literal>validate</literal> | <literal>update</literal> |
+ <literal>create</literal> | <literal>create-drop</literal>
+ </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.hbm2ddl.import_file</literal></entry>
+
+ <entry><para>Comma-separated names of the optional files
+ containing SQL DML statements executed during the
+ <classname>SessionFactory</classname> creation. This is useful for
+ testing or demoing: by adding INSERT statements for example you
+ can populate your database with a minimal set of data when it is
+ deployed.</para><para>File order matters, the statements of a give
+ file are executed before the statements of the following files.
+ These statements are only executed if the schema is created ie if
+ <literal>hibernate.hbm2ddl.auto</literal> is set to
+ <literal>create</literal> or
+ <literal>create-drop</literal>.</para><para> <emphasis
+ role="strong">e.g.</emphasis>
+ <literal>/humans.sql,/dogs.sql</literal> </para></entry>
+ </row>
+
+ <row>
+ <entry><literal>hibernate.cglib.use_reflection_optimizer</literal></entry>
+
+ <entry>Enables the use of CGLIB instead of runtime reflection
+ (System-level property). Reflection can sometimes be useful when
+ troubleshooting. Hibernate always requires CGLIB even if you turn
+ off the optimizer. You cannot set this property in
+ <literal>hibernate.cfg.xml</literal>. <para> <emphasis
+ role="strong">e.g.</emphasis> <literal>true</literal> |
+ <literal>false</literal> </para></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <section id="configuration-optional-dialects" revision="1">
+ <title>SQL Dialects</title>
+
+ <para>Always set the <literal>hibernate.dialect</literal> property to
+ the correct <literal>org.hibernate.dialect.Dialect</literal> subclass
+ for your database. If you specify a dialect, Hibernate will use sensible
+ defaults for some of the other properties listed above. This means that
+ you will not have to specify them manually.</para>
+
+ <table frame="topbot" id="sql-dialects" revision="3">
+ <title>Hibernate SQL Dialects
+ (<literal>hibernate.dialect</literal>)</title>
+
+ <tgroup cols="2">
+ <!--
+ <colspec colwidth="1*"/>
+ <colspec colwidth="2.5*"/>
+-->
+
+ <thead>
<row>
- <entry>
- <property>hibernate.connection.driver_class</property>
- </entry>
- <entry>
- <emphasis>JDBC driver class</emphasis>
- </entry>
+ <entry>RDBMS</entry>
+
+ <entry>Dialect</entry>
</row>
+ </thead>
+
+ <tbody>
<row>
- <entry>
- <property>hibernate.connection.url</property>
- </entry>
- <entry>
- <emphasis>JDBC URL</emphasis>
- </entry>
+ <entry>DB2</entry>
+
+ <entry><literal>org.hibernate.dialect.DB2Dialect</literal></entry>
</row>
+
<row>
- <entry>
- <property>hibernate.connection.username</property>
- </entry>
- <entry>
- <emphasis>database user</emphasis>
- </entry>
+ <entry>DB2 AS/400</entry>
+
+ <entry><literal>org.hibernate.dialect.DB2400Dialect</literal></entry>
</row>
+
<row>
- <entry>
- <property>hibernate.connection.password</property>
- </entry>
- <entry>
- <emphasis>database user password</emphasis>
- </entry>
+ <entry>DB2 OS390</entry>
+
+ <entry><literal>org.hibernate.dialect.DB2390Dialect</literal></entry>
</row>
+
<row>
- <entry>
- <property>hibernate.connection.pool_size</property>
- </entry>
- <entry>
- <emphasis>maximum number of pooled connections</emphasis>
- </entry>
+ <entry>PostgreSQL</entry>
+
+ <entry><literal>org.hibernate.dialect.PostgreSQLDialect</literal></entry>
</row>
- </tbody>
- </tgroup>
- </table>
- <para>
- Hibernate's own connection pooling algorithm is, however, quite rudimentary.
- It is intended to help you get started and is <emphasis>not intended for use
- in a production system</emphasis>, or even for performance testing. You should
- use a third party pool for best performance and stability. Just replace the
- <property>hibernate.connection.pool_size</property> property with connection
- pool specific settings. This will turn off Hibernate's internal pool. For
- example, you might like to use c3p0.
- </para>
+ <row>
+ <entry>MySQL</entry>
- <para>
- C3P0 is an open source JDBC connection pool distributed along with Hibernate in the <filename>lib</filename>
- directory. Hibernate will use its <classname>org.hibernate.connection.C3P0ConnectionProvider</classname>
- for connection pooling if you set <property>hibernate.c3p0.*</property> properties. If you would like to use Proxool,
- refer to the packaged <filename>hibernate.properties</filename> and the Hibernate web site for more
- information.
- </para>
+ <entry><literal>org.hibernate.dialect.MySQLDialect</literal></entry>
+ </row>
- <para>
- The following is an example <filename>hibernate.properties</filename> file for c3p0:
- </para>
+ <row>
+ <entry>MySQL with InnoDB</entry>
-
- <programlisting><![CDATA[hibernate.connection.driver_class = org.postgresql.Driver
-hibernate.connection.url = jdbc:postgresql://localhost/mydatabase
-hibernate.connection.username = myuser
-hibernate.connection.password = secret
-hibernate.c3p0.min_size=5
-hibernate.c3p0.max_size=20
-hibernate.c3p0.timeout=1800
-hibernate.c3p0.max_statements=50
-hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect]]></programlisting>
+ <entry><literal>org.hibernate.dialect.MySQLInnoDBDialect</literal></entry>
+ </row>
- <para>
- For use inside an application server, you should almost always configure Hibernate to obtain connections
- from an application server <interfacename>javax.sql.Datasource</interfacename> registered in JNDI. You will
- need to set at least one of the following properties:
- </para>
-
- <table frame="topbot">
- <title>Hibernate Datasource Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
<row>
- <entry>
- <property>hibernate.connection.datasource</property>
- </entry>
- <entry>
- <emphasis>datasource JNDI name</emphasis>
- </entry>
+ <entry>MySQL with MyISAM</entry>
+
+ <entry><literal>org.hibernate.dialect.MySQLMyISAMDialect</literal></entry>
</row>
+
<row>
- <entry>
- <property>hibernate.jndi.url</property>
- </entry>
- <entry>
- <emphasis>URL of the JNDI provider</emphasis> (optional)
- </entry>
+ <entry>Oracle (any version)</entry>
+
+ <entry><literal>org.hibernate.dialect.OracleDialect</literal></entry>
</row>
+
<row>
- <entry>
- <property>hibernate.jndi.class</property>
- </entry>
- <entry>
- <emphasis>class of the JNDI <literal>InitialContextFactory</literal></emphasis> (optional)
- </entry>
+ <entry>Oracle 9i</entry>
+
+ <entry><literal>org.hibernate.dialect.Oracle9iDialect</literal></entry>
</row>
+
<row>
- <entry>
- <property>hibernate.connection.username</property>
- </entry>
- <entry>
- <emphasis>database user</emphasis> (optional)
- </entry>
+ <entry>Oracle 10g</entry>
+
+ <entry><literal>org.hibernate.dialect.Oracle10gDialect</literal></entry>
</row>
+
<row>
- <entry>
- <property>hibernate.connection.password</property>
- </entry>
- <entry>
- <emphasis>database user password</emphasis> (optional)
- </entry>
+ <entry>Sybase</entry>
+
+ <entry><literal>org.hibernate.dialect.SybaseDialect</literal></entry>
</row>
- </tbody>
- </tgroup>
- </table>
- <para>
- Here is an example <filename>hibernate.properties</filename> file for an application server provided JNDI
- datasource:
- </para>
+ <row>
+ <entry>Sybase Anywhere</entry>
- <programlisting><![CDATA[hibernate.connection.datasource = java:/comp/env/jdbc/test
-hibernate.transaction.factory_class = \
- org.hibernate.transaction.JTATransactionFactory
-hibernate.transaction.manager_lookup_class = \
- org.hibernate.transaction.JBossTransactionManagerLookup
-hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect]]></programlisting>
+ <entry><literal>org.hibernate.dialect.SybaseAnywhereDialect</literal></entry>
+ </row>
- <para>
- JDBC connections obtained from a JNDI datasource will automatically participate
- in the container-managed transactions of the application server.
- </para>
+ <row>
+ <entry>Microsoft SQL Server</entry>
- <para>
- Arbitrary connection properties can be given by prepending "<literal>hibernate.connection</literal>" to the
- connection property name. For example, you can specify a <property>charSet</property>
- connection property using <property>hibernate.connection.charSet</property>.
- </para>
+ <entry><literal>org.hibernate.dialect.SQLServerDialect</literal></entry>
+ </row>
- <para>
- You can define your own plugin strategy for obtaining JDBC connections by implementing the
- interface <interfacename>org.hibernate.connection.ConnectionProvider</interfacename>, and specifying your
- custom implementation via the <property>hibernate.connection.provider_class</property> property.
- </para>
+ <row>
+ <entry>SAP DB</entry>
- </section>
+ <entry><literal>org.hibernate.dialect.SAPDBDialect</literal></entry>
+ </row>
- <section id="configuration-optional" revision="1">
- <title>Optional configuration properties</title>
-
- <para>
- There are a number of other properties that control the behavior of Hibernate at runtime. All are optional
- and have reasonable default values.
- </para>
+ <row>
+ <entry>Informix</entry>
- <para>
- <warning><para><emphasis>Some of these properties are "system-level" only.</emphasis> System-level properties can
- be set only via <literal>java -Dproperty=value</literal> or <filename>hibernate.properties</filename>. They
- <emphasis>cannot</emphasis> be set by the other techniques described above.</para></warning>
- </para>
+ <entry><literal>org.hibernate.dialect.InformixDialect</literal></entry>
+ </row>
- <table frame="topbot" id="configuration-optional-properties" revision="8">
- <title>Hibernate Configuration Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <property>hibernate.dialect</property>
- </entry>
- <entry>
- The classname of a Hibernate <classname>org.hibernate.dialect.Dialect</classname> which
- allows Hibernate to generate SQL optimized for a particular relational database.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>full.classname.of.Dialect</literal>
- </para>
- <para>
- In most cases Hibernate will actually be able to choose the correct
- <classname>org.hibernate.dialect.Dialect</classname> implementation based on the
- <literal>JDBC metadata</literal> returned by the JDBC driver.
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.show_sql</property>
- </entry>
- <entry>
- Write all SQL statements to console. This is an alternative
- to setting the log category <literal>org.hibernate.SQL</literal>
- to <literal>debug</literal>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.format_sql</property>
- </entry>
- <entry>
- Pretty print the SQL in the log and console.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.default_schema</property>
- </entry>
- <entry>
- Qualify unqualified table names with the given schema/tablespace
- in generated SQL.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>SCHEMA_NAME</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.default_catalog</property>
- </entry>
- <entry>
- Qualifies unqualified table names with the given catalog
- in generated SQL.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>CATALOG_NAME</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.session_factory_name</property>
- </entry>
- <entry>
- The <interfacename>org.hibernate.SessionFactory</interfacename> will be automatically
- bound to this name in JNDI after it has been created.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>jndi/composite/name</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.max_fetch_depth</property>
- </entry>
- <entry>
- Sets a maximum "depth" for the outer join fetch tree
- for single-ended associations (one-to-one, many-to-one).
- A <literal>0</literal> disables default outer join fetching.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- recommended values between <literal>0</literal> and
- <literal>3</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.default_batch_fetch_size</property>
- </entry>
- <entry>
- Sets a default size for Hibernate batch fetching of associations.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- recommended values <literal>4</literal>, <literal>8</literal>,
- <literal>16</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.default_entity_mode</property>
- </entry>
- <entry>
- Sets a default mode for entity representation for all sessions
- opened from this <literal>SessionFactory</literal>
- <para>
- <literal>dynamic-map</literal>, <literal>dom4j</literal>,
- <literal>pojo</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.order_updates</property>
- </entry>
- <entry>
- Forces Hibernate to order SQL updates by the primary key value
- of the items being updated. This will result in fewer transaction
- deadlocks in highly concurrent systems.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.generate_statistics</property>
- </entry>
- <entry>
- If enabled, Hibernate will collect statistics useful for
- performance tuning.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.use_identifier_rollback</property>
- </entry>
- <entry>
- If enabled, generated identifier properties will be
- reset to default values when objects are deleted.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.use_sql_comments</property>
- </entry>
- <entry>
- If turned on, Hibernate will generate comments inside the SQL, for
- easier debugging, defaults to <literal>false</literal>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <row>
+ <entry>HypersonicSQL</entry>
- <table frame="topbot" id="configuration-jdbc-properties" revision="8">
- <title>Hibernate JDBC and Connection Properties</title>
- <tgroup cols="2">
-<!--
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
--->
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <property>hibernate.jdbc.fetch_size</property>
- </entry>
- <entry>
- A non-zero value determines the JDBC fetch size (calls
- <literal>Statement.setFetchSize()</literal>).
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.jdbc.batch_size</property>
- </entry>
- <entry>
- A non-zero value enables use of JDBC2 batch updates by Hibernate.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- recommended values between <literal>5</literal> and <literal>30</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.jdbc.batch_versioned_data</property>
- </entry>
- <entry>
- Set this property to <literal>true</literal> if your JDBC driver returns
- correct row counts from <literal>executeBatch()</literal>. Iit is usually
- safe to turn this option on. Hibernate will then use batched DML for
- automatically versioned data. Defaults to <literal>false</literal>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.jdbc.factory_class</property>
- </entry>
- <entry>
- Select a custom <interfacename>org.hibernate.jdbc.Batcher</interfacename>. Most applications
- will not need this configuration property.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>classname.of.BatcherFactory</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.jdbc.use_scrollable_resultset</property>
- </entry>
- <entry>
- Enables use of JDBC2 scrollable resultsets by Hibernate.
- This property is only necessary when using user-supplied
- JDBC connections. Hibernate uses connection metadata otherwise.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.jdbc.use_streams_for_binary</property>
- </entry>
- <entry>
- Use streams when writing/reading <literal>binary</literal> or <literal>serializable</literal>
- types to/from JDBC. <emphasis>*system-level property*</emphasis>
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.jdbc.use_get_generated_keys</property>
- </entry>
- <entry>
- Enables use of JDBC3 <literal>PreparedStatement.getGeneratedKeys()</literal>
- to retrieve natively generated keys after insert. Requires JDBC3+ driver
- and JRE1.4+, set to false if your driver has problems with the Hibernate
- identifier generators. By default, it tries to determine the driver capabilities
- using connection metadata.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.connection.provider_class</property>
- </entry>
- <entry>
- The classname of a custom <interfacename>org.hibernate.connection.ConnectionProvider</interfacename>
- which provides JDBC connections to Hibernate.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>classname.of.ConnectionProvider</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.connection.isolation</property>
- </entry>
- <entry>
- Sets the JDBC transaction isolation level. Check <interfacename>java.sql.Connection</interfacename>
- for meaningful values, but note that most databases do not support all isolation levels and some
- define additional, non-standard isolations.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>1, 2, 4, 8</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.connection.autocommit</property>
- </entry>
- <entry>
- Enables autocommit for JDBC pooled connections (it is not recommended).
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.connection.release_mode</property>
- </entry>
- <entry>
- Specifies when Hibernate should release JDBC connections. By default,
- a JDBC connection is held until the session is explicitly closed or
- disconnected. For an application server JTA datasource, use
- <literal>after_statement</literal> to aggressively release connections
- after every JDBC call. For a non-JTA connection, it often makes sense to
- release the connection at the end of each transaction, by using
- <literal>after_transaction</literal>. <literal>auto</literal> will
- choose <literal>after_statement</literal> for the JTA and CMT transaction
- strategies and <literal>after_transaction</literal> for the JDBC
- transaction strategy.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>auto</literal> (default) | <literal>on_close</literal> |
- <literal>after_transaction</literal> | <literal>after_statement</literal>
- </para>
- <para>
- This setting only affects <literal>Session</literal>s returned from
- <literal>SessionFactory.openSession</literal>. For <literal>Session</literal>s
- obtained through <literal>SessionFactory.getCurrentSession</literal>, the
- <literal>CurrentSessionContext</literal> implementation configured for use
- controls the connection release mode for those <literal>Session</literal>s.
- See <xref linkend="architecture-current-session"/>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.connection.</property><emphasis><propertyName></emphasis>
- </entry>
- <entry>
- Pass the JDBC property <emphasis><propertyName></emphasis>
- to <literal>DriverManager.getConnection()</literal>.
- </entry>
- </row>
- <row>
- <entry>
- <property>hibernate.jndi.</property><emphasis><propertyName></emphasis>
- </entry>
- <entry>
- Pass the property <emphasis><propertyName></emphasis> to
- the JNDI <literal>InitialContextFactory</literal>.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <entry><literal>org.hibernate.dialect.HSQLDialect</literal></entry>
+ </row>
- <table frame="topbot" id="configuration-cache-properties" revision="7">
- <title>Hibernate Cache Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.cache.provider_class</literal>
- </entry>
- <entry>
- The classname of a custom <literal>CacheProvider</literal>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>classname.of.CacheProvider</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_minimal_puts</literal>
- </entry>
- <entry>
- Optimizes second-level cache operation to minimize writes, at the
- cost of more frequent reads. This setting is most useful for
- clustered caches and, in Hibernate3, is enabled by default for
- clustered cache implementations.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_query_cache</literal>
- </entry>
- <entry>
- Enables the query cache. Individual queries still have to be set cachable.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_second_level_cache</literal>
- </entry>
- <entry>
- Can be used to completely disable the second level cache, which is enabled
- by default for classes which specify a <literal><cache></literal>
- mapping.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.query_cache_factory</literal>
- </entry>
- <entry>
- The classname of a custom <literal>QueryCache</literal> interface,
- defaults to the built-in <literal>StandardQueryCache</literal>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>classname.of.QueryCache</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.region_prefix</literal>
- </entry>
- <entry>
- A prefix to use for second-level cache region names.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>prefix</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_structured_entries</literal>
- </entry>
- <entry>
- Forces Hibernate to store data in the second-level cache
- in a more human-friendly format.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <row>
+ <entry>Ingres</entry>
- <table frame="topbot" id="configuration-transaction-properties" revision="9">
- <title>Hibernate Transaction Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.transaction.factory_class</literal>
- </entry>
- <entry>
- The classname of a <literal>TransactionFactory</literal>
- to use with Hibernate <literal>Transaction</literal> API
- (defaults to <literal>JDBCTransactionFactory</literal>).
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>classname.of.TransactionFactory</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>jta.UserTransaction</literal>
- </entry>
- <entry>
- A JNDI name used by <literal>JTATransactionFactory</literal> to
- obtain the JTA <literal>UserTransaction</literal> from the
- application server.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>jndi/composite/name</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.transaction.manager_lookup_class</literal>
- </entry>
- <entry>
- The classname of a <literal>TransactionManagerLookup</literal>. It is
- required when JVM-level caching is enabled or when using hilo
- generator in a JTA environment.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>classname.of.TransactionManagerLookup</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.transaction.flush_before_completion</literal>
- </entry>
- <entry>
- If enabled, the session will be automatically flushed during the
- before completion phase of the transaction. Built-in and
- automatic session context management is preferred, see
- <xref linkend="architecture-current-session"/>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.transaction.auto_close_session</literal>
- </entry>
- <entry>
- If enabled, the session will be automatically closed during the
- after completion phase of the transaction. Built-in and
- automatic session context management is preferred, see
- <xref linkend="architecture-current-session"/>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <entry><literal>org.hibernate.dialect.IngresDialect</literal></entry>
+ </row>
- <table frame="topbot" id="configuration-misc-properties" revision="10">
- <title>Miscellaneous Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.current_session_context_class</literal>
- </entry>
- <entry>
- Supply a custom strategy for the scoping of the "current"
- <literal>Session</literal>. See
- <xref linkend="architecture-current-session"/> for more
- information about the built-in strategies.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>jta</literal> | <literal>thread</literal> |
- <literal>managed</literal> | <literal>custom.Class</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.query.factory_class</literal>
- </entry>
- <entry>
- Chooses the HQL parser implementation.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>org.hibernate.hql.ast.ASTQueryTranslatorFactory</literal> or
- <literal>org.hibernate.hql.classic.ClassicQueryTranslatorFactory</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.query.substitutions</literal>
- </entry>
- <entry>
- Is used to map from tokens in Hibernate queries to SQL tokens
- (tokens might be function or literal names, for example).
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.hbm2ddl.auto</literal>
- </entry>
- <entry>
- Automatically validates or exports schema DDL to the database
- when the <literal>SessionFactory</literal> is created. With
- <literal>create-drop</literal>, the database schema will be
- dropped when the <literal>SessionFactory</literal> is closed
- explicitly.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>validate</literal> | <literal>update</literal> |
- <literal>create</literal> | <literal>create-drop</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cglib.use_reflection_optimizer</literal>
- </entry>
- <entry>
- Enables the use of CGLIB instead of runtime reflection (System-level
- property). Reflection can sometimes be useful when troubleshooting.
- Hibernate always requires CGLIB even if you turn off the
- optimizer. You cannot set this property in <literal>hibernate.cfg.xml</literal>.
- <para>
- <emphasis role="strong">e.g.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <row>
+ <entry>Progress</entry>
- <section id="configuration-optional-dialects" revision="1">
- <title>SQL Dialects</title>
+ <entry><literal>org.hibernate.dialect.ProgressDialect</literal></entry>
+ </row>
- <para>
- Always set the <literal>hibernate.dialect</literal> property to the correct
- <literal>org.hibernate.dialect.Dialect</literal> subclass for your database. If you
- specify a dialect, Hibernate will use sensible defaults for some of the
- other properties listed above. This means that you will not have to specify them manually.
- </para>
+ <row>
+ <entry>Mckoi SQL</entry>
- <table frame="topbot" id="sql-dialects" revision="3">
- <title>Hibernate SQL Dialects (<literal>hibernate.dialect</literal>)</title>
- <tgroup cols="2">
-<!--
- <colspec colwidth="1*"/>
- <colspec colwidth="2.5*"/>
--->
- <thead>
- <row>
- <entry>RDBMS</entry>
- <entry>Dialect</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>DB2</entry> <entry><literal>org.hibernate.dialect.DB2Dialect</literal></entry>
- </row>
- <row>
- <entry>DB2 AS/400</entry> <entry><literal>org.hibernate.dialect.DB2400Dialect</literal></entry>
- </row>
- <row>
- <entry>DB2 OS390</entry> <entry><literal>org.hibernate.dialect.DB2390Dialect</literal></entry>
- </row>
- <row>
- <entry>PostgreSQL</entry> <entry><literal>org.hibernate.dialect.PostgreSQLDialect</literal></entry>
- </row>
- <row>
- <entry>MySQL</entry> <entry><literal>org.hibernate.dialect.MySQLDialect</literal></entry>
- </row>
- <row>
- <entry>MySQL with InnoDB</entry> <entry><literal>org.hibernate.dialect.MySQLInnoDBDialect</literal></entry>
- </row>
- <row>
- <entry>MySQL with MyISAM</entry> <entry><literal>org.hibernate.dialect.MySQLMyISAMDialect</literal></entry>
- </row>
- <row>
- <entry>Oracle (any version)</entry> <entry><literal>org.hibernate.dialect.OracleDialect</literal></entry>
- </row>
- <row>
- <entry>Oracle 9i</entry> <entry><literal>org.hibernate.dialect.Oracle9iDialect</literal></entry>
- </row>
- <row>
- <entry>Oracle 10g</entry> <entry><literal>org.hibernate.dialect.Oracle10gDialect</literal></entry>
- </row>
- <row>
- <entry>Sybase</entry> <entry><literal>org.hibernate.dialect.SybaseDialect</literal></entry>
- </row>
- <row>
- <entry>Sybase Anywhere</entry> <entry><literal>org.hibernate.dialect.SybaseAnywhereDialect</literal></entry>
- </row>
- <row>
- <entry>Microsoft SQL Server</entry> <entry><literal>org.hibernate.dialect.SQLServerDialect</literal></entry>
- </row>
- <row>
- <entry>SAP DB</entry> <entry><literal>org.hibernate.dialect.SAPDBDialect</literal></entry>
- </row>
- <row>
- <entry>Informix</entry> <entry><literal>org.hibernate.dialect.InformixDialect</literal></entry>
- </row>
- <row>
- <entry>HypersonicSQL</entry> <entry><literal>org.hibernate.dialect.HSQLDialect</literal></entry>
- </row>
- <row>
- <entry>Ingres</entry> <entry><literal>org.hibernate.dialect.IngresDialect</literal></entry>
- </row>
- <row>
- <entry>Progress</entry> <entry><literal>org.hibernate.dialect.ProgressDialect</literal></entry>
- </row>
- <row>
- <entry>Mckoi SQL</entry> <entry><literal>org.hibernate.dialect.MckoiDialect</literal></entry>
- </row>
- <row>
- <entry>Interbase</entry> <entry><literal>org.hibernate.dialect.InterbaseDialect</literal></entry>
- </row>
- <row>
- <entry>Pointbase</entry> <entry><literal>org.hibernate.dialect.PointbaseDialect</literal></entry>
- </row>
- <row>
- <entry>FrontBase</entry> <entry><literal>org.hibernate.dialect.FrontbaseDialect</literal></entry>
- </row>
- <row>
- <entry>Firebird</entry> <entry><literal>org.hibernate.dialect.FirebirdDialect</literal></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <entry><literal>org.hibernate.dialect.MckoiDialect</literal></entry>
+ </row>
- </section>
+ <row>
+ <entry>Interbase</entry>
- <section id="configuration-optional-outerjoin" revision="4">
- <title>Outer Join Fetching</title>
+ <entry><literal>org.hibernate.dialect.InterbaseDialect</literal></entry>
+ </row>
- <para>
- If your database supports ANSI, Oracle or Sybase style outer joins, <emphasis>outer join
- fetching</emphasis> will often increase performance by limiting the number of round
- trips to and from the database. This is, however, at the cost of possibly more work performed by
- the database itself. Outer join fetching allows a whole graph of objects connected
- by many-to-one, one-to-many, many-to-many and one-to-one associations to be retrieved
- in a single SQL <literal>SELECT</literal>.
- </para>
+ <row>
+ <entry>Pointbase</entry>
- <para>
- Outer join fetching can be disabled <emphasis>globally</emphasis> by setting
- the property <literal>hibernate.max_fetch_depth</literal> to <literal>0</literal>.
- A setting of <literal>1</literal> or higher enables outer join fetching for
- one-to-one and many-to-one associations that have been mapped with
- <literal>fetch="join"</literal>.
- </para>
+ <entry><literal>org.hibernate.dialect.PointbaseDialect</literal></entry>
+ </row>
- <para>
- See <xref linkend="performance-fetching"/> for more information.
- </para>
+ <row>
+ <entry>FrontBase</entry>
- </section>
+ <entry><literal>org.hibernate.dialect.FrontbaseDialect</literal></entry>
+ </row>
- <section id="configuration-optional-binarystreams" revision="1">
- <title>Binary Streams</title>
+ <row>
+ <entry>Firebird</entry>
- <para>
- Oracle limits the size of <literal>byte</literal> arrays that can
- be passed to and/or from its JDBC driver. If you wish to use large instances of
- <literal>binary</literal> or <literal>serializable</literal> type, you should
- enable <literal>hibernate.jdbc.use_streams_for_binary</literal>.
- <emphasis>This is a system-level setting only.</emphasis>
- </para>
+ <entry><literal>org.hibernate.dialect.FirebirdDialect</literal></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
- </section>
+ <section id="configuration-optional-outerjoin" revision="4">
+ <title>Outer Join Fetching</title>
- <section id="configuration-optional-cacheprovider" revision="2">
- <title>Second-level and query cache</title>
+ <para>If your database supports ANSI, Oracle or Sybase style outer
+ joins, <emphasis>outer join fetching</emphasis> will often increase
+ performance by limiting the number of round trips to and from the
+ database. This is, however, at the cost of possibly more work performed
+ by the database itself. Outer join fetching allows a whole graph of
+ objects connected by many-to-one, one-to-many, many-to-many and
+ one-to-one associations to be retrieved in a single SQL
+ <literal>SELECT</literal>.</para>
- <para>
- The properties prefixed by <literal>hibernate.cache</literal>
- allow you to use a process or cluster scoped second-level cache system
- with Hibernate. See the <xref linkend="performance-cache"/> for
- more information.
- </para>
+ <para>Outer join fetching can be disabled <emphasis>globally</emphasis>
+ by setting the property <literal>hibernate.max_fetch_depth</literal> to
+ <literal>0</literal>. A setting of <literal>1</literal> or higher
+ enables outer join fetching for one-to-one and many-to-one associations
+ that have been mapped with <literal>fetch="join"</literal>.</para>
- </section>
+ <para>See <xref linkend="performance-fetching" /> for more
+ information.</para>
+ </section>
- <section id="configuration-optional-querysubstitution">
- <title>Query Language Substitution</title>
+ <section id="configuration-optional-binarystreams" revision="1">
+ <title>Binary Streams</title>
- <para>
- You can define new Hibernate query tokens using <literal>hibernate.query.substitutions</literal>.
- For example:
- </para>
+ <para>Oracle limits the size of <literal>byte</literal> arrays that can
+ be passed to and/or from its JDBC driver. If you wish to use large
+ instances of <literal>binary</literal> or
+ <literal>serializable</literal> type, you should enable
+ <literal>hibernate.jdbc.use_streams_for_binary</literal>. <emphasis>This
+ is a system-level setting only.</emphasis></para>
+ </section>
- <programlisting>hibernate.query.substitutions true=1, false=0</programlisting>
+ <section id="configuration-optional-cacheprovider" revision="2">
+ <title>Second-level and query cache</title>
- <para>
- This would cause the tokens <literal>true</literal> and <literal>false</literal> to be translated to
- integer literals in the generated SQL.
- </para>
+ <para>The properties prefixed by <literal>hibernate.cache</literal>
+ allow you to use a process or cluster scoped second-level cache system
+ with Hibernate. See the <xref linkend="performance-cache" /> for more
+ information.</para>
+ </section>
- <programlisting>hibernate.query.substitutions toLowercase=LOWER</programlisting>
+ <section id="configuration-optional-querysubstitution">
+ <title>Query Language Substitution</title>
- <para>
- This would allow you to rename the SQL <literal>LOWER</literal> function.
- </para>
+ <para>You can define new Hibernate query tokens using
+ <literal>hibernate.query.substitutions</literal>. For example:</para>
- </section>
+ <programlisting>hibernate.query.substitutions true=1, false=0</programlisting>
- <section id="configuration-optional-statistics" revision="2">
- <title>Hibernate statistics</title>
+ <para>This would cause the tokens <literal>true</literal> and
+ <literal>false</literal> to be translated to integer literals in the
+ generated SQL.</para>
- <para>
- If you enable <literal>hibernate.generate_statistics</literal>, Hibernate
- exposes a number of metrics that are useful when tuning a running system via
- <literal>SessionFactory.getStatistics()</literal>. Hibernate can even be configured
- to expose these statistics via JMX. Read the Javadoc of the interfaces in
- <literal>org.hibernate.stats</literal> for more information.
- </para>
+ <programlisting>hibernate.query.substitutions toLowercase=LOWER</programlisting>
- </section>
+ <para>This would allow you to rename the SQL <literal>LOWER</literal>
+ function.</para>
</section>
- <section id="configuration-logging">
- <title>Logging</title>
+ <section id="configuration-optional-statistics" revision="2">
+ <title>Hibernate statistics</title>
- <para>
- Hibernate utilizes <ulink url="http://www.slf4j.org/">Simple Logging Facade for Java</ulink>
- (SLF4J) in order to log various system events. SLF4J can direct your logging output to
- several logging frameworks (NOP, Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on your
- chosen binding. In order to setup logging you will need <filename>slf4j-api.jar</filename> in
- your classpath together with the jar file for your preferred binding - <filename>slf4j-log4j12.jar</filename>
- in the case of Log4J. See the SLF4J <ulink url="http://www.slf4j.org/manual.html">documentation</ulink> for more detail.
- To use Log4j you will also need to place a <filename>log4j.properties</filename> file in your classpath.
- An example properties file is distributed with Hibernate in the <literal>src/</literal> directory.
- </para>
-
- <para>
- It is recommended that you familiarize yourself with Hibernate's log
- messages. A lot of work has been put into making the Hibernate log as
- detailed as possible, without making it unreadable. It is an essential
- troubleshooting device. The most interesting log categories are the
- following:
- </para>
-
- <table frame="topbot" id="log-categories" revision="2">
- <title>Hibernate Log Categories</title>
- <tgroup cols="2">
- <colspec colwidth="1*"/>
- <colspec colwidth="2.5*"/>
- <thead>
- <row>
- <entry>Category</entry>
- <entry>Function</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>org.hibernate.SQL</literal></entry>
- <entry>Log all SQL DML statements as they are executed</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.type</literal></entry>
- <entry>Log all JDBC parameters</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.tool.hbm2ddl</literal></entry>
- <entry>Log all SQL DDL statements as they are executed</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.pretty</literal></entry>
- <entry>
- Log the state of all entities (max 20 entities) associated
- with the session at flush time
- </entry>
- </row>
- <row>
- <entry><literal>org.hibernate.cache</literal></entry>
- <entry>Log all second-level cache activity</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction</literal></entry>
- <entry>Log transaction related activity</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.jdbc</literal></entry>
- <entry>Log all JDBC resource acquisition</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.hql.ast.AST</literal></entry>
- <entry>
- Log HQL and SQL ASTs during query parsing
- </entry>
- </row>
- <row>
- <entry><literal>org.hibernate.secure</literal></entry>
- <entry>Log all JAAS authorization requests</entry>
- </row>
- <row>
- <entry><literal>org.hibernate</literal></entry>
- <entry>
- Log everything. This is a lot of information but it is useful for
- troubleshooting
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- When developing applications with Hibernate, you should almost always work with
- <literal>debug</literal> enabled for the category <literal>org.hibernate.SQL</literal>,
- or, alternatively, the property <literal>hibernate.show_sql</literal> enabled.
- </para>
-
-
+ <para>If you enable <literal>hibernate.generate_statistics</literal>,
+ Hibernate exposes a number of metrics that are useful when tuning a
+ running system via <literal>SessionFactory.getStatistics()</literal>.
+ Hibernate can even be configured to expose these statistics via JMX.
+ Read the Javadoc of the interfaces in
+ <literal>org.hibernate.stats</literal> for more information.</para>
</section>
+ </section>
- <section id="configuration-namingstrategy">
- <title>Implementing a <literal>NamingStrategy</literal></title>
+ <section id="configuration-logging">
+ <title>Logging</title>
- <para>
- The interface <literal>org.hibernate.cfg.NamingStrategy</literal> allows you
- to specify a "naming standard" for database objects and schema elements.
- </para>
+ <para>Hibernate utilizes <ulink url="http://www.slf4j.org/">Simple Logging
+ Facade for Java</ulink> (SLF4J) in order to log various system events.
+ SLF4J can direct your logging output to several logging frameworks (NOP,
+ Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on
+ your chosen binding. In order to setup logging you will need
+ <filename>slf4j-api.jar</filename> in your classpath together with the jar
+ file for your preferred binding - <filename>slf4j-log4j12.jar</filename>
+ in the case of Log4J. See the SLF4J <ulink
+ url="http://www.slf4j.org/manual.html">documentation</ulink> for more
+ detail. To use Log4j you will also need to place a
+ <filename>log4j.properties</filename> file in your classpath. An example
+ properties file is distributed with Hibernate in the
+ <literal>src/</literal> directory.</para>
- <para>
- You can provide rules for automatically generating database identifiers from
- Java identifiers or for processing "logical" column and table names given in
- the mapping file into "physical" table and column names. This feature helps
- reduce the verbosity of the mapping document, eliminating repetitive noise
- (<literal>TBL_</literal> prefixes, for example). The default strategy used by
- Hibernate is quite minimal.
- </para>
+ <para>It is recommended that you familiarize yourself with Hibernate's log
+ messages. A lot of work has been put into making the Hibernate log as
+ detailed as possible, without making it unreadable. It is an essential
+ troubleshooting device. The most interesting log categories are the
+ following:</para>
- <para>
- You can specify a different strategy by calling
- <literal>Configuration.setNamingStrategy()</literal> before adding mappings:
- </para>
+ <table frame="topbot" id="log-categories" revision="2">
+ <title>Hibernate Log Categories</title>
- <programlisting role="JAVA"><![CDATA[SessionFactory sf = new Configuration()
+ <tgroup cols="2">
+ <colspec colwidth="1*" />
+
+ <colspec colwidth="2.5*" />
+
+ <thead>
+ <row>
+ <entry>Category</entry>
+
+ <entry>Function</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>org.hibernate.SQL</literal></entry>
+
+ <entry>Log all SQL DML statements as they are executed</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.type</literal></entry>
+
+ <entry>Log all JDBC parameters</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.tool.hbm2ddl</literal></entry>
+
+ <entry>Log all SQL DDL statements as they are executed</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.pretty</literal></entry>
+
+ <entry>Log the state of all entities (max 20 entities) associated
+ with the session at flush time</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.cache</literal></entry>
+
+ <entry>Log all second-level cache activity</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.transaction</literal></entry>
+
+ <entry>Log transaction related activity</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.jdbc</literal></entry>
+
+ <entry>Log all JDBC resource acquisition</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.hql.ast.AST</literal></entry>
+
+ <entry>Log HQL and SQL ASTs during query parsing</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate.secure</literal></entry>
+
+ <entry>Log all JAAS authorization requests</entry>
+ </row>
+
+ <row>
+ <entry><literal>org.hibernate</literal></entry>
+
+ <entry>Log everything. This is a lot of information but it is
+ useful for troubleshooting</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>When developing applications with Hibernate, you should almost
+ always work with <literal>debug</literal> enabled for the category
+ <literal>org.hibernate.SQL</literal>, or, alternatively, the property
+ <literal>hibernate.show_sql</literal> enabled.</para>
+ </section>
+
+ <section id="configuration-namingstrategy">
+ <title>Implementing a <literal>NamingStrategy</literal></title>
+
+ <para>The interface <literal>org.hibernate.cfg.NamingStrategy</literal>
+ allows you to specify a "naming standard" for database objects and schema
+ elements.</para>
+
+ <para>You can provide rules for automatically generating database
+ identifiers from Java identifiers or for processing "logical" column and
+ table names given in the mapping file into "physical" table and column
+ names. This feature helps reduce the verbosity of the mapping document,
+ eliminating repetitive noise (<literal>TBL_</literal> prefixes, for
+ example). The default strategy used by Hibernate is quite minimal.</para>
+
+ <para>You can specify a different strategy by calling
+ <literal>Configuration.setNamingStrategy()</literal> before adding
+ mappings:</para>
+
+ <programlisting role="JAVA">SessionFactory sf = new Configuration()
.setNamingStrategy(ImprovedNamingStrategy.INSTANCE)
.addFile("Item.hbm.xml")
.addFile("Bid.hbm.xml")
- .buildSessionFactory();]]></programlisting>
-
- <para>
- <literal>org.hibernate.cfg.ImprovedNamingStrategy</literal> is a built-in
- strategy that might be a useful starting point for some applications.
- </para>
+ .buildSessionFactory();</programlisting>
- </section>
+ <para><literal>org.hibernate.cfg.ImprovedNamingStrategy</literal> is a
+ built-in strategy that might be a useful starting point for some
+ applications.</para>
+ </section>
- <section id="configuration-xmlconfig" revision="2">
- <title>XML configuration file</title>
+ <section id="configuration-xmlconfig" revision="2">
+ <title>XML configuration file</title>
- <para>
- An alternative approach to configuration is to specify a full configuration in
- a file named <literal>hibernate.cfg.xml</literal>. This file can be used as a
- replacement for the <literal>hibernate.properties</literal> file or, if both
- are present, to override properties.
- </para>
+ <para>An alternative approach to configuration is to specify a full
+ configuration in a file named <literal>hibernate.cfg.xml</literal>. This
+ file can be used as a replacement for the
+ <literal>hibernate.properties</literal> file or, if both are present, to
+ override properties.</para>
- <para>
- The XML configuration file is by default expected to be in the root of
- your <literal>CLASSPATH</literal>. Here is an example:
- </para>
+ <para>The XML configuration file is by default expected to be in the root
+ of your <literal>CLASSPATH</literal>. Here is an example:</para>
- <programlisting role="XML"><![CDATA[<?xml version='1.0' encoding='utf-8'?>
-<!DOCTYPE hibernate-configuration PUBLIC
+ <programlisting role="XML"><?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
-<hibernate-configuration>
+<hibernate-configuration>
- <!-- a SessionFactory instance listed as /jndi/name -->
- <session-factory
- name="java:hibernate/SessionFactory">
+ <!-- a SessionFactory instance listed as /jndi/name -->
+ <session-factory
+ name="java:hibernate/SessionFactory">
- <!-- properties -->
- <property name="connection.datasource">java:/comp/env/jdbc/MyDB</property>
- <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
- <property name="show_sql">false</property>
- <property name="transaction.factory_class">
+ <!-- properties -->
+ <property name="connection.datasource">java:/comp/env/jdbc/MyDB</property>
+ <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
+ <property name="show_sql">false</property>
+ <property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
- </property>
- <property name="jta.UserTransaction">java:comp/UserTransaction</property>
+ </property>
+ <property name="jta.UserTransaction">java:comp/UserTransaction</property>
- <!-- mapping files -->
- <mapping resource="org/hibernate/auction/Item.hbm.xml"/>
- <mapping resource="org/hibernate/auction/Bid.hbm.xml"/>
+ <!-- mapping files -->
+ <mapping resource="org/hibernate/auction/Item.hbm.xml"/>
+ <mapping resource="org/hibernate/auction/Bid.hbm.xml"/>
- <!-- cache settings -->
- <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
- <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
- <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
+ <!-- cache settings -->
+ <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
+ <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
+ <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
- </session-factory>
+ </session-factory>
-</hibernate-configuration>]]></programlisting>
+</hibernate-configuration></programlisting>
- <para>
- The advantage of this approach is the externalization of the
- mapping file names to configuration. The <literal>hibernate.cfg.xml</literal>
- is also more convenient once you have to tune the Hibernate cache. It is
- your choice to use either <literal>hibernate.properties</literal> or
- <literal>hibernate.cfg.xml</literal>. Both are equivalent, except for the above
- mentioned benefits of using the XML syntax.
- </para>
+ <para>The advantage of this approach is the externalization of the mapping
+ file names to configuration. The <literal>hibernate.cfg.xml</literal> is
+ also more convenient once you have to tune the Hibernate cache. It is your
+ choice to use either <literal>hibernate.properties</literal> or
+ <literal>hibernate.cfg.xml</literal>. Both are equivalent, except for the
+ above mentioned benefits of using the XML syntax.</para>
- <para>
- With the XML configuration, starting Hibernate is then as simple as:
- </para>
+ <para>With the XML configuration, starting Hibernate is then as simple
+ as:</para>
- <programlisting role="JAVA"><![CDATA[SessionFactory sf = new Configuration().configure().buildSessionFactory();]]></programlisting>
+ <programlisting role="JAVA">SessionFactory sf = new Configuration().configure().buildSessionFactory();</programlisting>
- <para>
- You can select a different XML configuration file using:
- </para>
+ <para>You can select a different XML configuration file using:</para>
- <programlisting role="JAVA"><![CDATA[SessionFactory sf = new Configuration()
+ <programlisting role="JAVA">SessionFactory sf = new Configuration()
.configure("catdb.cfg.xml")
- .buildSessionFactory();]]></programlisting>
+ .buildSessionFactory();</programlisting>
+ </section>
- </section>
+ <section id="configuration-j2ee" revision="1">
+ <title>J2EE Application Server integration</title>
- <section id="configuration-j2ee" revision="1">
- <title>J2EE Application Server integration</title>
+ <para>Hibernate has the following integration points for J2EE
+ infrastructure:</para>
- <para>
- Hibernate has the following integration points for J2EE infrastructure:
- </para>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Container-managed datasources</emphasis>: Hibernate
+ can use JDBC connections managed by the container and provided through
+ JNDI. Usually, a JTA compatible <literal>TransactionManager</literal>
+ and a <literal>ResourceManager</literal> take care of transaction
+ management (CMT), especially distributed transaction handling across
+ several datasources. You can also demarcate transaction boundaries
+ programmatically (BMT), or you might want to use the optional
+ Hibernate <literal>Transaction</literal> API for this to keep your
+ code portable.</para>
+ </listitem>
+ </itemizedlist>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>Container-managed datasources</emphasis>: Hibernate can use
- JDBC connections managed by the container and provided through JNDI. Usually,
- a JTA compatible <literal>TransactionManager</literal> and a
- <literal>ResourceManager</literal> take care of transaction management (CMT),
- especially distributed transaction handling across several datasources. You can
- also demarcate transaction boundaries programmatically (BMT), or
- you might want to use the optional Hibernate <literal>Transaction</literal>
- API for this to keep your code portable.
- </para>
- </listitem>
- </itemizedlist>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Automatic JNDI binding</emphasis>: Hibernate can bind
+ its <literal>SessionFactory</literal> to JNDI after startup.</para>
+ </listitem>
+ </itemizedlist>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>Automatic JNDI binding</emphasis>: Hibernate can bind its
- <literal>SessionFactory</literal> to JNDI after startup.
- </para>
- </listitem>
- </itemizedlist>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>JTA Session binding:</emphasis> the Hibernate
+ <literal>Session</literal> can be automatically bound to the scope of
+ JTA transactions. Simply lookup the <literal>SessionFactory</literal>
+ from JNDI and get the current <literal>Session</literal>. Let
+ Hibernate manage flushing and closing the <literal>Session</literal>
+ when your JTA transaction completes. Transaction demarcation is either
+ declarative (CMT) or programmatic (BMT/UserTransaction).</para>
+ </listitem>
+ </itemizedlist>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>JTA Session binding:</emphasis> the Hibernate <literal>Session</literal>
- can be automatically bound to the scope of JTA transactions. Simply
- lookup the <literal>SessionFactory</literal> from JNDI and get the current
- <literal>Session</literal>. Let Hibernate manage flushing and closing the
- <literal>Session</literal> when your JTA transaction completes. Transaction
- demarcation is either declarative (CMT) or programmatic (BMT/UserTransaction).
- </para>
- </listitem>
- </itemizedlist>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>JMX deployment:</emphasis> if you have a JMX capable
+ application server (e.g. JBoss AS), you can choose to deploy Hibernate
+ as a managed MBean. This saves you the one line startup code to build
+ your <literal>SessionFactory</literal> from a
+ <literal>Configuration</literal>. The container will startup your
+ <literal>HibernateService</literal> and also take care of service
+ dependencies (datasource has to be available before Hibernate starts,
+ etc).</para>
+ </listitem>
+ </itemizedlist>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>JMX deployment:</emphasis> if you have a JMX capable application server
- (e.g. JBoss AS), you can choose to deploy Hibernate as a managed MBean. This saves
- you the one line startup code to build your <literal>SessionFactory</literal> from
- a <literal>Configuration</literal>. The container will startup your
- <literal>HibernateService</literal> and also take care of service
- dependencies (datasource has to be available before Hibernate starts, etc).
- </para>
- </listitem>
- </itemizedlist>
+ <para>Depending on your environment, you might have to set the
+ configuration option
+ <literal>hibernate.connection.aggressive_release</literal> to true if your
+ application server shows "connection containment" exceptions.</para>
- <para>
- Depending on your environment, you might have to set the configuration option
- <literal>hibernate.connection.aggressive_release</literal> to true if your
- application server shows "connection containment" exceptions.
- </para>
+ <section id="configuration-optional-transactionstrategy" revision="3">
+ <title>Transaction strategy configuration</title>
- <section id="configuration-optional-transactionstrategy" revision="3">
- <title>Transaction strategy configuration</title>
+ <para>The Hibernate <literal>Session</literal> API is independent of any
+ transaction demarcation system in your architecture. If you let
+ Hibernate use JDBC directly through a connection pool, you can begin and
+ end your transactions by calling the JDBC API. If you run in a J2EE
+ application server, you might want to use bean-managed transactions and
+ call the JTA API and <literal>UserTransaction</literal> when
+ needed.</para>
- <para>
- The Hibernate <literal>Session</literal> API is independent of any transaction
- demarcation system in your architecture. If you let Hibernate use JDBC directly
- through a connection pool, you can begin and end your transactions by calling
- the JDBC API. If you run in a J2EE application server, you might want to use bean-managed
- transactions and call the JTA API and <literal>UserTransaction</literal> when needed.
- </para>
+ <para>To keep your code portable between these two (and other)
+ environments we recommend the optional Hibernate
+ <literal>Transaction</literal> API, which wraps and hides the underlying
+ system. You have to specify a factory class for
+ <literal>Transaction</literal> instances by setting the Hibernate
+ configuration property
+ <literal>hibernate.transaction.factory_class</literal>.</para>
- <para>
- To keep your code portable between these two (and other) environments we recommend the optional
- Hibernate <literal>Transaction</literal> API, which wraps and hides the underlying system.
- You have to specify a factory class for <literal>Transaction</literal> instances by setting the
- Hibernate configuration property <literal>hibernate.transaction.factory_class</literal>.
- </para>
+ <para>There are three standard, or built-in, choices:</para>
- <para>
- There are three standard, or built-in, choices:
- </para>
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term><literal>org.hibernate.transaction.JDBCTransactionFactory</literal></term>
- <variablelist spacing="compact">
- <varlistentry>
- <term><literal>org.hibernate.transaction.JDBCTransactionFactory</literal></term>
- <listitem>
- <para>delegates to database (JDBC) transactions (default)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><literal>org.hibernate.transaction.JTATransactionFactory</literal></term>
- <listitem>
- <para>
- delegates to container-managed transactions if an existing transaction is
- underway in this context (for example, EJB session bean method). Otherwise,
- a new transaction is started and bean-managed transactions are used.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><literal>org.hibernate.transaction.CMTTransactionFactory</literal></term>
- <listitem>
- <para>delegates to container-managed JTA transactions</para>
- </listitem>
- </varlistentry>
- </variablelist>
+ <listitem>
+ <para>delegates to database (JDBC) transactions (default)</para>
+ </listitem>
+ </varlistentry>
- <para>
- You can also define your own transaction strategies (for a CORBA transaction service,
- for example).
- </para>
+ <varlistentry>
+ <term><literal>org.hibernate.transaction.JTATransactionFactory</literal></term>
- <para>
- Some features in Hibernate (i.e., the second level cache, Contextual Sessions with JTA, etc.)
- require access to the JTA <literal>TransactionManager</literal> in a managed environment.
- In an application server, since J2EE does not standardize a single mechanism, you have to specify how Hibernate should obtain a reference to the
- <literal>TransactionManager</literal>:
- </para>
+ <listitem>
+ <para>delegates to container-managed transactions if an existing
+ transaction is underway in this context (for example, EJB session
+ bean method). Otherwise, a new transaction is started and
+ bean-managed transactions are used.</para>
+ </listitem>
+ </varlistentry>
- <table frame="topbot" id="jtamanagerlookup" revision="1">
- <title>JTA TransactionManagers</title>
- <tgroup cols="2">
- <colspec colwidth="2.5*"/>
- <colspec colwidth="1*"/>
- <thead>
- <row>
- <entry>Transaction Factory</entry>
- <entry align="center">Application Server</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>org.hibernate.transaction.JBossTransactionManagerLookup</literal></entry>
- <entry align="center">JBoss</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry>
- <entry align="center">Weblogic</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry>
- <entry align="center">WebSphere</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</literal></entry>
- <entry align="center">WebSphere 6</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.OrionTransactionManagerLookup</literal></entry>
- <entry align="center">Orion</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.ResinTransactionManagerLookup</literal></entry>
- <entry align="center">Resin</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.JOTMTransactionManagerLookup</literal></entry>
- <entry align="center">JOTM</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.JOnASTransactionManagerLookup</literal></entry>
- <entry align="center">JOnAS</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry>
- <entry align="center">JRun4</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.BESTransactionManagerLookup</literal></entry>
- <entry align="center">Borland ES</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <varlistentry>
+ <term><literal>org.hibernate.transaction.CMTTransactionFactory</literal></term>
- </section>
+ <listitem>
+ <para>delegates to container-managed JTA transactions</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
- <section id="configuration-optional-jndi" revision="3">
- <title>JNDI-bound <literal>SessionFactory</literal></title>
+ <para>You can also define your own transaction strategies (for a CORBA
+ transaction service, for example).</para>
- <para>
- A JNDI-bound Hibernate <literal>SessionFactory</literal> can simplify the lookup
- function of the factory and create new <literal>Session</literal>s. This
- is not, however, related to a JNDI bound <literal>Datasource</literal>; both simply use the
- same registry.
- </para>
+ <para>Some features in Hibernate (i.e., the second level cache,
+ Contextual Sessions with JTA, etc.) require access to the JTA
+ <literal>TransactionManager</literal> in a managed environment. In an
+ application server, since J2EE does not standardize a single mechanism,
+ you have to specify how Hibernate should obtain a reference to the
+ <literal>TransactionManager</literal>:</para>
- <para>
- If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify
- a name (e.g. <literal>java:hibernate/SessionFactory</literal>) using the property
- <literal>hibernate.session_factory_name</literal>. If this property is omitted, the
- <literal>SessionFactory</literal> will not be bound to JNDI. This is especially useful in
- environments with a read-only JNDI default implementation (in Tomcat, for example).
- </para>
+ <table frame="topbot" id="jtamanagerlookup" revision="1">
+ <title>JTA TransactionManagers</title>
- <para>
- When binding the <literal>SessionFactory</literal> to JNDI, Hibernate will use the values of
- <literal>hibernate.jndi.url</literal>, <literal>hibernate.jndi.class</literal> to instantiate
- an initial context. If they are not specified, the default <literal>InitialContext</literal>
- will be used.
- </para>
+ <tgroup cols="2">
+ <colspec colwidth="2.5*" />
- <para>
- Hibernate will automatically place the <literal>SessionFactory</literal> in JNDI after
- you call <literal>cfg.buildSessionFactory()</literal>. This means you will have
- this call in some startup code, or utility class in your application, unless you use
- JMX deployment with the <literal>HibernateService</literal> (this is discussed later in greater detail).
- </para>
+ <colspec colwidth="1*" />
- <para>
- If you use a JNDI <literal>SessionFactory</literal>, an EJB or any other class, you can
- obtain the <literal>SessionFactory</literal> using a JNDI lookup.
- </para>
+ <thead>
+ <row>
+ <entry>Transaction Factory</entry>
- <para>
- It is recommended that you bind the <literal>SessionFactory</literal> to JNDI in
- a managed environment and use a <literal>static</literal> singleton otherwise.
- To shield your application code from these details, we also recommend to hide the
- actual lookup code for a <literal>SessionFactory</literal> in a helper class,
- such as <literal>HibernateUtil.getSessionFactory()</literal>. Note that such a
- class is also a convenient way to startup Hibernate—see chapter 1.
- </para>
+ <entry align="center">Application Server</entry>
+ </row>
+ </thead>
- </section>
+ <tbody>
+ <row>
+ <entry><literal>org.hibernate.transaction.JBossTransactionManagerLookup</literal></entry>
- <section id="configuration-j2ee-currentsession" revision="4">
- <title>Current Session context management with JTA</title>
+ <entry align="center">JBoss</entry>
+ </row>
- <para>
- The easiest way to handle <literal>Sessions</literal> and transactions is
- Hibernate's automatic "current" <literal>Session</literal> management.
- For a discussion of contextual sessions see <xref linkend="architecture-current-session"/>.
- Using the <literal>"jta"</literal> session context, if there is no Hibernate
- <literal>Session</literal> associated with the current JTA transaction, one will
- be started and associated with that JTA transaction the first time you call
- <literal>sessionFactory.getCurrentSession()</literal>. The <literal>Session</literal>s
- retrieved via <literal>getCurrentSession()</literal> in the<literal>"jta"</literal> context
- are set to automatically flush before the transaction completes, close
- after the transaction completes, and aggressively release JDBC connections
- after each statement. This allows the <literal>Session</literal>s to
- be managed by the life cycle of the JTA transaction to which it is associated,
- keeping user code clean of such management concerns. Your code can either use
- JTA programmatically through <literal>UserTransaction</literal>, or (recommended
- for portable code) use the Hibernate <literal>Transaction</literal> API to set
- transaction boundaries. If you run in an EJB container, declarative transaction
- demarcation with CMT is preferred.
- </para>
+ <row>
+ <entry><literal>org.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry>
- </section>
+ <entry align="center">Weblogic</entry>
+ </row>
- <section id="configuration-j2ee-jmx" revision="1">
- <title>JMX deployment</title>
+ <row>
+ <entry><literal>org.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry>
- <para>
- The line <literal>cfg.buildSessionFactory()</literal> still has to be executed
- somewhere to get a <literal>SessionFactory</literal> into JNDI. You can do this
- either in a <literal>static</literal> initializer block, like the one in
- <literal>HibernateUtil</literal>, or you can deploy Hibernate as a <emphasis>managed
- service</emphasis>.
- </para>
+ <entry align="center">WebSphere</entry>
+ </row>
- <para>
- Hibernate is distributed with <literal>org.hibernate.jmx.HibernateService</literal>
- for deployment on an application server with JMX capabilities, such as JBoss AS.
- The actual deployment and configuration is vendor-specific. Here is an example
- <literal>jboss-service.xml</literal> for JBoss 4.0.x:
- </para>
+ <row>
+ <entry><literal>org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</literal></entry>
- <programlisting role="XML"><![CDATA[<?xml version="1.0"?>
-<server>
+ <entry align="center">WebSphere 6</entry>
+ </row>
-<mbean code="org.hibernate.jmx.HibernateService"
- name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
+ <row>
+ <entry><literal>org.hibernate.transaction.OrionTransactionManagerLookup</literal></entry>
- <!-- Required services -->
- <depends>jboss.jca:service=RARDeployer</depends>
- <depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends>
+ <entry align="center">Orion</entry>
+ </row>
- <!-- Bind the Hibernate service to JNDI -->
- <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
+ <row>
+ <entry><literal>org.hibernate.transaction.ResinTransactionManagerLookup</literal></entry>
- <!-- Datasource settings -->
- <attribute name="Datasource">java:HsqlDS</attribute>
- <attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
+ <entry align="center">Resin</entry>
+ </row>
- <!-- Transaction integration -->
- <attribute name="TransactionStrategy">
- org.hibernate.transaction.JTATransactionFactory</attribute>
- <attribute name="TransactionManagerLookupStrategy">
- org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
- <attribute name="FlushBeforeCompletionEnabled">true</attribute>
- <attribute name="AutoCloseSessionEnabled">true</attribute>
+ <row>
+ <entry><literal>org.hibernate.transaction.JOTMTransactionManagerLookup</literal></entry>
- <!-- Fetching options -->
- <attribute name="MaximumFetchDepth">5</attribute>
+ <entry align="center">JOTM</entry>
+ </row>
- <!-- Second-level caching -->
- <attribute name="SecondLevelCacheEnabled">true</attribute>
- <attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
- <attribute name="QueryCacheEnabled">true</attribute>
+ <row>
+ <entry><literal>org.hibernate.transaction.JOnASTransactionManagerLookup</literal></entry>
- <!-- Logging -->
- <attribute name="ShowSqlEnabled">true</attribute>
+ <entry align="center">JOnAS</entry>
+ </row>
- <!-- Mapping files -->
- <attribute name="MapResources">auction/Item.hbm.xml,auction/Category.hbm.xml</attribute>
+ <row>
+ <entry><literal>org.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry>
-</mbean>
+ <entry align="center">JRun4</entry>
+ </row>
-</server>]]></programlisting>
+ <row>
+ <entry><literal>org.hibernate.transaction.BESTransactionManagerLookup</literal></entry>
- <para>
- This file is deployed in a directory called <literal>META-INF</literal> and packaged
- in a JAR file with the extension <literal>.sar</literal> (service archive). You also need
- to package Hibernate, its required third-party libraries, your compiled persistent classes,
- as well as your mapping files in the same archive. Your enterprise beans (usually session
- beans) can be kept in their own JAR file, but you can include this EJB JAR file in the
- main service archive to get a single (hot-)deployable unit. Consult the JBoss AS
- documentation for more information about JMX service and EJB deployment.
- </para>
+ <entry align="center">Borland ES</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
- </section>
+ <section id="configuration-optional-jndi" revision="3">
+ <title>JNDI-bound <literal>SessionFactory</literal></title>
+ <para>A JNDI-bound Hibernate <literal>SessionFactory</literal> can
+ simplify the lookup function of the factory and create new
+ <literal>Session</literal>s. This is not, however, related to a JNDI
+ bound <literal>Datasource</literal>; both simply use the same
+ registry.</para>
+
+ <para>If you wish to have the <literal>SessionFactory</literal> bound to
+ a JNDI namespace, specify a name (e.g.
+ <literal>java:hibernate/SessionFactory</literal>) using the property
+ <literal>hibernate.session_factory_name</literal>. If this property is
+ omitted, the <literal>SessionFactory</literal> will not be bound to
+ JNDI. This is especially useful in environments with a read-only JNDI
+ default implementation (in Tomcat, for example).</para>
+
+ <para>When binding the <literal>SessionFactory</literal> to JNDI,
+ Hibernate will use the values of <literal>hibernate.jndi.url</literal>,
+ <literal>hibernate.jndi.class</literal> to instantiate an initial
+ context. If they are not specified, the default
+ <literal>InitialContext</literal> will be used.</para>
+
+ <para>Hibernate will automatically place the
+ <literal>SessionFactory</literal> in JNDI after you call
+ <literal>cfg.buildSessionFactory()</literal>. This means you will have
+ this call in some startup code, or utility class in your application,
+ unless you use JMX deployment with the
+ <literal>HibernateService</literal> (this is discussed later in greater
+ detail).</para>
+
+ <para>If you use a JNDI <literal>SessionFactory</literal>, an EJB or any
+ other class, you can obtain the <literal>SessionFactory</literal> using
+ a JNDI lookup.</para>
+
+ <para>It is recommended that you bind the
+ <literal>SessionFactory</literal> to JNDI in a managed environment and
+ use a <literal>static</literal> singleton otherwise. To shield your
+ application code from these details, we also recommend to hide the
+ actual lookup code for a <literal>SessionFactory</literal> in a helper
+ class, such as <literal>HibernateUtil.getSessionFactory()</literal>.
+ Note that such a class is also a convenient way to startup Hibernate—see
+ chapter 1.</para>
</section>
-</chapter>
+ <section id="configuration-j2ee-currentsession" revision="4">
+ <title>Current Session context management with JTA</title>
+ <para>The easiest way to handle <literal>Sessions</literal> and
+ transactions is Hibernate's automatic "current"
+ <literal>Session</literal> management. For a discussion of contextual
+ sessions see <xref linkend="architecture-current-session" />. Using the
+ <literal>"jta"</literal> session context, if there is no Hibernate
+ <literal>Session</literal> associated with the current JTA transaction,
+ one will be started and associated with that JTA transaction the first
+ time you call <literal>sessionFactory.getCurrentSession()</literal>. The
+ <literal>Session</literal>s retrieved via
+ <literal>getCurrentSession()</literal> in the<literal>"jta"</literal>
+ context are set to automatically flush before the transaction completes,
+ close after the transaction completes, and aggressively release JDBC
+ connections after each statement. This allows the
+ <literal>Session</literal>s to be managed by the life cycle of the JTA
+ transaction to which it is associated, keeping user code clean of such
+ management concerns. Your code can either use JTA programmatically
+ through <literal>UserTransaction</literal>, or (recommended for portable
+ code) use the Hibernate <literal>Transaction</literal> API to set
+ transaction boundaries. If you run in an EJB container, declarative
+ transaction demarcation with CMT is preferred.</para>
+ </section>
+
+ <section id="configuration-j2ee-jmx" revision="1">
+ <title>JMX deployment</title>
+
+ <para>The line <literal>cfg.buildSessionFactory()</literal> still has to
+ be executed somewhere to get a <literal>SessionFactory</literal> into
+ JNDI. You can do this either in a <literal>static</literal> initializer
+ block, like the one in <literal>HibernateUtil</literal>, or you can
+ deploy Hibernate as a <emphasis>managed service</emphasis>.</para>
+
+ <para>Hibernate is distributed with
+ <literal>org.hibernate.jmx.HibernateService</literal> for deployment on
+ an application server with JMX capabilities, such as JBoss AS. The
+ actual deployment and configuration is vendor-specific. Here is an
+ example <literal>jboss-service.xml</literal> for JBoss 4.0.x:</para>
+
+ <programlisting role="XML"><?xml version="1.0"?>
+<server>
+
+<mbean code="org.hibernate.jmx.HibernateService"
+ name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
+
+ <!-- Required services -->
+ <depends>jboss.jca:service=RARDeployer</depends>
+ <depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends>
+
+ <!-- Bind the Hibernate service to JNDI -->
+ <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
+
+ <!-- Datasource settings -->
+ <attribute name="Datasource">java:HsqlDS</attribute>
+ <attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
+
+ <!-- Transaction integration -->
+ <attribute name="TransactionStrategy">
+ org.hibernate.transaction.JTATransactionFactory</attribute>
+ <attribute name="TransactionManagerLookupStrategy">
+ org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
+ <attribute name="FlushBeforeCompletionEnabled">true</attribute>
+ <attribute name="AutoCloseSessionEnabled">true</attribute>
+
+ <!-- Fetching options -->
+ <attribute name="MaximumFetchDepth">5</attribute>
+
+ <!-- Second-level caching -->
+ <attribute name="SecondLevelCacheEnabled">true</attribute>
+ <attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
+ <attribute name="QueryCacheEnabled">true</attribute>
+
+ <!-- Logging -->
+ <attribute name="ShowSqlEnabled">true</attribute>
+
+ <!-- Mapping files -->
+ <attribute name="MapResources">auction/Item.hbm.xml,auction/Category.hbm.xml</attribute>
+
+</mbean>
+
+</server></programlisting>
+
+ <para>This file is deployed in a directory called
+ <literal>META-INF</literal> and packaged in a JAR file with the
+ extension <literal>.sar</literal> (service archive). You also need to
+ package Hibernate, its required third-party libraries, your compiled
+ persistent classes, as well as your mapping files in the same archive.
+ Your enterprise beans (usually session beans) can be kept in their own
+ JAR file, but you can include this EJB JAR file in the main service
+ archive to get a single (hot-)deployable unit. Consult the JBoss AS
+ documentation for more information about JMX service and EJB
+ deployment.</para>
+ </section>
+ </section>
+</chapter>
13 years, 10 months
Hibernate SVN: r19804 - in core/trunk: core/src/main/java/org/hibernate/tool/hbm2ddl and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-23 18:33:00 -0400 (Wed, 23 Jun 2010)
New Revision: 19804
Added:
core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.java
core/trunk/testsuite/src/test/resources/dogs.sql
core/trunk/testsuite/src/test/resources/humans.sql
Removed:
core/trunk/testsuite/src/test/resources/database.sql
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java
core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java
Log:
HHH-5337 support for comma-separated multi-files imports
hibernate.hbm2ddl.import_files=[filename],[filename2],...
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2010-06-23 22:32:15 UTC (rev 19803)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2010-06-23 22:33:00 UTC (rev 19804)
@@ -469,13 +469,17 @@
public static final String HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
/**
- * Name of the optional file containing SQL DML statements executed during the SessionFactory creation.
+ * Comma-separated names of the optional files containing SQL DML statements executed
+ * during the SessionFactory creation.
+ * File order matters, the statements of a give file are executed before the statements of the
+ * following files.
+ *
* These statements are only executed if the schema is created ie if <tt>hibernate.hbm2ddl.auto</tt>
* is set to <tt>create</tt> or <tt>create-drop</tt>.
*
* The default value is <tt>/import.sql</tt>
*/
- public static final String HBM2DDL_IMPORT_FILE = "hibernate.hbm2ddl.import_file";
+ public static final String HBM2DDL_IMPORT_FILES = "hibernate.hbm2ddl.import_files";
/**
* The {@link org.hibernate.exception.SQLExceptionConverter} to use for converting SQLExceptions
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java 2010-06-23 22:32:15 UTC (rev 19803)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java 2010-06-23 22:33:00 UTC (rev 19804)
@@ -100,7 +100,7 @@
// private ComponentTuplizerFactory componentTuplizerFactory; todo : HHH-3517 and HHH-1907
// private BytecodeProvider bytecodeProvider;
private JdbcSupport jdbcSupport;
-private String importFile;
+ private String importFiles;
/**
* Package protected constructor
@@ -118,12 +118,12 @@
// return formatSql;
// }
- public String getImportFile() {
- return importFile;
+ public String getImportFiles() {
+ return importFiles;
}
- public void setImportFile(String importFile) {
- this.importFile = importFile;
+ public void setImportFiles(String importFiles) {
+ this.importFiles = importFiles;
}
public SQLStatementLogger getSqlStatementLogger() {
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2010-06-23 22:32:15 UTC (rev 19803)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2010-06-23 22:33:00 UTC (rev 19804)
@@ -337,7 +337,7 @@
settings.setAutoCreateSchema(true);
settings.setAutoDropSchema(true);
}
- settings.setImportFile( properties.getProperty( Environment.HBM2DDL_IMPORT_FILE ) );
+ settings.setImportFiles( properties.getProperty( Environment.HBM2DDL_IMPORT_FILES ) );
EntityMode defaultEntityMode = EntityMode.parse( properties.getProperty( Environment.DEFAULT_ENTITY_MODE ) );
log.info( "Default entity-mode: " + defaultEntityMode );
Modified: core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java 2010-06-23 22:32:15 UTC (rev 19803)
+++ core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java 2010-06-23 22:33:00 UTC (rev 19804)
@@ -73,7 +73,7 @@
private String[] dropSQL;
private String[] createSQL;
private String outputFile = null;
- private String importFile;
+ private String importFiles;
private Dialect dialect;
private String delimiter;
private final List exceptions = new ArrayList();
@@ -106,7 +106,7 @@
createSQL = cfg.generateSchemaCreationScript( dialect );
sqlStatementLogger = settings.getSqlStatementLogger();
formatter = ( sqlStatementLogger.isFormatSql() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
- importFile = settings.getImportFile() != null ? settings.getImportFile() : DEFAULT_IMPORT_FILE;
+ importFiles = settings.getImportFiles() != null ? settings.getImportFiles() : DEFAULT_IMPORT_FILE;
}
/**
@@ -132,7 +132,7 @@
formatter = ( PropertiesHelper.getBoolean( Environment.FORMAT_SQL, props ) ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
- importFile = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILE, props, DEFAULT_IMPORT_FILE );
+ importFiles = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILES, props, DEFAULT_IMPORT_FILE );
}
/**
@@ -148,7 +148,7 @@
dropSQL = cfg.generateDropSchemaScript( dialect );
createSQL = cfg.generateSchemaCreationScript( dialect );
formatter = ( PropertiesHelper.getBoolean( Environment.FORMAT_SQL, cfg.getProperties() ) ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
- importFile = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILE, cfg.getProperties(),
+ importFiles = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILES, cfg.getProperties(),
DEFAULT_IMPORT_FILE
);
}
@@ -172,7 +172,7 @@
* @deprecated use {@link org.hibernate.cfg.Environment.HBM2DDL_IMPORT_FILE}
*/
public SchemaExport setImportFile(String filename) {
- importFile = filename;
+ importFiles = filename;
return this;
}
@@ -235,20 +235,23 @@
Connection connection = null;
Writer outputFileWriter = null;
- Reader importFileReader = null;
+ List<NamedReader> importFileReaders = new ArrayList<NamedReader>();
Statement statement = null;
exceptions.clear();
try {
- try {
- InputStream stream = ConfigHelper.getResourceAsStream( importFile );
- importFileReader = new InputStreamReader( stream );
+ for ( String currentFile : importFiles.split(",") ) {
+ try {
+ final String resourceName = currentFile.trim();
+ InputStream stream = ConfigHelper.getResourceAsStream( resourceName );
+ importFileReaders.add( new NamedReader( resourceName, stream ) );
+ }
+ catch ( HibernateException e ) {
+ log.debug( "import file not found: " + currentFile );
+ }
}
- catch ( HibernateException e ) {
- log.debug( "import file not found: " + importFile );
- }
if ( outputFile != null ) {
log.info( "writing generated schema to file: " + outputFile );
@@ -268,8 +271,10 @@
if ( !justDrop ) {
create( script, export, outputFileWriter, statement );
- if ( export && importFileReader != null ) {
- importScript( importFileReader, statement );
+ if ( export && importFileReaders.size() > 0 ) {
+ for (NamedReader reader : importFileReaders) {
+ importScript( reader, statement );
+ }
}
}
@@ -301,22 +306,47 @@
if ( outputFileWriter != null ) {
outputFileWriter.close();
}
- if ( importFileReader != null ) {
- importFileReader.close();
- }
}
catch ( IOException ioe ) {
exceptions.add( ioe );
log.error( "Error closing output file: " + outputFile, ioe );
}
+ for (NamedReader reader : importFileReaders) {
+ try {
+ reader.getReader().close();
+ }
+ catch ( IOException ioe ) {
+ exceptions.add( ioe );
+ log.error( "Error closing imput files: " + reader.getName(), ioe );
+ }
+ }
+
}
}
- private void importScript(Reader importFileReader, Statement statement)
+ private class NamedReader {
+ private final Reader reader;
+ private final String name;
+
+ public NamedReader(String name, InputStream stream) {
+ this.name = name;
+ this.reader = new InputStreamReader( stream );
+ }
+
+ public Reader getReader() {
+ return reader;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+
+ private void importScript(NamedReader importFileReader, Statement statement)
throws IOException {
- log.info( "Executing import script: " + importFile );
- BufferedReader reader = new BufferedReader( importFileReader );
+ log.info( "Executing import script: " + importFileReader.getName() );
+ BufferedReader reader = new BufferedReader( importFileReader.getReader() );
long lineNo = 0;
for ( String sql = reader.readLine(); sql != null; sql = reader.readLine() ) {
try {
@@ -480,7 +510,7 @@
}
if (importFile != null) {
- cfg.setProperty( Environment.HBM2DDL_IMPORT_FILE, importFile );
+ cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, importFile );
}
SchemaExport se = new SchemaExport( cfg )
.setHaltOnError( halt )
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.hbm.xml (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.hbm.xml 2010-06-23 22:33:00 UTC (rev 19804)
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ Test for import files.
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.importfile">
+ <class name="Dog" table="dog">
+ <id name="id"/>
+ <many-to-one name="master" column="master_fk"/>
+ </class>
+</hibernate-mapping>
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Dog.java 2010-06-23 22:33:00 UTC (rev 19804)
@@ -0,0 +1,25 @@
+package org.hibernate.test.importfile;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Dog {
+ private Integer id;
+ private Human master;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Human getMaster() {
+ return master;
+ }
+
+ public void setMaster(Human master) {
+ this.master = master;
+ }
+}
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java 2010-06-23 22:32:15 UTC (rev 19803)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java 2010-06-23 22:33:00 UTC (rev 19804)
@@ -16,17 +16,23 @@
public void testImportFile() throws Exception {
Session s = openSession( );
final Transaction tx = s.beginTransaction();
- final List<?> list = s.createQuery( "from " + Human.class.getName() ).list();
- assertEquals( "database.sql not imported", 3, list.size() );
- for (Object entity : list) {
+ final List<?> humans = s.createQuery( "from " + Human.class.getName() ).list();
+ assertEquals( "humans.sql not imported", 3, humans.size() );
+
+ final List<?> dogs = s.createQuery( "from " + Dog.class.getName() ).list();
+ assertEquals( "dogs.sql not imported", 3, dogs.size() );
+ for (Object entity : dogs) {
s.delete( entity );
}
+ for (Object entity : humans) {
+ s.delete( entity );
+ }
tx.commit();
s.close();
}
public void configure(Configuration cfg) {
- cfg.setProperty( Environment.HBM2DDL_IMPORT_FILE, "/database.sql");
+ cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, "/humans.sql,/dogs.sql");
}
public ImportFileTest(String string) {
@@ -35,7 +41,8 @@
public String[] getMappings() {
return new String[] {
- "importfile/Human.hbm.xml"
+ "importfile/Human.hbm.xml",
+ "importfile/Dog.hbm.xml"
};
}
}
Deleted: core/trunk/testsuite/src/test/resources/database.sql
===================================================================
--- core/trunk/testsuite/src/test/resources/database.sql 2010-06-23 22:32:15 UTC (rev 19803)
+++ core/trunk/testsuite/src/test/resources/database.sql 2010-06-23 22:33:00 UTC (rev 19804)
@@ -1,3 +0,0 @@
-INSERT INTO human (id, fname, lname) VALUES (1,'Emmanuel','Bernard')
-INSERT INTO human (id, fname, lname) VALUES (2,'Gavin','King')
-INSERT INTO human (id, fname, lname) VALUES (3,'Max','Andersen')
\ No newline at end of file
Added: core/trunk/testsuite/src/test/resources/dogs.sql
===================================================================
--- core/trunk/testsuite/src/test/resources/dogs.sql (rev 0)
+++ core/trunk/testsuite/src/test/resources/dogs.sql 2010-06-23 22:33:00 UTC (rev 19804)
@@ -0,0 +1,3 @@
+INSERT INTO dog (id, master_fk) VALUES (1,1)
+INSERT INTO dog (id, master_fk) VALUES (2,2)
+INSERT INTO dog (id, master_fk) VALUES (3,3)
\ No newline at end of file
Copied: core/trunk/testsuite/src/test/resources/humans.sql (from rev 19803, core/trunk/testsuite/src/test/resources/database.sql)
===================================================================
--- core/trunk/testsuite/src/test/resources/humans.sql (rev 0)
+++ core/trunk/testsuite/src/test/resources/humans.sql 2010-06-23 22:33:00 UTC (rev 19804)
@@ -0,0 +1,3 @@
+INSERT INTO human (id, fname, lname) VALUES (1,'Emmanuel','Bernard')
+INSERT INTO human (id, fname, lname) VALUES (2,'Gavin','King')
+INSERT INTO human (id, fname, lname) VALUES (3,'Max','Andersen')
\ No newline at end of file
13 years, 10 months
Hibernate SVN: r19803 - in core/trunk: core/src/main/java/org/hibernate/tool/hbm2ddl and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-23 18:32:15 -0400 (Wed, 23 Jun 2010)
New Revision: 19803
Added:
core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/
core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.java
core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java
core/trunk/testsuite/src/test/resources/database.sql
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java
core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
Log:
HHH-5337 Allow Customization of DML import file name
hibernate.hbm2ddl.import_file=[filename]
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2010-06-23 18:08:55 UTC (rev 19802)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2010-06-23 22:32:15 UTC (rev 19803)
@@ -469,6 +469,15 @@
public static final String HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
/**
+ * Name of the optional file containing SQL DML statements executed during the SessionFactory creation.
+ * These statements are only executed if the schema is created ie if <tt>hibernate.hbm2ddl.auto</tt>
+ * is set to <tt>create</tt> or <tt>create-drop</tt>.
+ *
+ * The default value is <tt>/import.sql</tt>
+ */
+ public static final String HBM2DDL_IMPORT_FILE = "hibernate.hbm2ddl.import_file";
+
+ /**
* The {@link org.hibernate.exception.SQLExceptionConverter} to use for converting SQLExceptions
* to Hibernate's JDBCException hierarchy. The default is to use the configured
* {@link org.hibernate.dialect.Dialect}'s preferred SQLExceptionConverter.
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java 2010-06-23 18:08:55 UTC (rev 19802)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java 2010-06-23 22:32:15 UTC (rev 19803)
@@ -100,6 +100,7 @@
// private ComponentTuplizerFactory componentTuplizerFactory; todo : HHH-3517 and HHH-1907
// private BytecodeProvider bytecodeProvider;
private JdbcSupport jdbcSupport;
+private String importFile;
/**
* Package protected constructor
@@ -117,6 +118,14 @@
// return formatSql;
// }
+ public String getImportFile() {
+ return importFile;
+ }
+
+ public void setImportFile(String importFile) {
+ this.importFile = importFile;
+ }
+
public SQLStatementLogger getSqlStatementLogger() {
return sqlStatementLogger;
}
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2010-06-23 18:08:55 UTC (rev 19802)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2010-06-23 22:32:15 UTC (rev 19803)
@@ -337,6 +337,7 @@
settings.setAutoCreateSchema(true);
settings.setAutoDropSchema(true);
}
+ settings.setImportFile( properties.getProperty( Environment.HBM2DDL_IMPORT_FILE ) );
EntityMode defaultEntityMode = EntityMode.parse( properties.getProperty( Environment.DEFAULT_ENTITY_MODE ) );
log.info( "Default entity-mode: " + defaultEntityMode );
Modified: core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java 2010-06-23 18:08:55 UTC (rev 19802)
+++ core/trunk/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java 2010-06-23 22:32:15 UTC (rev 19803)
@@ -73,13 +73,14 @@
private String[] dropSQL;
private String[] createSQL;
private String outputFile = null;
- private String importFile = "/import.sql";
+ private String importFile;
private Dialect dialect;
private String delimiter;
private final List exceptions = new ArrayList();
private boolean haltOnError = false;
private Formatter formatter;
private SQLStatementLogger sqlStatementLogger;
+ private static final String DEFAULT_IMPORT_FILE = "/import.sql";
/**
* Create a schema exporter for the given Configuration
@@ -105,6 +106,7 @@
createSQL = cfg.generateSchemaCreationScript( dialect );
sqlStatementLogger = settings.getSqlStatementLogger();
formatter = ( sqlStatementLogger.isFormatSql() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
+ importFile = settings.getImportFile() != null ? settings.getImportFile() : DEFAULT_IMPORT_FILE;
}
/**
@@ -129,6 +131,8 @@
createSQL = cfg.generateSchemaCreationScript( dialect );
formatter = ( PropertiesHelper.getBoolean( Environment.FORMAT_SQL, props ) ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
+
+ importFile = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILE, props, DEFAULT_IMPORT_FILE );
}
/**
@@ -144,6 +148,9 @@
dropSQL = cfg.generateDropSchemaScript( dialect );
createSQL = cfg.generateSchemaCreationScript( dialect );
formatter = ( PropertiesHelper.getBoolean( Environment.FORMAT_SQL, cfg.getProperties() ) ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
+ importFile = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILE, cfg.getProperties(),
+ DEFAULT_IMPORT_FILE
+ );
}
/**
@@ -162,6 +169,7 @@
*
* @param filename The import file name.
* @return this
+ * @deprecated use {@link org.hibernate.cfg.Environment.HBM2DDL_IMPORT_FILE}
*/
public SchemaExport setImportFile(String filename) {
importFile = filename;
@@ -405,7 +413,7 @@
boolean halt = false;
boolean export = true;
String outFile = null;
- String importFile = "/import.sql";
+ String importFile = DEFAULT_IMPORT_FILE;
String propFile = null;
boolean format = false;
String delim = null;
@@ -471,10 +479,12 @@
cfg.setProperties( props );
}
+ if (importFile != null) {
+ cfg.setProperty( Environment.HBM2DDL_IMPORT_FILE, importFile );
+ }
SchemaExport se = new SchemaExport( cfg )
.setHaltOnError( halt )
.setOutputFile( outFile )
- .setImportFile( importFile )
.setDelimiter( delim );
if ( format ) {
se.setFormat( true );
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.hbm.xml (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.hbm.xml 2010-06-23 22:32:15 UTC (rev 19803)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ Test for import files.
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.importfile">
+ <class name="Human" table="human">
+ <id name="id"/>
+ <property name="firstname" column="fname"/>
+ <property name="lastname" column="lname"/>
+ </class>
+</hibernate-mapping>
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/Human.java 2010-06-23 22:32:15 UTC (rev 19803)
@@ -0,0 +1,34 @@
+package org.hibernate.test.importfile;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Human {
+ private Integer id;
+ private String firstname;
+ private String lastname;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+}
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/importfile/ImportFileTest.java 2010-06-23 22:32:15 UTC (rev 19803)
@@ -0,0 +1,41 @@
+package org.hibernate.test.importfile;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ImportFileTest extends FunctionalTestCase {
+
+ public void testImportFile() throws Exception {
+ Session s = openSession( );
+ final Transaction tx = s.beginTransaction();
+ final List<?> list = s.createQuery( "from " + Human.class.getName() ).list();
+ assertEquals( "database.sql not imported", 3, list.size() );
+ for (Object entity : list) {
+ s.delete( entity );
+ }
+ tx.commit();
+ s.close();
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.HBM2DDL_IMPORT_FILE, "/database.sql");
+ }
+
+ public ImportFileTest(String string) {
+ super( string );
+ }
+
+ public String[] getMappings() {
+ return new String[] {
+ "importfile/Human.hbm.xml"
+ };
+ }
+}
Added: core/trunk/testsuite/src/test/resources/database.sql
===================================================================
--- core/trunk/testsuite/src/test/resources/database.sql (rev 0)
+++ core/trunk/testsuite/src/test/resources/database.sql 2010-06-23 22:32:15 UTC (rev 19803)
@@ -0,0 +1,3 @@
+INSERT INTO human (id, fname, lname) VALUES (1,'Emmanuel','Bernard')
+INSERT INTO human (id, fname, lname) VALUES (2,'Gavin','King')
+INSERT INTO human (id, fname, lname) VALUES (3,'Max','Andersen')
\ No newline at end of file
13 years, 10 months
Hibernate SVN: r19802 - core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/compositeelement.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-06-23 14:08:55 -0400 (Wed, 23 Jun 2010)
New Revision: 19802
Modified:
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/compositeelement/CompositeElementTest.java
Log:
HHH-5305 : Added 'FailureExpected' tests for selecting elements of a collection mapped as composite-element
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/compositeelement/CompositeElementTest.java
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/compositeelement/CompositeElementTest.java 2010-06-23 17:34:22 UTC (rev 19801)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/compositeelement/CompositeElementTest.java 2010-06-23 18:08:55 UTC (rev 19802)
@@ -87,6 +87,70 @@
s.close();
}
+ public void testHandSQLSetOfCompositeElementsByAliasFailureExpected() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Child c = new Child( "Child One" );
+ Parent p = new Parent( "Parent" );
+ p.getChildren().add( c );
+ c.setParent( p );
+ s.save( p );
+ s.flush();
+
+ p.getChildren().remove( c );
+ c.setParent( null );
+ s.flush();
+
+ p.getChildren().add( c );
+ c.setParent( p );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.createQuery("select c from Parent p left outer join p.children c").uniqueResult();
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( p );
+ t.commit();
+ s.close();
+ }
+
+ public void testHandSQLSetOfCompositeElementsByPathFailureExpected() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Child c = new Child( "Child One" );
+ Parent p = new Parent( "Parent" );
+ p.getChildren().add( c );
+ c.setParent( p );
+ s.save( p );
+ s.flush();
+
+ p.getChildren().remove( c );
+ c.setParent( null );
+ s.flush();
+
+ p.getChildren().add( c );
+ c.setParent( p );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.createQuery("select p.children from Parent p left outer join p.children").uniqueResult(); //we really need to be able to do this!
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( p );
+ t.commit();
+ s.close();
+ }
+
public void testCustomColumnReadAndWrite() {
final double HEIGHT_INCHES = 49;
final double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d;
13 years, 10 months
Hibernate SVN: r19801 - core/branches/Branch_3_3_2_GA_CP/parent.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-06-23 13:34:22 -0400 (Wed, 23 Jun 2010)
New Revision: 19801
Modified:
core/branches/Branch_3_3_2_GA_CP/parent/pom.xml
Log:
JBPAPP-4517 update javassist dependency to 3.12.0.GA in hibernate
Modified: core/branches/Branch_3_3_2_GA_CP/parent/pom.xml
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2010-06-23 16:18:16 UTC (rev 19800)
+++ core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2010-06-23 17:34:22 UTC (rev 19801)
@@ -380,7 +380,7 @@
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
- <version>3.9.0.GA</version>
+ <version>3.12.0.GA</version>
</dependency>
<!-- cglib is optional, but if defined it should be version 2.2 -->
<dependency>
13 years, 10 months
Hibernate SVN: r19800 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator: util/annotationfactory and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-06-23 12:18:16 -0400 (Wed, 23 Jun 2010)
New Revision: 19800
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintHelper.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/annotationfactory/AnnotationProxy.java
Log:
HV-341
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java 2010-06-23 14:55:58 UTC (rev 19799)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java 2010-06-23 16:18:16 UTC (rev 19800)
@@ -440,8 +440,9 @@
List<ConstraintDescriptorImpl<?>> constraintDescriptors = new ArrayList<ConstraintDescriptorImpl<?>>();
List<Annotation> constraints = new ArrayList<Annotation>();
- if ( constraintHelper.isConstraintAnnotation( annotation ) ||
- constraintHelper.isBuiltinConstraint( annotation.annotationType() ) ) {
+ Class<? extends Annotation> annotationType = annotation.annotationType();
+ if ( constraintHelper.isConstraintAnnotation( annotationType )
+ || constraintHelper.isBuiltinConstraint( annotationType ) ) {
constraints.add( annotation );
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java 2010-06-23 14:55:58 UTC (rev 19799)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java 2010-06-23 16:18:16 UTC (rev 19800)
@@ -83,6 +83,11 @@
private final T annotation;
/**
+ * The type of the annotation made instance variable, because {@code annotation.annotationType()} is quite expensive.
+ */
+ private final Class<T> annotationType;
+
+ /**
* The set of classes implementing the validation for this constraint. See also
* <code>ConstraintValidator</code> resolution algorithm.
*/
@@ -134,10 +139,11 @@
public ConstraintDescriptorImpl(T annotation, ConstraintHelper constraintHelper, Class<?> implicitGroup, ElementType type, ConstraintOrigin definedOn) {
this.annotation = annotation;
+ this.annotationType = ( Class<T> ) this.annotation.annotationType();
this.constraintHelper = constraintHelper;
this.elementType = type;
this.definedOn = definedOn;
- this.isReportAsSingleInvalidConstraint = annotation.annotationType().isAnnotationPresent(
+ this.isReportAsSingleInvalidConstraint = annotationType.isAnnotationPresent(
ReportAsSingleViolation.class
);
@@ -191,7 +197,6 @@
}
private List<Class<? extends ConstraintValidator<T, ?>>> findConstraintValidatorClasses() {
- final Class<T> annotationType = getAnnotationType();
final List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses = new ArrayList<Class<? extends ConstraintValidator<T, ?>>>();
if ( constraintHelper.containsConstraintValidatorDefinition( annotationType ) ) {
for ( Class<? extends ConstraintValidator<T, ?>> validator : constraintHelper
@@ -202,7 +207,7 @@
}
List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> constraintDefinitionClasses = new ArrayList<Class<? extends ConstraintValidator<? extends Annotation, ?>>>();
- if ( constraintHelper.isBuiltinConstraint( annotation.annotationType() ) ) {
+ if ( constraintHelper.isBuiltinConstraint( annotationType ) ) {
constraintDefinitionClasses.addAll( constraintHelper.getBuiltInConstraints( annotationType ) );
}
else {
@@ -213,7 +218,7 @@
}
constraintHelper.addConstraintValidatorDefinition(
- annotation.annotationType(), constraintDefinitionClasses
+ annotationType, constraintDefinitionClasses
);
for ( Class<? extends ConstraintValidator<? extends Annotation, ?>> validator : constraintDefinitionClasses ) {
@@ -224,11 +229,6 @@
return Collections.unmodifiableList( constraintValidatorClasses );
}
- @SuppressWarnings("unchecked")
- private Class<T> getAnnotationType() {
- return ( Class<T> ) annotation.annotationType();
- }
-
public T getAnnotation() {
return annotation;
}
@@ -269,7 +269,7 @@
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append( "ConstraintDescriptorImpl" );
- sb.append( "{annotation=" ).append( annotation.annotationType().getName() );
+ sb.append( "{annotation=" ).append( annotationType.getName() );
sb.append( ", payloads=" ).append( payloads );
sb.append( ", hasComposingConstraints=" ).append( composingConstraints.isEmpty() );
sb.append( ", isReportAsSingleInvalidConstraint=" ).append( isReportAsSingleInvalidConstraint );
@@ -315,7 +315,7 @@
private Map<ClassIndexWrapper, Map<String, Object>> parseOverrideParameters() {
Map<ClassIndexWrapper, Map<String, Object>> overrideParameters = new HashMap<ClassIndexWrapper, Map<String, Object>>();
- final Method[] methods = ReflectionHelper.getMethods( annotation.annotationType() );
+ final Method[] methods = ReflectionHelper.getMethods( annotationType );
for ( Method m : methods ) {
if ( m.getAnnotation( OverridesAttribute.class ) != null ) {
addOverrideAttributes(
@@ -370,19 +370,22 @@
Set<ConstraintDescriptor<?>> composingConstraintsSet = new HashSet<ConstraintDescriptor<?>>();
Map<ClassIndexWrapper, Map<String, Object>> overrideParameters = parseOverrideParameters();
- for ( Annotation declaredAnnotation : annotation.annotationType().getDeclaredAnnotations() ) {
- if ( NON_COMPOSING_CONSTRAINT_ANNOTATIONS.contains( declaredAnnotation.annotationType().getName() ) ) {
+ for ( Annotation declaredAnnotation : annotationType.getDeclaredAnnotations() ) {
+ Class<? extends Annotation> declaredAnnotationType = declaredAnnotation.annotationType();
+ if ( NON_COMPOSING_CONSTRAINT_ANNOTATIONS.contains( declaredAnnotationType.getName() ) ) {
// ignore the usual suspects which will be in almost any constraint, but are no composing constraint
continue;
}
- if ( constraintHelper.isConstraintAnnotation( declaredAnnotation )
- || constraintHelper.isBuiltinConstraint( declaredAnnotation.annotationType() ) ) {
+ if ( constraintHelper.isConstraintAnnotation( declaredAnnotationType )
+ || constraintHelper.isBuiltinConstraint( declaredAnnotationType ) ) {
ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(
declaredAnnotation, overrideParameters, OVERRIDES_PARAMETER_DEFAULT_INDEX
);
composingConstraintsSet.add( descriptor );
- log.debug( "Adding composing constraint: " + descriptor );
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Adding composing constraint: " + descriptor );
+ }
}
else if ( constraintHelper.isMultiValueConstraint( declaredAnnotation ) ) {
List<Annotation> multiValueConstraints = constraintHelper.getMultiValueConstraints( declaredAnnotation );
@@ -392,7 +395,9 @@
constraintAnnotation, overrideParameters, index
);
composingConstraintsSet.add( descriptor );
- log.debug( "Adding composing constraint: " + descriptor );
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Adding composing constraint: " + descriptor );
+ }
index++;
}
}
@@ -401,8 +406,6 @@
}
private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(U declaredAnnotation, Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, int index) {
- //TODO don't quite understand this warning
- //TODO assuming U.getClass() returns Class<U>
@SuppressWarnings("unchecked")
final Class<U> annotationType = ( Class<U> ) declaredAnnotation.annotationType();
return createComposingConstraintDescriptor(
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintHelper.java 2010-06-23 14:55:58 UTC (rev 19799)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintHelper.java 2010-06-23 16:18:16 UTC (rev 19800)
@@ -198,7 +198,8 @@
if ( returnType.isArray() && returnType.getComponentType().isAnnotation() ) {
Annotation[] annotations = ( Annotation[] ) method.invoke( annotation );
for ( Annotation a : annotations ) {
- if ( isConstraintAnnotation( a ) || isBuiltinConstraint( a.annotationType() ) ) {
+ Class<? extends Annotation> annotationType = a.annotationType();
+ if ( isConstraintAnnotation( annotationType ) || isBuiltinConstraint( annotationType ) ) {
isMultiValueConstraint = true;
}
else {
@@ -236,7 +237,8 @@
if ( returnType.isArray() && returnType.getComponentType().isAnnotation() ) {
Annotation[] annotations = ( Annotation[] ) method.invoke( annotation );
for ( Annotation a : annotations ) {
- if ( isConstraintAnnotation( a ) || isBuiltinConstraint( a.annotationType() ) ) {
+ Class<? extends Annotation> annotationType = a.annotationType();
+ if ( isConstraintAnnotation( annotationType ) || isBuiltinConstraint( annotationType ) ) {
annotationList.add( a );
}
}
@@ -262,29 +264,26 @@
* <li>Defines a payload parameter.</li>
* </ul>
*
- * @param annotation The annotation to test.
+ * @param annotationType The annotation type to test.
*
* @return <code>true</code> if the annotation fulfills the above condtions, <code>false</code> otherwise.
*/
- public boolean isConstraintAnnotation(Annotation annotation) {
-
- Constraint constraint = annotation.annotationType()
- .getAnnotation( Constraint.class );
+ public boolean isConstraintAnnotation(Class<? extends Annotation> annotationType) {
+ Constraint constraint = annotationType.getAnnotation( Constraint.class );
if ( constraint == null ) {
return false;
}
- assertMessageParameterExists( annotation );
- assertGroupsParameterExists( annotation );
- assertPayloadParameterExists( annotation );
+ assertMessageParameterExists( annotationType );
+ assertGroupsParameterExists( annotationType );
+ assertPayloadParameterExists( annotationType );
+ assertNoParameterStartsWithValid( annotationType );
- assertNoParameterStartsWithValid( annotation );
-
return true;
}
- private void assertNoParameterStartsWithValid(Annotation annotation) {
- final Method[] methods = ReflectionHelper.getMethods( annotation.annotationType() );
+ private void assertNoParameterStartsWithValid(Class<? extends Annotation> annotationType) {
+ final Method[] methods = ReflectionHelper.getMethods( annotationType );
for ( Method m : methods ) {
if ( m.getName().startsWith( "valid" ) ) {
String msg = "Parameters starting with 'valid' are not allowed in a constraint.";
@@ -293,64 +292,75 @@
}
}
- private void assertPayloadParameterExists(Annotation annotation) {
+ private void assertPayloadParameterExists(Class<? extends Annotation> annotationType) {
try {
- final Method method = ReflectionHelper.getMethod( annotation.annotationType(), "payload" );
+ final Method method = ReflectionHelper.getMethod( annotationType, "payload" );
if ( method == null ) {
- String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
+ String msg = annotationType.getName() + " contains Constraint annotation, but does " +
"not contain a payload parameter.";
throw new ConstraintDefinitionException( msg );
}
Class<?>[] defaultPayload = ( Class<?>[] ) method.getDefaultValue();
if ( defaultPayload.length != 0 ) {
- String msg = annotation.annotationType()
+ String msg = annotationType
.getName() + " contains Constraint annotation, but the payload " +
- "paramter default value is not the empty array.";
+ "parameter default value is not the empty array.";
throw new ConstraintDefinitionException( msg );
}
}
catch ( ClassCastException e ) {
- String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the " +
+ String msg = annotationType.getName() + " contains Constraint annotation, but the " +
"payload parameter is of wrong type.";
throw new ConstraintDefinitionException( msg );
}
}
- private void assertGroupsParameterExists(Annotation annotation) {
+ private void assertGroupsParameterExists(Class<? extends Annotation> annotationType) {
try {
- final Method method = ReflectionHelper.getMethod( annotation.annotationType(), "groups" );
+ final Method method = ReflectionHelper.getMethod( annotationType, "groups" );
if ( method == null ) {
- String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
+ String msg = annotationType.getName() + " contains Constraint annotation, but does " +
"not contain a groups parameter.";
throw new ConstraintDefinitionException( msg );
}
Class<?>[] defaultGroups = ( Class<?>[] ) method.getDefaultValue();
if ( defaultGroups.length != 0 ) {
- String msg = annotation.annotationType()
+ String msg = annotationType
.getName() + " contains Constraint annotation, but the groups " +
- "paramter default value is not the empty array.";
+ "parameter default value is not the empty array.";
throw new ConstraintDefinitionException( msg );
}
}
catch ( ClassCastException e ) {
- String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the " +
+ String msg = annotationType.getName() + " contains Constraint annotation, but the " +
"groups parameter is of wrong type.";
throw new ConstraintDefinitionException( msg );
}
}
- private void assertMessageParameterExists(Annotation annotation) {
+ private void assertMessageParameterExists(Class<? extends Annotation> annotationType) {
try {
- ReflectionHelper.getAnnotationParameter( annotation, "message", String.class );
+ final Method method = ReflectionHelper.getMethod( annotationType, "message" );
+ if ( method == null ) {
+ String msg = annotationType.getName() + " contains Constraint annotation, but does " +
+ "not contain a message parameter.";
+ throw new ConstraintDefinitionException( msg );
+ }
+ if ( method.getReturnType() != String.class ) {
+ String msg = annotationType.getName() + " contains Constraint annotation, but the message parameter " +
+ "is not of type java.lang.String.";
+ throw new ConstraintDefinitionException( msg );
+ }
}
- catch ( Exception e ) {
- String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
- "not contain a message parameter.";
+ catch ( ClassCastException e ) {
+ String msg = annotationType.getName() + " contains Constraint annotation, but the " +
+ "groups parameter is of wrong type.";
throw new ConstraintDefinitionException( msg );
}
}
- public <T extends Annotation> List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorDefinition(Class<T> annotationClass) {
+ public <T extends Annotation> List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorDefinition
+ (Class<T> annotationClass) {
if ( annotationClass == null ) {
throw new IllegalArgumentException( "Class cannot be null" );
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/annotationfactory/AnnotationProxy.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/annotationfactory/AnnotationProxy.java 2010-06-23 14:55:58 UTC (rev 19799)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/annotationfactory/AnnotationProxy.java 2010-06-23 16:18:16 UTC (rev 19800)
@@ -100,7 +100,7 @@
public String toString() {
StringBuilder result = new StringBuilder();
- result.append( '@' ).append( annotationType().getName() ).append( '(' );
+ result.append( '@' ).append( annotationType.getName() ).append( '(' );
for ( String s : getRegisteredMethodsInAlphabeticalOrder() ) {
result.append( s ).append( '=' ).append( values.get( s ) ).append( ", " );
}
13 years, 10 months