diff --git a/build.gradle b/build.gradle
index bb1da8756b..798ca9f20b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,9 +4,8 @@ apply from: "./libraries.gradle"
allprojects {
repositories {
- mavenCentral()
- mavenLocal()
-
+ mavenCentral()
+ mavenLocal()
mavenRepo name: 'jboss-nexus', url: "http://repository.jboss.org/nexus/content/groups/public/"
mavenRepo name: "jboss-snapshots", url: "http://snapshots.jboss.org/maven2/"
}
@@ -14,8 +13,8 @@ allprojects {
buildscript {
repositories {
- mavenCentral()
- mavenLocal()
+ mavenCentral()
+ mavenLocal()
mavenRepo name: 'jboss-nexus', url: "http://repository.jboss.org/nexus/content/groups/public/"
mavenRepo name: "jboss-snapshots", url: "http://snapshots.jboss.org/maven2/"
@@ -26,10 +25,15 @@ buildscript {
}
ext.hibernateTargetVersion = '5.0.0-SNAPSHOT'
+ext.javaLanguageLevel = "1.6"
+
+task wrapper(type: Wrapper) {
+ gradleVersion = '1.5'
+}
idea {
project {
- languageLevel = '1.6'
+ languageLevel = javaLanguageLevel
ipr {
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
@@ -65,8 +69,14 @@ subprojects { subProject ->
apply plugin: 'maven' // for install task as well as deploy dependencies
apply plugin: 'uploadAuth'
apply plugin: 'osgi'
+
apply from: "../utilities.gradle"
+ apply plugin: 'findbugs'
+ apply plugin: 'checkstyle'
+ apply plugin: 'build-dashboard'
+ apply plugin: 'project-report'
+
configurations {
provided {
// todo : need to make sure these are non-exported
@@ -93,6 +103,7 @@ subprojects { subProject ->
// appropriately inject the common dependencies into each sub-project
dependencies {
compile( libraries.logging )
+
testCompile( libraries.junit )
testCompile( libraries.byteman )
testCompile( libraries.byteman_install )
@@ -104,8 +115,11 @@ subprojects { subProject ->
testRuntime( libraries.jcl )
testRuntime( libraries.javassist )
testRuntime( libraries.h2 )
+
jbossLoggingTool( libraries.logging_processor )
+
hibernateJpaModelGenTool( libraries.jpa_modelgen )
+
jaxb( libraries.jaxb ){
exclude group: "javax.xml.stream"
}
@@ -117,12 +131,17 @@ subprojects { subProject ->
deployerJars "org.apache.maven.wagon:wagon-http:1.0"
}
+ // mac-specific stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ext.toolsJar = file("${System.getProperty('java.home')}/../lib/tools.jar")
if ( ext.toolsJar.exists() ) {
dependencies{
testCompile files( toolsJar )
}
}
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ targetCompatibility = rootProject.javaLanguageLevel
+ sourceCompatibility = rootProject.javaLanguageLevel
task compile
compile.dependsOn compileJava, compileTestJava
@@ -150,8 +169,8 @@ subprojects { subProject ->
"-processor", "org.jboss.logging.processor.apt.LoggingToolsProcessor",
"-s", "$sourceSets.main.generatedLoggingSrcDir.absolutePath",
"-AloggingVersion=3.0",
- "-source", "1.6",
- "-target", "1.6",
+ "-source", rootProject.javaLanguageLevel,
+ "-target", rootProject.javaLanguageLevel,
"-AtranslationFilesPath=${project.rootDir}/src/main/resources"
]
);
@@ -177,33 +196,33 @@ subprojects { subProject ->
jar {
Set exportPackages = new HashSet()
Set privatePackages = new HashSet()
-
+
// TODO: Could more of this be pulled into utilities.gradle?
- sourceSets.each { SourceSet sourceSet ->
- // skip certain source sets
- if ( ! ['test','matrix'].contains( sourceSet.name ) ) {
- sourceSet.java.each { javaFile ->
- // - org.hibernate.boot.registry.classloading.internal
- // until EntityManagerFactoryBuilderImpl no longer imports ClassLoaderServiceImpl
- // - .util for external module use (especially envers)
- final String[] temporaryExports = [
- 'org.hibernate.boot.registry.classloading.internal',
- 'org.hibernate.internal.util' ]
-
- final String packageName = determinePackageName( sourceSet.java, javaFile );
- if ( ! temporaryExports.contains( packageName )
- && ( packageName.endsWith( ".internal" )
- || packageName.contains( ".internal." )
- || packageName.endsWith( ".test" )
- || packageName.contains( ".test." ) ) ) {
- privatePackages.add( packageName );
- }
- else {
- exportPackages.add( packageName );
- }
- }
+ sourceSets.each { sourceSet ->
+ // skip certain source sets
+ if ( ! ['test','matrix'].contains( sourceSet.name ) ) {
+ sourceSet.java.each { javaFile ->
+ // - org.hibernate.boot.registry.classloading.internal
+ // until EntityManagerFactoryBuilderImpl no longer imports ClassLoaderServiceImpl
+ // - .util for external module use (especially envers)
+ final String[] temporaryExports = [
+ 'org.hibernate.boot.registry.classloading.internal',
+ 'org.hibernate.internal.util' ]
+
+ final String packageName = determinePackageName( sourceSet.java, javaFile );
+ if ( ! temporaryExports.contains( packageName )
+ && ( packageName.endsWith( ".internal" )
+ || packageName.contains( ".internal." )
+ || packageName.endsWith( ".test" )
+ || packageName.contains( ".test." ) ) ) {
+ privatePackages.add( packageName );
+ }
+ else {
+ exportPackages.add( packageName );
}
}
+ }
+ }
manifest = osgiManifest {
// GRADLE-1411: Even if we override Imports and Exports
@@ -211,11 +230,17 @@ subprojects { subProject ->
// need to be here (temporarily).
classesDir = sourceSets.main.output.classesDir
classpath = configurations.runtime
+
+ instruction 'Import-Package',
+ // Temporarily support JTA 1.1 -- Karaf and other frameworks still
+ // use it. Without this, the plugin generates [1.2,2).
+ 'javax.transaction;version="[1.1,2)"',
+ '*'
instruction 'Export-Package', exportPackages.toArray(new String[0])
instruction 'Private-Package', privatePackages.toArray(new String[0])
- instruction 'Bundle-Vendor', 'Hibernate.org'
+ instruction 'Bundle-Vendor', 'Hibernate.org'
instruction 'Implementation-Url', 'http://hibernate.org'
instruction 'Implementation-Version', version
instruction 'Implementation-Vendor', 'Hibernate.org'
@@ -234,10 +259,10 @@ subprojects { subProject ->
systemProperties['hibernate.test.validatefailureexpected'] = true
systemProperties += System.properties.findAll { it.key.startsWith( "hibernate.") }
maxHeapSize = "1024m"
+ // Not strictly needed but useful to attach a profiler:
+ jvmArgs '-XX:MaxPermSize=256m'
}
-
-
processTestResources.doLast( {
copy {
from( sourceSets.test.java.srcDirs ) {
@@ -251,9 +276,6 @@ subprojects { subProject ->
assemble.doLast( { install } )
uploadArchives.dependsOn install
- targetCompatibility = "1.6"
- sourceCompatibility = "1.6"
-
idea {
module {
iml {
@@ -287,6 +309,40 @@ subprojects { subProject ->
}
}
+ // eclipseClasspath will not add sources to classpath unless the dirs actually exist.
+ eclipseClasspath.dependsOn("generateSources")
+
+ // specialized API/SPI checkstyle tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ task checkstylePublicSources(type: Checkstyle) {
+ checkstyleClasspath = checkstyleMain.checkstyleClasspath
+ classpath = checkstyleMain.classpath
+ configFile = rootProject.file( 'shared/config/checkstyle/public_checks.xml' )
+ source subProject.sourceSets.main.originalJavaSrcDirs
+ exclude '**/internal/**'
+ exclude '**/internal/*'
+ ignoreFailures = false
+ showViolations = true
+ reports {
+ xml {
+ destination "$buildDir/reports/checkstyle/public.xml"
+ }
+ }
+ }
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ // Report configs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ checkstyle {
+ configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
+ showViolations = false
+ ignoreFailures = true
+ }
+ findbugs {
+ ignoreFailures = true
+ }
+ buildDashboard.dependsOn check
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
// elements used to customize the generated POM used during upload
def pomConfig = {
name 'A Hibernate O/RM Module'
@@ -352,13 +408,3 @@ subprojects { subProject ->
}
}
-
-// This is a task that generates the gradlew scripts, allowing users to run gradle without having gradle installed
-// on their system.
-// This task should be run by "build master" and the resulting output committed to source control. Its outputs include:
-// 1) /gradlew which is the *NIX shell script for executing builds
-// 2) /gradlew.bat which is the windows bat script for for executing builds
-// 3) /wrapper which is a directory named by the "jarPath" config which contains other needed files.
-task wrapper(type: Wrapper) {
- gradleVersion = '1.5'
-}
diff --git a/buildSrc/src/main/groovy/org/hibernate/build/qalab/DatabaseAllocator.groovy b/buildSrc/src/main/groovy/org/hibernate/build/qalab/DatabaseAllocator.groovy
index 0b86ce7b0d..8edb9dc7ff 100644
--- a/buildSrc/src/main/groovy/org/hibernate/build/qalab/DatabaseAllocator.groovy
+++ b/buildSrc/src/main/groovy/org/hibernate/build/qalab/DatabaseAllocator.groovy
@@ -51,9 +51,10 @@ class DatabaseAllocator {
public static def SUPPORTED_DB_NAMES = [
"oracle9i", "oracle10g", "oracle11gR1", "oracle11gR2", "oracle11gR2RAC", "oracle11gR1RAC",
- "postgresql82", "postgresql83", "postgresql84", "postgresql91",
+ "postgresql82", "postgresql83", "postgresql84", "postgresql91", "postgresql92",
+ "postgresplus92",
"mysql50", "mysql51","mysql55",
- "db2-91", "db2-97",
+ "db2-91", "db2-97", "db2-10",
"mssql2005", "mssql2008R1", "mssql2008R2", "mssql2012",
"sybase155", "sybase157"
];
diff --git a/changelog.txt b/changelog.txt
index f329728f7b..1f6a846cb6 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -4890,7 +4890,7 @@ Changes in version 0.9.5 (8.2.2002)
* fixed potential bug related to cacheing of compiled queries
* major rewrite of code relating to O-R mappings
* Session.copy() and Session.equals() as convenience for users
-* fixed repeated invocations of hasNext() on iterator + iterators now always work with distinct SQL resultsets
+* fixed repeated invocations of hasNext() on iterator + wrappedIterators now always work with distinct SQL resultsets
* McKoi dialect was contributed by Gabe Hicks
Changes in version 0.9.4 (29.1.2002)
diff --git a/documentation/src/main/docbook/devguide/en-US/Envers.xml b/documentation/src/main/docbook/devguide/en-US/Envers.xml
index d2e1fd7d0a..acdba3762c 100644
--- a/documentation/src/main/docbook/devguide/en-US/Envers.xml
+++ b/documentation/src/main/docbook/devguide/en-US/Envers.xml
@@ -1,4 +1,4 @@
-
+
@@ -40,7 +40,7 @@
which stores the historical data, whenever you commit a transaction. Envers automatically creates audit
tables if hibernate.hbm2ddl.auto option is set to create,
create-drop or update. Otherwise, to export complete database schema
- programatically, use org.hibernate.tool.EnversSchemaGenerator. Appropriate DDL
+ programatically, use org.hibernate.envers.tools.hbm2ddl.EnversSchemaGenerator. Appropriate DDL
statements can be also generated with Ant task described later in this manual.
@@ -58,7 +58,7 @@
-
+ Configuration
It is possible to configure various aspects of Hibernate Envers behavior, such as table names, etc.
@@ -300,7 +300,7 @@
When set to false, such column can be added to selected entities or properties using the
@Audited annotation.
For more information refer to
- and .
+ and .
@@ -315,6 +315,17 @@
For example: a property called "age", will by default get modified flag with column name "age_MOD".
+
+
+ org.hibernate.envers.embeddable_set_ordinal_field_name
+
+
+ SETORDINAL
+
+
+ Name of column used for storing ordinal of the change in sets of embeddable elements.
+
+
@@ -480,7 +491,7 @@
class is inaccessible from @RevisionEntity (e.g. exists in a different
module), set org.hibernate.envers.revision_listener property to it's fully
qualified name. Class name defined by the configuration parameter overrides revision entity's
- value attribute.
+ value attribute.
@@ -621,7 +632,7 @@ public class AnnotatedTrackingRevisionEntity {
EntityTrackingRevisionListener interface exposes one method that notifies
whenever audited entity instance has been added, modified or removed within current revision boundaries.
-
+
Custom implementation of tracking entity classes modified during revisions
@@ -735,7 +746,7 @@ Set modifiedEntityTypes = revEntity.getModifiedEntityT
To see how "Modified Flags" can be utilized, check out the very
- simple query API that uses them: .
+ simple query API that uses them: .
@@ -771,7 +782,7 @@ Set modifiedEntityTypes = revEntity.getModifiedEntityT
In the future, queries will be improved both in terms of speed and possibilities, when using the valid-time
audit strategy, that is when storing both start and end revisions for entities. See
- .
+ .
@@ -929,7 +940,7 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>
-
+ Querying for revisions of entity that modified given property
@@ -948,11 +959,10 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>
-
+
@@ -967,11 +977,10 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>
-
+
@@ -991,11 +1000,10 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>forEntitiesModifiedAtRevision query:
-
+
@@ -1049,7 +1057,7 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>Conditional auditing
Envers persists audit data in reaction to various Hibernate events (e.g. post update, post insert, and
- so on), using a series of even listeners from the org.hibernate.envers.event
+ so on), using a series of even listeners from the org.hibernate.envers.event.spi
package. By default, if the Envers jar is in the classpath, the event listeners are auto-registered with
Hibernate.
@@ -1062,13 +1070,13 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>hibernate.listeners.envers.autoRegister Hibernate property to
false.
-
+
Create subclasses for appropriate event listeners. For example, if you want to
conditionally audit entity insertions, extend the
- org.hibernate.envers.eventEnversPostInsertEventListenerImpl
+ org.hibernate.envers.event.spi.EnversPostInsertEventListenerImpl
class. Place the conditional-auditing logic in the subclasses, call the super method if
auditing should be performed.
@@ -1076,7 +1084,7 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>
Create your own implementation of org.hibernate.integrator.spi.Integrator,
- similar to org.hibernate.envers.event.EnversIntegrator. Use your event
+ similar to org.hibernate.envers.event.spi.EnversIntegrator. Use your event
listener classes instead of the default ones.
@@ -1398,7 +1406,7 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>
- Optionally, you can also override the default values following properties:
+ Optionally, you can also override the default values using following properties:
org.hibernate.envers.audit_strategy_validity_end_rev_field_name
@@ -1408,7 +1416,7 @@ query.add(AuditEntity.relatedId("address").eq(relatedEntityId));]]>
- For more information, see .
+ For more information, see .
diff --git a/documentation/src/main/docbook/manual/en-US/content/collection_mapping.xml b/documentation/src/main/docbook/manual/en-US/content/collection_mapping.xml
index 3fe09b797d..26b6c0f166 100644
--- a/documentation/src/main/docbook/manual/en-US/content/collection_mapping.xml
+++ b/documentation/src/main/docbook/manual/en-US/content/collection_mapping.xml
@@ -584,13 +584,16 @@ public class Order {
- We recommend you to convert the legacy
- @org.hibernate.annotations.IndexColumn usages to
- @OrderColumn unless you are making use of the
- base property. The base property lets you define
- the index value of the first element (aka as base index). The usual
- value is 0 or 1. The default
- is 0 like in Java.
+
+ We recommend you to convert the legacy @org.hibernate.annotations.IndexColumn
+ usages to the JPA standard @javax.persistence.OrderColumn.
+
+
+ If you are leveraging a custom list index base (maybe currently using the
+ org.hibernate.annotations.IndexColumn.literal attribute), you can
+ specify this using the @org.hibernate.annotations.ListIndexBase in conjunction
+ with @javax.persistence.OrderColumn. The default base is 0 like in Java.
+ Looking again at the Hibernate mapping file equivalent, the
diff --git a/hibernate-c3p0/hibernate-c3p0.gradle b/hibernate-c3p0/hibernate-c3p0.gradle
index 3d19fe5db2..20e36fcf19 100644
--- a/hibernate-c3p0/hibernate-c3p0.gradle
+++ b/hibernate-c3p0/hibernate-c3p0.gradle
@@ -13,6 +13,5 @@ dependencies {
jar {
manifest {
instruction 'Bundle-Description', 'Hibernate ORM C3P0'
- instruction 'Bundle-SymbolicName', 'org.hibernate.c3p0'
}
}
\ No newline at end of file
diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle
index 41e66d4b42..4022394b93 100644
--- a/hibernate-core/hibernate-core.gradle
+++ b/hibernate-core/hibernate-core.gradle
@@ -40,7 +40,6 @@ manifest.mainAttributes(
jar {
manifest {
instruction 'Bundle-Description', 'Hibernate ORM Core'
- instruction 'Bundle-SymbolicName', 'org.hibernate.core'
instruction 'Import-Package',
'javax.security.auth;resolution:=optional',
@@ -49,6 +48,13 @@ jar {
'javax.validation.constraints;resolution:=optional',
'javax.validation.groups;resolution:=optional',
'javax.validation.metadata;resolution:=optional',
+ // TODO: Shouldn't have to explicitly list this, but the plugin
+ // generates it with a [1.0,2) version.
+ 'javax.persistence;version="2.1.0"',
+ // Temporarily support JTA 1.1 -- Karaf and other frameworks still
+ // use it. Without this, the plugin generates [1.2,2).
+ // build.gradle adds javax.transaction for all modules
+ 'javax.transaction.xa;version="[1.1,2)"',
'*'
// TODO: Uncomment once EntityManagerFactoryBuilderImpl no longer
diff --git a/hibernate-core/src/main/java/org/hibernate/AnnotationException.java b/hibernate-core/src/main/java/org/hibernate/AnnotationException.java
index d371dc58ca..c5d2dc7176 100644
--- a/hibernate-core/src/main/java/org/hibernate/AnnotationException.java
+++ b/hibernate-core/src/main/java/org/hibernate/AnnotationException.java
@@ -23,25 +23,30 @@
*/
package org.hibernate;
-
/**
* Annotation related exception.
- * The EJB3 EG will probably set a generic exception.
- * I'll then use this one.
+ *
+ * The EJB3 EG will probably set a generic exception. I'll then use this one.
*
* @author Emmanuel Bernard
*/
public class AnnotationException extends MappingException {
-
- public AnnotationException(String msg, Throwable root) {
- super( msg, root );
+ /**
+ * Constructs an AnnotationException using the given message and cause.
+ *
+ * @param msg The message explaining the reason for the exception.
+ * @param cause The underlying cause.
+ */
+ public AnnotationException(String msg, Throwable cause) {
+ super( msg, cause );
}
- public AnnotationException(Throwable root) {
- super( root );
- }
-
- public AnnotationException(String s) {
- super( s );
+ /**
+ * Constructs an AnnotationException using the given message.
+ *
+ * @param msg The message explaining the reason for the exception.
+ */
+ public AnnotationException(String msg) {
+ super( msg );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/AssertionFailure.java b/hibernate-core/src/main/java/org/hibernate/AssertionFailure.java
index cf0ee1a7e7..cc36bccf64 100644
--- a/hibernate-core/src/main/java/org/hibernate/AssertionFailure.java
+++ b/hibernate-core/src/main/java/org/hibernate/AssertionFailure.java
@@ -33,19 +33,28 @@ import org.hibernate.internal.CoreMessageLogger;
* @author Gavin King
*/
public class AssertionFailure extends RuntimeException {
-
private static final long serialVersionUID = 1L;
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, AssertionFailure.class.getName());
- public AssertionFailure( String s ) {
- super(s);
- LOG.failed(this);
+ /**
+ * Creates an instance of AssertionFailure using the given message.
+ *
+ * @param message The message explaining the reason for the exception
+ */
+ public AssertionFailure(String message) {
+ super( message );
+ LOG.failed( this );
}
- public AssertionFailure( String s,
- Throwable t ) {
- super(s, t);
- LOG.failed(t);
+ /**
+ * Creates an instance of AssertionFailure using the given message and underlying cause.
+ *
+ * @param message The message explaining the reason for the exception
+ * @param cause The underlying cause.
+ */
+ public AssertionFailure(String message, Throwable cause) {
+ super( message, cause );
+ LOG.failed( cause );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/BasicQueryContract.java b/hibernate-core/src/main/java/org/hibernate/BasicQueryContract.java
index 524299c4ac..97e4b7446a 100644
--- a/hibernate-core/src/main/java/org/hibernate/BasicQueryContract.java
+++ b/hibernate-core/src/main/java/org/hibernate/BasicQueryContract.java
@@ -47,6 +47,8 @@ public interface BasicQueryContract {
*
* @param flushMode The new FlushMode to use.
*
+ * @return {@code this}, for method chaining
+ *
* @see #getFlushMode()
*/
public BasicQueryContract setFlushMode(FlushMode flushMode);
@@ -70,6 +72,8 @@ public interface BasicQueryContract {
*
* @param cacheMode The new CacheMode to use.
*
+ * @return {@code this}, for method chaining
+ *
* @see #getCacheMode()
*/
public BasicQueryContract setCacheMode(CacheMode cacheMode);
@@ -93,6 +97,8 @@ public interface BasicQueryContract {
*
* @param cacheable Should the query results be cacheable?
*
+ * @return {@code this}, for method chaining
+ *
* @see #isCacheable
*/
public BasicQueryContract setCacheable(boolean cacheable);
@@ -113,6 +119,8 @@ public interface BasicQueryContract {
* @param cacheRegion the name of a query cache region, or {@code null} to indicate that the default region
* should be used.
*
+ * @return {@code this}, for method chaining
+ *
* @see #getCacheRegion()
*/
public BasicQueryContract setCacheRegion(String cacheRegion);
@@ -136,6 +144,8 @@ public interface BasicQueryContract {
*
* @param timeout the timeout in seconds
*
+ * @return {@code this}, for method chaining
+ *
* @see #getTimeout()
*/
public BasicQueryContract setTimeout(int timeout);
@@ -160,6 +170,8 @@ public interface BasicQueryContract {
*
* @param fetchSize the fetch size hint
*
+ * @return {@code this}, for method chaining
+ *
* @see #getFetchSize()
*/
public BasicQueryContract setFetchSize(int fetchSize);
@@ -201,6 +213,8 @@ public interface BasicQueryContract {
* The read-only/modifiable setting has no impact on entities/proxies
* returned by the query that existed in the session before the query was executed.
*
+ * @return {@code this}, for method chaining
+ *
* @param readOnly true, entities and proxies loaded by the query will be put in read-only mode
* false, entities and proxies loaded by the query will be put in modifiable mode
*/
@@ -211,5 +225,5 @@ public interface BasicQueryContract {
*
* @return an array of types
*/
- public Type[] getReturnTypes() throws HibernateException;
+ public Type[] getReturnTypes();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/CacheMode.java b/hibernate-core/src/main/java/org/hibernate/CacheMode.java
index 7bc9d9ffe1..54ebf079a9 100755
--- a/hibernate-core/src/main/java/org/hibernate/CacheMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/CacheMode.java
@@ -24,27 +24,25 @@
package org.hibernate;
/**
- * Controls how the session interacts with the second-level
- * cache and query cache.
+ * Controls how the session interacts with the second-level cache and query cache.
*
* @author Gavin King
* @author Strong Liu
* @see Session#setCacheMode(CacheMode)
*/
public enum CacheMode {
-
/**
- * The session may read items from the cache, and add items to the cache
+ * The session may read items from the cache, and add items to the cache.
*/
NORMAL( true, true ),
/**
* The session will never interact with the cache, except to invalidate
- * cache items when updates occur
+ * cache items when updates occur.
*/
IGNORE( false, false ),
/**
* The session may read items from the cache, but will not add items,
- * except to invalidate items when updates occur
+ * except to invalidate items when updates occur.
*/
GET( false, true ),
/**
@@ -54,9 +52,9 @@ public enum CacheMode {
PUT( true, false ),
/**
* The session will never read items from the cache, but will add items
- * to the cache as it reads them from the database. In this mode, the
+ * to the cache as it reads them from the database. In this mode, the
* effect of hibernate.cache.use_minimal_puts is bypassed, in
- * order to force a cache refresh
+ * order to force a cache refresh.
*/
REFRESH( true, false );
@@ -64,19 +62,38 @@ public enum CacheMode {
private final boolean isPutEnabled;
private final boolean isGetEnabled;
- CacheMode( boolean isPutEnabled, boolean isGetEnabled) {
+ private CacheMode( boolean isPutEnabled, boolean isGetEnabled) {
this.isPutEnabled = isPutEnabled;
this.isGetEnabled = isGetEnabled;
}
+ /**
+ * Does this cache mode indicate that reads are allowed?
+ *
+ * @return {@code true} if cache reads are allowed; {@code false} otherwise.
+ */
public boolean isGetEnabled() {
return isGetEnabled;
}
+ /**
+ * Does this cache mode indicate that writes are allowed?
+ *
+ * @return {@code true} if cache writes are allowed; {@code false} otherwise.
+ */
public boolean isPutEnabled() {
return isPutEnabled;
}
+ /**
+ * Used to interpret externalized forms of this enum.
+ *
+ * @param setting The externalized form.
+ *
+ * @return The matching enum value.
+ *
+ * @throws MappingException Indicates the external form was not recognized as a valid enum value.
+ */
public static CacheMode interpretExternalSetting(String setting) {
if (setting == null) {
return null;
diff --git a/hibernate-core/src/main/java/org/hibernate/CallbackException.java b/hibernate-core/src/main/java/org/hibernate/CallbackException.java
index c28a401f56..325afd0782 100644
--- a/hibernate-core/src/main/java/org/hibernate/CallbackException.java
+++ b/hibernate-core/src/main/java/org/hibernate/CallbackException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,38 +20,44 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
- * Should be thrown by persistent objects from Lifecycle
- * or Interceptor callbacks.
+ * Intended to be thrown from {@link org.hibernate.classic.Lifecycle} and {@link Interceptor} callbacks.
+ *
+ * IMPL NOTE : This is a legacy exception type from back in the day before Hibernate moved to a untyped (runtime)
+ * exception strategy.
*
- * @see org.hibernate.classic.Lifecycle
- * @see Interceptor
* @author Gavin King
*/
-
public class CallbackException extends HibernateException {
-
- public CallbackException(Exception root) {
- super("An exception occurred in a callback", root);
+ /**
+ * Creates a CallbackException using the given underlying cause.
+ *
+ * @param cause The underlying cause
+ */
+ public CallbackException(Exception cause) {
+ this( "An exception occurred in a callback", cause );
}
+ /**
+ * Creates a CallbackException using the given message.
+ *
+ * @param message The message explaining the reason for the exception
+ */
public CallbackException(String message) {
- super(message);
+ super( message );
}
- public CallbackException(String message, Exception e) {
- super(message, e);
+ /**
+ * Creates a CallbackException using the given message and underlying cause.
+ *
+ * @param message The message explaining the reason for the exception
+ * @param cause The underlying cause
+ */
+ public CallbackException(String message, Exception cause) {
+ super( message, cause );
}
}
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java b/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java
index 972621a6f7..700e0b1bd5 100644
--- a/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
@@ -31,7 +30,6 @@ package org.hibernate;
* @author Steve Ebersole
*/
public enum ConnectionReleaseMode{
-
/**
* Indicates that JDBC connection should be aggressively released after each
* SQL statement is executed. In this mode, the application must
@@ -55,7 +53,14 @@ public enum ConnectionReleaseMode{
*/
ON_CLOSE;
- public static ConnectionReleaseMode parse(String name){
+ /**
+ * Alias for {@link ConnectionReleaseMode#valueOf(String)} using upper-case version of the incoming name.
+ *
+ * @param name The name to parse
+ *
+ * @return The matched enum value.
+ */
+ public static ConnectionReleaseMode parse(final String name){
return ConnectionReleaseMode.valueOf( name.toUpperCase() );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/Criteria.java b/hibernate-core/src/main/java/org/hibernate/Criteria.java
index 1a10390cc2..17152825dc 100644
--- a/hibernate-core/src/main/java/org/hibernate/Criteria.java
+++ b/hibernate-core/src/main/java/org/hibernate/Criteria.java
@@ -143,7 +143,7 @@ public interface Criteria extends CriteriaSpecification {
public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;
/**
- * Set the lock mode of the current entity
+ * Set the lock mode of the current entity.
*
* @param lockMode The lock mode to be applied
*
@@ -152,7 +152,7 @@ public interface Criteria extends CriteriaSpecification {
public Criteria setLockMode(LockMode lockMode);
/**
- * Set the lock mode of the aliased entity
+ * Set the lock mode of the aliased entity.
*
* @param alias The previously assigned alias representing the entity to
* which the given lock mode should apply.
@@ -533,7 +533,7 @@ public interface Criteria extends CriteriaSpecification {
public List list() throws HibernateException;
/**
- * Get the results as an instance of {@link ScrollableResults}
+ * Get the results as an instance of {@link ScrollableResults}.
*
* @return The {@link ScrollableResults} representing the matched
* query results.
diff --git a/hibernate-core/src/main/java/org/hibernate/CustomEntityDirtinessStrategy.java b/hibernate-core/src/main/java/org/hibernate/CustomEntityDirtinessStrategy.java
index dbec870c1b..7a52a0a9d9 100644
--- a/hibernate-core/src/main/java/org/hibernate/CustomEntityDirtinessStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/CustomEntityDirtinessStrategy.java
@@ -94,7 +94,7 @@ public interface CustomEntityDirtinessStrategy {
public static interface DirtyCheckContext {
/**
* The callback to indicate that dirty checking (the dirty attribute determination phase) should be handled
- * by the calling {@link CustomEntityDirtinessStrategy} using the given {@link AttributeChecker}
+ * by the calling {@link CustomEntityDirtinessStrategy} using the given {@link AttributeChecker}.
*
* @param attributeChecker The delegate usable by the context for determining which attributes are dirty.
*/
@@ -139,7 +139,7 @@ public interface CustomEntityDirtinessStrategy {
public int getAttributeIndex();
/**
- * Get the name of this attribute
+ * Get the name of this attribute.
*
* @return The attribute name
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/DuplicateMappingException.java b/hibernate-core/src/main/java/org/hibernate/DuplicateMappingException.java
index f9c865d098..e837a4995b 100644
--- a/hibernate-core/src/main/java/org/hibernate/DuplicateMappingException.java
+++ b/hibernate-core/src/main/java/org/hibernate/DuplicateMappingException.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2008, 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -24,36 +24,80 @@
package org.hibernate;
/**
- * Raised whenever a duplicate for a certain type occurs.
- * Duplicate class, table, property name etc.
+ * Raised whenever a duplicate for a certain type occurs. Duplicate class, table, property name etc.
*
* @author Max Rydahl Andersen
* @author Steve Ebersole
*/
public class DuplicateMappingException extends MappingException {
+ /**
+ * Enumeration of the types of things that can be duplicated.
+ */
public static enum Type {
+ /**
+ * A duplicate entity definition was encountered.
+ */
ENTITY,
+ /**
+ * A duplicate table definition was encountered.
+ */
TABLE,
+ /**
+ * A duplicate property/attribute definition was encountered.
+ */
PROPERTY,
+ /**
+ * A duplicate column definition was encountered.
+ */
COLUMN
}
private final String name;
private final String type;
+ /**
+ * Creates a DuplicateMappingException using the given type and name.
+ *
+ * @param type The type of the duplicated thing.
+ * @param name The name of the duplicated thing.
+ */
public DuplicateMappingException(Type type, String name) {
this( type.name(), name );
}
+ /**
+ * Creates a DuplicateMappingException using the given type and name.
+ *
+ * @param type The type of the duplicated thing.
+ * @param name The name of the duplicated thing.
+ *
+ * @deprecated Use the for taking {@link Type} instead.
+ */
@Deprecated
public DuplicateMappingException(String type, String name) {
this( "Duplicate " + type + " mapping " + name, type, name );
}
+ /**
+ * Creates a DuplicateMappingException using the given customMessage, type and name.
+ *
+ * @param customMessage A custom exception message explaining the exception condition
+ * @param type The type of the duplicated thing.
+ * @param name The name of the duplicated thing.
+ */
public DuplicateMappingException(String customMessage, Type type, String name) {
this( customMessage, type.name(), name );
}
+ /**
+ * Creates a DuplicateMappingException using the given customMessage, type and name.
+ *
+ * @param customMessage A custom exception message explaining the exception condition
+ * @param type The type of the duplicated thing.
+ * @param name The name of the duplicated thing.
+ *
+ * @deprecated Use the for taking {@link Type} instead.
+ */
@Deprecated
public DuplicateMappingException(String customMessage, String type, String name) {
super( customMessage );
diff --git a/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java b/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java
index b3e0dc56f3..cc583c35cd 100755
--- a/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java
+++ b/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,26 +20,29 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
import java.util.Iterator;
import org.hibernate.type.Type;
/**
- * An interceptor that does nothing. May be used as a base class
- * for application-defined custom interceptors.
+ * An interceptor that does nothing. May be used as a base class for application-defined custom interceptors.
*
* @author Gavin King
*/
public class EmptyInterceptor implements Interceptor, Serializable {
-
+ /**
+ * The singleton reference.
+ */
public static final Interceptor INSTANCE = new EmptyInterceptor();
-
- protected EmptyInterceptor() {}
+ protected EmptyInterceptor() {
+ }
+
+ @Override
public void onDelete(
Object entity,
Serializable id,
@@ -47,6 +50,7 @@ public class EmptyInterceptor implements Interceptor, Serializable {
String[] propertyNames,
Type[] types) {}
+ @Override
public boolean onFlushDirty(
Object entity,
Serializable id,
@@ -57,6 +61,7 @@ public class EmptyInterceptor implements Interceptor, Serializable {
return false;
}
+ @Override
public boolean onLoad(
Object entity,
Serializable id,
@@ -66,6 +71,7 @@ public class EmptyInterceptor implements Interceptor, Serializable {
return false;
}
+ @Override
public boolean onSave(
Object entity,
Serializable id,
@@ -75,18 +81,27 @@ public class EmptyInterceptor implements Interceptor, Serializable {
return false;
}
- public void postFlush(Iterator entities) {}
- public void preFlush(Iterator entities) {}
+ @Override
+ public void postFlush(Iterator entities) {
+ }
+ @Override
+ public void preFlush(Iterator entities) {
+ }
+
+ @Override
public Boolean isTransient(Object entity) {
return null;
}
+ @Override
public Object instantiate(String entityName, EntityMode entityMode, Serializable id) {
return null;
}
- public int[] findDirty(Object entity,
+ @Override
+ public int[] findDirty(
+ Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
@@ -95,26 +110,43 @@ public class EmptyInterceptor implements Interceptor, Serializable {
return null;
}
+ @Override
public String getEntityName(Object object) {
return null;
}
+ @Override
public Object getEntity(String entityName, Serializable id) {
return null;
}
- public void afterTransactionBegin(Transaction tx) {}
- public void afterTransactionCompletion(Transaction tx) {}
- public void beforeTransactionCompletion(Transaction tx) {}
+ @Override
+ public void afterTransactionBegin(Transaction tx) {
+ }
+ @Override
+ public void afterTransactionCompletion(Transaction tx) {
+ }
+
+ @Override
+ public void beforeTransactionCompletion(Transaction tx) {
+ }
+
+ @Override
public String onPrepareStatement(String sql) {
return sql;
}
- public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {}
+ @Override
+ public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
+ }
- public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {}
+ @Override
+ public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {
+ }
- public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {}
+ @Override
+ public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
+ }
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/EntityMode.java b/hibernate-core/src/main/java/org/hibernate/EntityMode.java
index f9e9ee9d07..d8d1e784f3 100644
--- a/hibernate-core/src/main/java/org/hibernate/EntityMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/EntityMode.java
@@ -29,12 +29,20 @@ package org.hibernate;
* @author Steve Ebersole
*/
public enum EntityMode {
+ /**
+ * The {@code pojo} entity mode describes an entity model made up of entity classes (loosely) following
+ * the java bean convention.
+ */
POJO( "pojo" ),
+
+ /**
+ * The {@code dynamic-map} entity mode describes an entity model defined using {@link java.util.Map} references.
+ */
MAP( "dynamic-map" );
private final String name;
- EntityMode(String name) {
+ private EntityMode(String name) {
this.name = name;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/FetchMode.java b/hibernate-core/src/main/java/org/hibernate/FetchMode.java
index 635ca99e83..97aac87aa5 100644
--- a/hibernate-core/src/main/java/org/hibernate/FetchMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/FetchMode.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
@@ -32,6 +31,7 @@ package org.hibernate;
* For HQL queries, use the FETCH keyword instead.
*
* @see Criteria#setFetchMode(java.lang.String, FetchMode)
+ *
* @author Gavin King
*/
public enum FetchMode {
@@ -52,18 +52,16 @@ public enum FetchMode {
/**
* Fetch lazily. Equivalent to outer-join="false".
+ *
* @deprecated use FetchMode.SELECT
*/
+ @Deprecated
public static final FetchMode LAZY = SELECT;
/**
- * Fetch eagerly, using an outer join. Equivalent to
- * outer-join="true".
+ * Fetch eagerly, using an outer join. Equivalent to outer-join="true".
+ *
* @deprecated use FetchMode.JOIN
*/
+ @Deprecated
public static final FetchMode EAGER = JOIN;
}
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/FlushMode.java b/hibernate-core/src/main/java/org/hibernate/FlushMode.java
index f3f886f1b9..8a0dbacb93 100644
--- a/hibernate-core/src/main/java/org/hibernate/FlushMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/FlushMode.java
@@ -35,13 +35,14 @@ package org.hibernate;
* @author Gavin King
*/
public enum FlushMode {
- /**
+ /**
* The {@link Session} is never flushed unless {@link Session#flush}
* is explicitly called by the application. This mode is very
* efficient for read only transactions.
*
* @deprecated use {@link #MANUAL} instead.
*/
+ @Deprecated
NEVER ( 0 ),
/**
@@ -75,25 +76,53 @@ public enum FlushMode {
private FlushMode(int level) {
this.level = level;
}
-
+
+ /**
+ * Checks to see if {@code this} flush mode is less than the given flush mode.
+ *
+ * @param other THe flush mode value to be checked against {@code this}
+ *
+ * @return {@code true} indicates {@code other} is less than {@code this}; {@code false} otherwise
+ */
public boolean lessThan(FlushMode other) {
- return this.levelnull
* @return true if the argument is already initialized, or is not a proxy or collection
*/
+ @SuppressWarnings("SimplifiableIfStatement")
public static boolean isInitialized(Object proxy) {
if ( proxy instanceof HibernateProxy ) {
- return !( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().isUninitialized();
+ return !( (HibernateProxy) proxy ).getHibernateLazyInitializer().isUninitialized();
}
else if ( proxy instanceof PersistentCollection ) {
- return ( ( PersistentCollection ) proxy ).wasInitialized();
+ return ( (PersistentCollection) proxy ).wasInitialized();
}
else {
return true;
@@ -106,7 +108,7 @@ public final class Hibernate {
*/
public static Class getClass(Object proxy) {
if ( proxy instanceof HibernateProxy ) {
- return ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer()
+ return ( (HibernateProxy) proxy ).getHibernateLazyInitializer()
.getImplementation()
.getClass();
}
@@ -115,10 +117,24 @@ public final class Hibernate {
}
}
+ /**
+ * Obtain a lob creator for the given session.
+ *
+ * @param session The session for which to obtain a lob creator
+ *
+ * @return The log creator reference
+ */
public static LobCreator getLobCreator(Session session) {
return getLobCreator( (SessionImplementor) session );
}
+ /**
+ * Obtain a lob creator for the given session.
+ *
+ * @param session The session for which to obtain a lob creator
+ *
+ * @return The log creator reference
+ */
public static LobCreator getLobCreator(SessionImplementor session) {
return session.getFactory()
.getJdbcServices()
@@ -126,17 +142,19 @@ public final class Hibernate {
}
/**
- * Close an Iterator created by iterate() immediately,
+ * Close an {@link Iterator} instances obtained from {@link org.hibernate.Query#iterate()} immediately
* instead of waiting until the session is closed or disconnected.
*
- * @param iterator an Iterator created by iterate()
- * @throws HibernateException
- * @see org.hibernate.Query#iterate
+ * @param iterator an Iterator created by iterate()
+ *
+ * @throws HibernateException Indicates a problem closing the Hibernate iterator.
+ * @throws IllegalArgumentException If the Iterator is not a "Hibernate Iterator".
+ *
* @see Query#iterate()
*/
public static void close(Iterator iterator) throws HibernateException {
if ( iterator instanceof HibernateIterator ) {
- ( ( HibernateIterator ) iterator ).close();
+ ( (HibernateIterator) iterator ).close();
}
else {
throw new IllegalArgumentException( "not a Hibernate iterator" );
@@ -152,10 +170,9 @@ public final class Hibernate {
* @return true if the named property of the object is not listed as uninitialized; false otherwise
*/
public static boolean isPropertyInitialized(Object proxy, String propertyName) {
-
- Object entity;
+ final Object entity;
if ( proxy instanceof HibernateProxy ) {
- LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
+ final LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
if ( li.isUninitialized() ) {
return false;
}
@@ -168,13 +185,12 @@ public final class Hibernate {
}
if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
- FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
+ final FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
return interceptor == null || interceptor.isInitialized( propertyName );
}
else {
return true;
}
-
}
}
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/ant/JPAConfigurationTaskWithEnvers.java b/hibernate-core/src/main/java/org/hibernate/HibernateError.java
similarity index 60%
rename from hibernate-envers/src/main/java/org/hibernate/envers/ant/JPAConfigurationTaskWithEnvers.java
rename to hibernate-core/src/main/java/org/hibernate/HibernateError.java
index 89eefb2d94..4376031c02 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/ant/JPAConfigurationTaskWithEnvers.java
+++ b/hibernate-core/src/main/java/org/hibernate/HibernateError.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -21,18 +21,23 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.envers.ant;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.envers.configuration.AuditConfiguration;
-import org.hibernate.tool.ant.JPAConfigurationTask;
+package org.hibernate;
/**
- * @author Adam Warski (adam at warski dot org)
+ * Marks a group of exceptions that generally indicate an internal Hibernate error or bug.
+ *
+ * @author Steve Ebersole
*/
-public class JPAConfigurationTaskWithEnvers extends JPAConfigurationTask {
- protected void doConfiguration(Configuration configuration) {
- AuditConfiguration.getFor(configuration);
+public abstract class HibernateError extends HibernateException {
+ public HibernateError(String message) {
+ super( message );
+ }
- super.doConfiguration(configuration);
- }
+ public HibernateError(Throwable root) {
+ super( root );
+ }
+
+ public HibernateError(String message, Throwable root) {
+ super( message, root );
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/HibernateException.java b/hibernate-core/src/main/java/org/hibernate/HibernateException.java
index 52be3448b4..542e81df31 100644
--- a/hibernate-core/src/main/java/org/hibernate/HibernateException.java
+++ b/hibernate-core/src/main/java/org/hibernate/HibernateException.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2007-2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2007,2011, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -23,9 +23,8 @@
*/
package org.hibernate;
-
/**
- * The base {@link Throwable} type for Hibernate.
+ * The base exception type for Hibernate exceptions.
*
* Note that all {@link java.sql.SQLException SQLExceptions} will be wrapped in some form of
* {@link JDBCException}.
@@ -35,16 +34,32 @@ package org.hibernate;
* @author Gavin King
*/
public class HibernateException extends RuntimeException {
+ /**
+ * Constructs a HibernateException using the given exception message.
+ *
+ * @param message The message explaining the reason for the exception
+ */
public HibernateException(String message) {
super( message );
}
- public HibernateException(Throwable root) {
- super( root );
+ /**
+ * Constructs a HibernateException using the given message and underlying cause.
+ *
+ * @param cause The underlying cause.
+ */
+ public HibernateException(Throwable cause) {
+ super( cause );
}
- public HibernateException(String message, Throwable root) {
- super( message, root );
+ /**
+ * Constructs a HibernateException using the given message and underlying cause.
+ *
+ * @param message The message explaining the reason for the exception.
+ * @param cause The underlying cause.
+ */
+ public HibernateException(String message, Throwable cause) {
+ super( message, cause );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/IdentifierLoadAccess.java b/hibernate-core/src/main/java/org/hibernate/IdentifierLoadAccess.java
index f4fae2178f..72c2e12cee 100644
--- a/hibernate-core/src/main/java/org/hibernate/IdentifierLoadAccess.java
+++ b/hibernate-core/src/main/java/org/hibernate/IdentifierLoadAccess.java
@@ -26,7 +26,7 @@ package org.hibernate;
import java.io.Serializable;
/**
- * Loads an entity by its primary identifier
+ * Loads an entity by its primary identifier.
*
* @author Eric Dalquist
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/InstantiationException.java b/hibernate-core/src/main/java/org/hibernate/InstantiationException.java
index 9a1c668964..fdfafa18eb 100644
--- a/hibernate-core/src/main/java/org/hibernate/InstantiationException.java
+++ b/hibernate-core/src/main/java/org/hibernate/InstantiationException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,49 +20,75 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
- * Thrown if Hibernate can't instantiate an entity or component
- * class at runtime.
+ * Thrown if Hibernate can't instantiate a class at runtime.
*
* @author Gavin King
*/
-
public class InstantiationException extends HibernateException {
-
private final Class clazz;
- public InstantiationException(String s, Class clazz, Throwable root) {
- super(s, root);
+ /**
+ * Constructs a InstantiationException.
+ *
+ * @param message A message explaining the exception condition
+ * @param clazz The Class we are attempting to instantiate
+ * @param cause The underlying exception
+ */
+ public InstantiationException(String message, Class clazz, Throwable cause) {
+ super( message, cause );
this.clazz = clazz;
}
- public InstantiationException(String s, Class clazz) {
- super(s);
- this.clazz = clazz;
- }
-
- public InstantiationException(String s, Class clazz, Exception e) {
- super(s, e);
+ /**
+ * Constructs a InstantiationException.
+ *
+ * @param message A message explaining the exception condition
+ * @param clazz The Class we are attempting to instantiate
+ */
+ public InstantiationException(String message, Class clazz) {
+ this( message, clazz, null );
+ }
+
+ /**
+ * Constructs a InstantiationException.
+ *
+ * @param message A message explaining the exception condition
+ * @param clazz The Class we are attempting to instantiate
+ * @param cause The underlying exception
+ */
+ public InstantiationException(String message, Class clazz, Exception cause) {
+ super( message, cause );
this.clazz = clazz;
}
+ /**
+ * Returns the Class we were attempting to instantiate.
+ *
+ * @deprecated Use {@link #getUninstantiatableClass} instead
+ *
+ * @return The class we are unable to instantiate
+ */
+ @Deprecated
public Class getPersistentClass() {
return clazz;
}
+ /**
+ * Returns the Class we were attempting to instantiate.
+ *
+ * @return The class we are unable to instantiate
+ */
+ public Class getUninstantiatableClass() {
+ return clazz;
+ }
+
+ @Override
public String getMessage() {
- return super.getMessage() + clazz.getName();
+ return super.getMessage() + " : " + clazz.getName();
}
}
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/Interceptor.java b/hibernate-core/src/main/java/org/hibernate/Interceptor.java
index 7664c36eb6..29b5108387 100644
--- a/hibernate-core/src/main/java/org/hibernate/Interceptor.java
+++ b/hibernate-core/src/main/java/org/hibernate/Interceptor.java
@@ -30,18 +30,18 @@ import org.hibernate.type.Type;
/**
* Allows user code to inspect and/or change property values.
- *
+ *
* Inspection occurs before property values are written and after they are read
- * from the database.
- *
+ * from the database.
+ *
* There might be a single instance of Interceptor for a SessionFactory, or a new instance
* might be specified for each Session. Whichever approach is used, the interceptor must be
* serializable if the Session is to be serializable. This means that SessionFactory-scoped
- * interceptors should implement readResolve().
- *
+ * interceptors should implement readResolve().
+ *
* The Session may not be invoked from a callback (nor may a callback cause a collection or proxy to
- * be lazily initialized).
- *
+ * be lazily initialized).
+ *
* Instead of implementing this interface directly, it is usually better to extend EmptyInterceptor
* and override only the callback methods of interest.
*
@@ -155,9 +155,9 @@ public interface Interceptor {
public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException;
/**
- * Called before a flush
+ * Called before a flush.
*
- * @param entities The entities to be flushed
+ * @param entities The entities to be flushed.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
@@ -215,6 +215,7 @@ public interface Interceptor {
* @param entityName the name of the entity
* @param entityMode The type of entity instance to be returned.
* @param id the identifier of the new instance
+ *
* @return an instance of the class, or null to choose default behaviour
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
@@ -222,8 +223,10 @@ public interface Interceptor {
public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException;
/**
- * Get the entity name for a persistent or transient instance
+ * Get the entity name for a persistent or transient instance.
+ *
* @param object an entity instance
+ *
* @return the name of the entity
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
@@ -231,9 +234,11 @@ public interface Interceptor {
public String getEntityName(Object object) throws CallbackException;
/**
- * Get a fully loaded entity instance that is cached externally
+ * Get a fully loaded entity instance that is cached externally.
+ *
* @param entityName the name of the entity
* @param id the instance identifier
+ *
* @return a fully initialized entity
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
diff --git a/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java b/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java
index c4e461cb7d..f23715de01 100644
--- a/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java
+++ b/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java
@@ -23,12 +23,13 @@
*/
package org.hibernate;
-import org.hibernate.internal.util.xml.XmlDocument;
import org.hibernate.jaxb.spi.Origin;
/**
* Thrown when a mapping is found to be invalid.
- * Similar to MappingException, but this contains more info about the path and type of mapping (e.g. file, resource or url)
+ *
+ * Similar to MappingException, but this contains more info about the path and type of
+ * mapping (e.g. file, resource or url)
*
* @author Max Rydahl Andersen
* @author Steve Ebersole
@@ -37,45 +38,105 @@ public class InvalidMappingException extends MappingException {
private final String path;
private final String type;
+ /**
+ * Constructs an InvalidMappingException using the given information.
+ *
+ * @param customMessage The custom message explaining the exception condition
+ * @param type The type of invalid mapping document
+ * @param path The path (type specific) of the invalid mapping document
+ * @param cause The underlying cause
+ */
public InvalidMappingException(String customMessage, String type, String path, Throwable cause) {
- super(customMessage, cause);
- this.type=type;
- this.path=path;
+ super( customMessage, cause );
+ this.type = type;
+ this.path = path;
}
+ /**
+ * Constructs an InvalidMappingException using the given information.
+ *
+ * @param customMessage The custom message explaining the exception condition
+ * @param type The type of invalid mapping document
+ * @param path The path (type specific) of the invalid mapping document
+ */
public InvalidMappingException(String customMessage, String type, String path) {
super(customMessage);
this.type=type;
this.path=path;
}
+// /**
+// * Constructs an InvalidMappingException using the given information.
+// *
+// * @param customMessage The custom message explaining the exception condition
+// * @param xmlDocument The document that was invalid
+// * @param cause The underlying cause
+// */
// public InvalidMappingException(String customMessage, XmlDocument xmlDocument, Throwable cause) {
// this( customMessage, xmlDocument.getOrigin().getType(), xmlDocument.getOrigin().getName(), cause );
// }
//
+// /**
+// * Constructs an InvalidMappingException using the given information.
+// *
+// * @param customMessage The custom message explaining the exception condition
+// * @param xmlDocument The document that was invalid
+// */
// public InvalidMappingException(String customMessage, XmlDocument xmlDocument) {
// this( customMessage, xmlDocument.getOrigin().getType(), xmlDocument.getOrigin().getName() );
-// }
-//
-// public InvalidMappingException(String customMessage, Origin origin) {
-// this( customMessage, origin.getType().toString(), origin.getName() );
-// }
-//
-// public InvalidMappingException(String type, String path) {
-// this("Could not parse mapping document from " + type + (path==null?"":" " + path), type, path);
// }
+ /**
+ * Constructs an InvalidMappingException using the given information.
+ *
+ * @param customMessage The custom message explaining the exception condition
+ * @param origin The origin of the invalid mapping document
+ */
+ public InvalidMappingException(String customMessage, Origin origin) {
+ this( customMessage, origin.getType().toString(), origin.getName() );
+ }
+
+ /**
+ * Constructs an InvalidMappingException using the given information and a standard message.
+ *
+ * @param type The type of invalid mapping document
+ * @param path The path (type specific) of the invalid mapping document
+ */
+ public InvalidMappingException(String type, String path) {
+ this("Could not parse mapping document from " + type + (path==null?"":" " + path), type, path);
+ }
+
+ /**
+ * Constructs an InvalidMappingException using the given information and a standard message.
+ *
+ * @param type The type of invalid mapping document
+ * @param path The path (type specific) of the invalid mapping document
+ * @param cause The underlying cause
+ */
public InvalidMappingException(String type, String path, Throwable cause) {
this("Could not parse mapping document from " + type + (path==null?"":" " + path), type, path, cause);
}
- public InvalidMappingException(String message, Origin origin, Exception cause) {
- this( message, origin.getType().name(), origin.getName(), cause );
+ /**
+ * Constructs an InvalidMappingException using the given information.
+ *
+ * @param customMessage The custom message explaining the exception condition
+ * @param origin The origin of the invalid mapping document
+ * @param cause The underlying cause
+ */
+ public InvalidMappingException(String customMessage, Origin origin, Exception cause) {
+ this( customMessage, origin.getType().name(), origin.getName(), cause );
}
- public InvalidMappingException(String message, Origin origin) {
- this( message, origin, null );
- }
+// /**
+// * Constructs an InvalidMappingException using the given information.
+// *
+// * @param customMessage The custom message explaining the exception condition
+// * @param origin The origin of the invalid mapping document
+// */
+// public InvalidMappingException(String customMessage, Origin origin) {
+// this( customMessage, origin, null );
+// }
public String getType() {
return type;
diff --git a/hibernate-core/src/main/java/org/hibernate/JDBCException.java b/hibernate-core/src/main/java/org/hibernate/JDBCException.java
index c02305e29e..922657d10e 100644
--- a/hibernate-core/src/main/java/org/hibernate/JDBCException.java
+++ b/hibernate-core/src/main/java/org/hibernate/JDBCException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,63 +20,80 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.sql.SQLException;
-
/**
- * Wraps an SQLException. Indicates that an exception
- * occurred during a JDBC call.
+ * Wraps a {@link SQLException}. Indicates that an exception occurred during a JDBC call.
+ *
+ * @author Gavin King
*
* @see java.sql.SQLException
- * @author Gavin King
*/
public class JDBCException extends HibernateException {
+ private final SQLException sqlException;
+ private final String sql;
- private SQLException sqle;
- private String sql;
-
- public JDBCException(String string, SQLException root) {
- super(string, root);
- sqle=root;
+ /**
+ * Constructs a JDBCException using the given information.
+ *
+ * @param message The message explaining the exception condition
+ * @param cause The underlying cause
+ */
+ public JDBCException(String message, SQLException cause) {
+ this( message, cause, null );
}
- public JDBCException(String string, SQLException root, String sql) {
- this(string, root);
+ /**
+ * Constructs a JDBCException using the given information.
+ *
+ * @param message The message explaining the exception condition
+ * @param cause The underlying cause
+ * @param sql The sql being executed when the exception occurred
+ */
+ public JDBCException(String message, SQLException cause, String sql) {
+ super( message, cause );
+ this.sqlException = cause;
this.sql = sql;
}
/**
- * Get the SQLState of the underlying SQLException.
- * @see java.sql.SQLException
- * @return String
+ * Get the X/Open or ANSI SQL SQLState error code from the underlying {@link SQLException}.
+ *
+ * @return The X/Open or ANSI SQL SQLState error code; may return null.
+ *
+ * @see java.sql.SQLException#getSQLState()
*/
public String getSQLState() {
- return sqle.getSQLState();
+ return sqlException.getSQLState();
}
/**
- * Get the errorCode of the underlying SQLException.
- * @see java.sql.SQLException
- * @return int the error code
+ * Get the vendor specific error code from the underlying {@link SQLException}.
+ *
+ * @return The vendor specific error code
+ *
+ * @see java.sql.SQLException#getErrorCode()
*/
public int getErrorCode() {
- return sqle.getErrorCode();
+ return sqlException.getErrorCode();
}
/**
- * Get the underlying SQLException.
- * @return SQLException
+ * Get the underlying {@link SQLException}.
+ *
+ * @return The SQLException
*/
public SQLException getSQLException() {
- return sqle;
+ return sqlException;
}
/**
- * Get the actual SQL statement that caused the exception
- * (may be null)
+ * Get the actual SQL statement being executed when the exception occurred.
+ *
+ * @return The SQL statement; may return null.
*/
public String getSQL() {
return sql;
diff --git a/hibernate-core/src/main/java/org/hibernate/LazyInitializationException.java b/hibernate-core/src/main/java/org/hibernate/LazyInitializationException.java
index 87b948ac73..e4f801173a 100644
--- a/hibernate-core/src/main/java/org/hibernate/LazyInitializationException.java
+++ b/hibernate-core/src/main/java/org/hibernate/LazyInitializationException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,17 +20,17 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
/**
- * Indicates access to unfetched data outside of a session context.
- * For example, when an uninitialized proxy or collection is accessed
- * after the session was closed.
+ * Indicates an attempt to access not-yet-fetched data outside of a session context.
+ *
+ * For example, when an uninitialized proxy or collection is accessed after the session was closed.
*
* @see Hibernate#initialize(java.lang.Object)
* @see Hibernate#isInitialized(java.lang.Object)
@@ -38,11 +38,19 @@ import org.hibernate.internal.CoreMessageLogger;
*/
public class LazyInitializationException extends HibernateException {
- private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, LazyInitializationException.class.getName() );
+ private static final CoreMessageLogger LOG = Logger.getMessageLogger(
+ CoreMessageLogger.class,
+ LazyInitializationException.class.getName()
+ );
- public LazyInitializationException(String msg) {
- super( msg );
- LOG.trace( msg, this );
+ /**
+ * Constructs a LazyInitializationException using the given message.
+ *
+ * @param message A message explaining the exception condition
+ */
+ public LazyInitializationException(String message) {
+ super( message );
+ LOG.trace( message, this );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/LobHelper.java b/hibernate-core/src/main/java/org/hibernate/LobHelper.java
index f22566fed2..f2c7849289 100644
--- a/hibernate-core/src/main/java/org/hibernate/LobHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/LobHelper.java
@@ -30,7 +30,7 @@ import java.sql.Clob;
import java.sql.NClob;
/**
- * A {@link Session session's} helper for creating LOB data
+ * A {@link Session session's} helper for creating LOB data.
*
* @author Steve Ebersole
*/
@@ -56,7 +56,7 @@ public interface LobHelper {
public Blob createBlob(InputStream stream, long length);
/**
- * Create a new {@link java.sql.Clob} from content
+ * Create a new {@link java.sql.Clob} from content.
*
* @param string The string data
*
diff --git a/hibernate-core/src/main/java/org/hibernate/LockOptions.java b/hibernate-core/src/main/java/org/hibernate/LockOptions.java
index 0e6e9f48a1..ea5c2999ca 100644
--- a/hibernate-core/src/main/java/org/hibernate/LockOptions.java
+++ b/hibernate-core/src/main/java/org/hibernate/LockOptions.java
@@ -36,18 +36,17 @@ import java.util.Map;
*/
public class LockOptions implements Serializable {
/**
- * NONE represents LockMode.NONE (timeout + scope do not apply)
+ * Represents LockMode.NONE (timeout + scope do not apply).
*/
public static final LockOptions NONE = new LockOptions(LockMode.NONE);
/**
- * READ represents LockMode.READ (timeout + scope do not apply)
+ * Represents LockMode.READ (timeout + scope do not apply).
*/
public static final LockOptions READ = new LockOptions(LockMode.READ);
/**
- * UPGRADE represents LockMode.UPGRADE (will wait forever for lock and
- * scope of false meaning only entity is locked)
+ * Represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked).
*/
@SuppressWarnings("deprecation")
public static final LockOptions UPGRADE = new LockOptions(LockMode.UPGRADE);
@@ -73,12 +72,19 @@ public class LockOptions implements Serializable {
private LockMode lockMode = LockMode.NONE;
private int timeout = WAIT_FOREVER;
- //initialize lazily as LockOptions is frequently created without needing this
- private Map aliasSpecificLockModes = null;
+ private Map aliasSpecificLockModes;
+ /**
+ * Constructs a LockOptions with all default options.
+ */
public LockOptions() {
}
+ /**
+ * Constructs a LockOptions with the given lock mode.
+ *
+ * @param lockMode The lock mode to use
+ */
public LockOptions( LockMode lockMode) {
this.lockMode = lockMode;
}
@@ -109,7 +115,6 @@ public class LockOptions implements Serializable {
return this;
}
-
/**
* Specify the {@link LockMode} to be used for a specific query alias.
*
@@ -168,6 +173,11 @@ public class LockOptions implements Serializable {
return lockMode == null ? LockMode.NONE : lockMode;
}
+ /**
+ * Does this LockOptions object define alias-specific lock modes?
+ *
+ * @return {@code true} if this LockOptions object define alias-specific lock modes; {@code false} otherwise.
+ */
public boolean hasAliasSpecificLockModes() {
return aliasSpecificLockModes != null
&& ! aliasSpecificLockModes.isEmpty();
@@ -186,7 +196,7 @@ public class LockOptions implements Serializable {
}
/**
- * Iterator for accessing Alias (key) and LockMode (value) as Map.Entry
+ * Iterator for accessing Alias (key) and LockMode (value) as Map.Entry.
*
* @return Iterator for accessing the Map.Entry's
*/
@@ -198,7 +208,7 @@ public class LockOptions implements Serializable {
}
/**
- * Currently needed for follow-on locking
+ * Currently needed for follow-on locking.
*
* @return The greatest of all requested lock modes.
*/
@@ -251,7 +261,7 @@ public class LockOptions implements Serializable {
return this;
}
- private boolean scope=false;
+ private boolean scope;
/**
* Retrieve the current lock scope setting.
@@ -265,7 +275,7 @@ public class LockOptions implements Serializable {
}
/**
- * Set the cope.
+ * Set the scope.
*
* @param scope The new scope setting
*
@@ -276,6 +286,11 @@ public class LockOptions implements Serializable {
return this;
}
+ /**
+ * Make a copy.
+ *
+ * @return The copy
+ */
public LockOptions makeCopy() {
final LockOptions copy = new LockOptions();
copy( this, copy );
@@ -283,7 +298,7 @@ public class LockOptions implements Serializable {
}
/**
- * Perform a shallow copy
+ * Perform a shallow copy.
*
* @param source Source for the copy (copied from)
* @param destination Destination for the copy (copied to)
diff --git a/hibernate-core/src/main/java/org/hibernate/MappingException.java b/hibernate-core/src/main/java/org/hibernate/MappingException.java
index ae24dc2ef4..31d6aec618 100644
--- a/hibernate-core/src/main/java/org/hibernate/MappingException.java
+++ b/hibernate-core/src/main/java/org/hibernate/MappingException.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2008, 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -24,23 +24,38 @@
package org.hibernate;
/**
- * An exception that usually occurs at configuration time, rather
- * than runtime, as a result of something screwy in the O-R mappings.
+ * An exception that occurs while reading mapping sources (xml/annotations),usually as a result of something
+ * screwy in the O-R mappings.
*
* @author Gavin King
*/
public class MappingException extends HibernateException {
-
- public MappingException(String msg, Throwable root) {
- super( msg, root );
+ /**
+ * Constructs a MappingException using the given information.
+ *
+ * @param message A message explaining the exception condition
+ * @param cause The underlying cause
+ */
+ public MappingException(String message, Throwable cause) {
+ super( message, cause );
}
- public MappingException(Throwable root) {
- super(root);
+ /**
+ * Constructs a MappingException using the given information.
+ *
+ * @param cause The underlying cause
+ */
+ public MappingException(Throwable cause) {
+ super(cause);
}
- public MappingException(String s) {
- super(s);
+ /**
+ * Constructs a MappingException using the given information.
+ *
+ * @param message A message explaining the exception condition
+ */
+ public MappingException(String message) {
+ super(message);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/MappingNotFoundException.java b/hibernate-core/src/main/java/org/hibernate/MappingNotFoundException.java
index 30c17fc54e..73680e32eb 100644
--- a/hibernate-core/src/main/java/org/hibernate/MappingNotFoundException.java
+++ b/hibernate-core/src/main/java/org/hibernate/MappingNotFoundException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,10 +20,8 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
-package org.hibernate;
-
+package org.hibernate;
/**
* Thrown when a resource for a mapping could not be found.
@@ -31,26 +29,53 @@ package org.hibernate;
* @author Max Rydahl Andersen
*/
public class MappingNotFoundException extends MappingException {
-
private final String path;
private final String type;
+ /**
+ * Constructs a MappingNotFoundException using the given information.
+ *
+ * @param customMessage A message explaining the exception condition
+ * @param type The type of mapping that could not be found
+ * @param path The path (type specific) of the mapping that could not be found
+ * @param cause The underlying cause
+ */
public MappingNotFoundException(String customMessage, String type, String path, Throwable cause) {
super(customMessage, cause);
this.type=type;
this.path=path;
}
-
+
+ /**
+ * Constructs a MappingNotFoundException using the given information.
+ *
+ * @param customMessage A message explaining the exception condition
+ * @param type The type of mapping that could not be found
+ * @param path The path (type specific) of the mapping that could not be found
+ */
public MappingNotFoundException(String customMessage, String type, String path) {
super(customMessage);
this.type=type;
this.path=path;
}
-
+
+ /**
+ * Constructs a MappingNotFoundException using the given information, using a standard message.
+ *
+ * @param type The type of mapping that could not be found
+ * @param path The path (type specific) of the mapping that could not be found
+ */
public MappingNotFoundException(String type, String path) {
this(type + ": " + path + " not found", type, path);
}
+ /**
+ * Constructs a MappingNotFoundException using the given information, using a standard message.
+ *
+ * @param type The type of mapping that could not be found
+ * @param path The path (type specific) of the mapping that could not be found
+ * @param cause The underlying cause
+ */
public MappingNotFoundException(String type, String path, Throwable cause) {
this(type + ": " + path + " not found", type, path, cause);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java b/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java
index fff40398ad..9cd26fd450 100644
--- a/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java
@@ -49,7 +49,7 @@ public enum MultiTenancyStrategy {
*/
DATABASE,
/**
- * No multi-tenancy
+ * No multi-tenancy.
*/
NONE;
@@ -58,10 +58,24 @@ public enum MultiTenancyStrategy {
MultiTenancyStrategy.class.getName()
);
+ /**
+ * Does this strategy indicate a requirement for the specialized
+ * {@link org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider}, rather than the
+ * traditional {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider}?
+ *
+ * @return {@code true} indicates a MultiTenantConnectionProvider is required; {@code false} indicates it is not.
+ */
public boolean requiresMultiTenantConnectionProvider() {
return this == DATABASE || this == SCHEMA;
}
+ /**
+ * Extract the MultiTenancyStrategy from the setting map.
+ *
+ * @param properties The map of settings.
+ *
+ * @return The selected strategy. {@link #NONE} is always the default.
+ */
public static MultiTenancyStrategy determineMultiTenancyStrategy(Map properties) {
final Object strategy = properties.get( Environment.MULTI_TENANT );
if ( strategy == null ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/NaturalIdLoadAccess.java b/hibernate-core/src/main/java/org/hibernate/NaturalIdLoadAccess.java
index 89effd90b6..e5c1e62356 100644
--- a/hibernate-core/src/main/java/org/hibernate/NaturalIdLoadAccess.java
+++ b/hibernate-core/src/main/java/org/hibernate/NaturalIdLoadAccess.java
@@ -24,7 +24,7 @@
package org.hibernate;
/**
- * Loads an entity by its natural identifier
+ * Loads an entity by its natural identifier.
*
* @author Eric Dalquist
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/NonUniqueObjectException.java b/hibernate-core/src/main/java/org/hibernate/NonUniqueObjectException.java
index 6664316d8c..ccc676db4d 100644
--- a/hibernate-core/src/main/java/org/hibernate/NonUniqueObjectException.java
+++ b/hibernate-core/src/main/java/org/hibernate/NonUniqueObjectException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,19 +20,17 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
import org.hibernate.pretty.MessageHelper;
/**
- * This exception is thrown when an operation would
- * break session-scoped identity. This occurs if the
- * user tries to associate two different instances of
- * the same Java class with a particular identifier,
- * in the scope of a single Session.
+ * This exception is thrown when an operation would break session-scoped identity. This occurs if the
+ * user tries to associate two different instances of the same Java class with a particular identifier,
+ * in the scope of a single Session.
*
* @author Gavin King
*/
@@ -40,27 +38,43 @@ public class NonUniqueObjectException extends HibernateException {
private final Serializable identifier;
private final String entityName;
- public NonUniqueObjectException(String message, Serializable id, String clazz) {
- super(message);
- this.entityName = clazz;
- this.identifier = id;
+ /**
+ * Constructs a NonUniqueObjectException using the given information.
+ *
+ * @param message A message explaining the exception condition
+ * @param entityId The identifier of the entity
+ * @param entityName The name of the entity
+ */
+ public NonUniqueObjectException(String message, Serializable entityId, String entityName) {
+ super( message );
+ this.entityName = entityName;
+ this.identifier = entityId;
}
- public NonUniqueObjectException(Serializable id, String clazz) {
- this("a different object with the same identifier value was already associated with the session", id, clazz);
- }
-
- public Serializable getIdentifier() {
- return identifier;
- }
-
- public String getMessage() {
- return super.getMessage() + ": " +
- MessageHelper.infoString(entityName, identifier);
+ /**
+ * Constructs a NonUniqueObjectException using the given information, using a standard message.
+ *
+ * @param entityId The identifier of the entity
+ * @param entityName The name of the entity
+ */
+ public NonUniqueObjectException(Serializable entityId, String entityName) {
+ this(
+ "A different object with the same identifier value was already associated with the session",
+ entityId,
+ entityName
+ );
}
public String getEntityName() {
return entityName;
}
+ public Serializable getIdentifier() {
+ return identifier;
+ }
+
+ @Override
+ public String getMessage() {
+ return super.getMessage() + " : " + MessageHelper.infoString( entityName, identifier );
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/NonUniqueResultException.java b/hibernate-core/src/main/java/org/hibernate/NonUniqueResultException.java
index 12630e2c42..a7cf8c4682 100644
--- a/hibernate-core/src/main/java/org/hibernate/NonUniqueResultException.java
+++ b/hibernate-core/src/main/java/org/hibernate/NonUniqueResultException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,20 +20,22 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
* Thrown when the application calls Query.uniqueResult() and
- * the query returned more than one result. Unlike all other Hibernate
+ * the query returned more than one result. Unlike all other Hibernate
* exceptions, this one is recoverable!
*
* @author Gavin King
*/
public class NonUniqueResultException extends HibernateException {
-
+ /**
+ * Constructs a NonUniqueResultException.
+ *
+ * @param resultCount The number of actual results.
+ */
public NonUniqueResultException(int resultCount) {
super( "query did not return a unique result: " + resultCount );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/NullPrecedence.java b/hibernate-core/src/main/java/org/hibernate/NullPrecedence.java
index f4b9dab727..c2e59bd1ea 100644
--- a/hibernate-core/src/main/java/org/hibernate/NullPrecedence.java
+++ b/hibernate-core/src/main/java/org/hibernate/NullPrecedence.java
@@ -1,3 +1,26 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate;
/**
@@ -21,21 +44,37 @@ public enum NullPrecedence {
*/
LAST;
- public static NullPrecedence parse(String type) {
- if ( "none".equalsIgnoreCase( type ) ) {
+ /**
+ * Interprets a string representation of a NullPrecedence, returning {@code null} by default. For
+ * alternative default handling, see {@link #parse(String, NullPrecedence)}
+ *
+ * @param name The String representation to interpret
+ *
+ * @return The recognized NullPrecedence, or {@code null}
+ */
+ public static NullPrecedence parse(String name) {
+ if ( "none".equalsIgnoreCase( name ) ) {
return NullPrecedence.NONE;
}
- else if ( "first".equalsIgnoreCase( type ) ) {
+ else if ( "first".equalsIgnoreCase( name ) ) {
return NullPrecedence.FIRST;
}
- else if ( "last".equalsIgnoreCase( type ) ) {
+ else if ( "last".equalsIgnoreCase( name ) ) {
return NullPrecedence.LAST;
}
return null;
}
- public static NullPrecedence parse(String type, NullPrecedence defaultValue) {
- final NullPrecedence value = parse( type );
+ /**
+ * Interprets a string representation of a NullPrecedence, returning the specified default if not recognized.
+ *
+ * @param name The String representation to interpret
+ * @param defaultValue The default value to use
+ *
+ * @return The recognized NullPrecedence, or {@code defaultValue}.
+ */
+ public static NullPrecedence parse(String name, NullPrecedence defaultValue) {
+ final NullPrecedence value = parse( name );
return value != null ? value : defaultValue;
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/ObjectDeletedException.java b/hibernate-core/src/main/java/org/hibernate/ObjectDeletedException.java
index 766fb4e86e..dff4130c05 100644
--- a/hibernate-core/src/main/java/org/hibernate/ObjectDeletedException.java
+++ b/hibernate-core/src/main/java/org/hibernate/ObjectDeletedException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,21 +20,26 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
/**
- * Thrown when the user tries to do something illegal with a deleted
- * object.
+ * Thrown when the user tries to do something illegal with a deleted object.
*
* @author Gavin King
*/
public class ObjectDeletedException extends UnresolvableObjectException {
-
- public ObjectDeletedException(String message, Serializable identifier, String clazz) {
- super(message, identifier, clazz);
+ /**
+ * Constructs an ObjectDeletedException using the given information.
+ *
+ * @param message A message explaining the exception condition
+ * @param identifier The identifier of the entity
+ * @param entityName The name of the entity
+ */
+ public ObjectDeletedException(String message, Serializable identifier, String entityName) {
+ super( message, identifier, entityName );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/ObjectNotFoundException.java b/hibernate-core/src/main/java/org/hibernate/ObjectNotFoundException.java
index 06a945cda0..a69dd6e551 100644
--- a/hibernate-core/src/main/java/org/hibernate/ObjectNotFoundException.java
+++ b/hibernate-core/src/main/java/org/hibernate/ObjectNotFoundException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,9 +20,9 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
/**
@@ -39,8 +39,13 @@ import java.io.Serializable;
* @author Gavin King
*/
public class ObjectNotFoundException extends UnresolvableObjectException {
-
- public ObjectNotFoundException(Serializable identifier, String clazz) {
- super(identifier, clazz);
+ /**
+ * Constructs a ObjectNotFoundException using the given information.
+ *
+ * @param identifier The identifier of the entity
+ * @param entityName The name of the entity
+ */
+ public ObjectNotFoundException(Serializable identifier, String entityName) {
+ super(identifier, entityName);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/OptimisticLockException.java b/hibernate-core/src/main/java/org/hibernate/OptimisticLockException.java
index 87ad02b1ef..2960609f2f 100644
--- a/hibernate-core/src/main/java/org/hibernate/OptimisticLockException.java
+++ b/hibernate-core/src/main/java/org/hibernate/OptimisticLockException.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2009-2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2009, 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -32,8 +32,15 @@ import org.hibernate.dialect.lock.OptimisticEntityLockException;
*
* @deprecated Use {@link org.hibernate.dialect.lock.OptimisticEntityLockException} instead
*/
+@Deprecated
public class OptimisticLockException extends OptimisticEntityLockException {
+ /**
+ * Constructs a OptimisticLockException using the specified information.
+ *
+ * @param entity The entity instance that could not be locked
+ * @param message A message explaining the exception condition
+ */
public OptimisticLockException(Object entity, String message) {
super( entity, message );
}
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/PersistentObjectException.java b/hibernate-core/src/main/java/org/hibernate/PersistentObjectException.java
index 3d0f4b0142..7841bcf7a3 100644
--- a/hibernate-core/src/main/java/org/hibernate/PersistentObjectException.java
+++ b/hibernate-core/src/main/java/org/hibernate/PersistentObjectException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,11 +20,9 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
* Thrown when the user passes a persistent instance to a Session
* method that expects a transient instance.
@@ -32,8 +30,12 @@ package org.hibernate;
* @author Gavin King
*/
public class PersistentObjectException extends HibernateException {
-
- public PersistentObjectException(String s) {
- super(s);
+ /**
+ * Constructs a PersistentObjectException using the given message.
+ *
+ * @param message A message explaining the exception condition
+ */
+ public PersistentObjectException(String message) {
+ super( message );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/PessimisticLockException.java b/hibernate-core/src/main/java/org/hibernate/PessimisticLockException.java
index c89660ad5d..7bef92625a 100644
--- a/hibernate-core/src/main/java/org/hibernate/PessimisticLockException.java
+++ b/hibernate-core/src/main/java/org/hibernate/PessimisticLockException.java
@@ -31,7 +31,14 @@ import java.sql.SQLException;
* @author Scott Marlow
*/
public class PessimisticLockException extends JDBCException {
- public PessimisticLockException(String s, SQLException se, String sql) {
- super( s, se, sql );
+ /**
+ * Constructs a PessimisticLockException using the specified information.
+ *
+ * @param message A message explaining the exception condition
+ * @param sqlException The underlying SQL exception
+ * @param sql The sql that led to the exception (may be null, though usually should not be)
+ */
+ public PessimisticLockException(String message, SQLException sqlException, String sql) {
+ super( message, sqlException, sql );
}
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/PropertyAccessException.java b/hibernate-core/src/main/java/org/hibernate/PropertyAccessException.java
index 829ee685d6..2c0620e7a9 100644
--- a/hibernate-core/src/main/java/org/hibernate/PropertyAccessException.java
+++ b/hibernate-core/src/main/java/org/hibernate/PropertyAccessException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
@@ -39,13 +38,26 @@ import org.hibernate.internal.util.StringHelper;
* @author Gavin King
*/
public class PropertyAccessException extends HibernateException {
-
private final Class persistentClass;
private final String propertyName;
private final boolean wasSetter;
- public PropertyAccessException(Throwable root, String s, boolean wasSetter, Class persistentClass, String propertyName) {
- super(s, root);
+ /**
+ * Constructs a PropertyAccessException using the specified information.
+ *
+ * @param cause The underlying cause
+ * @param message A message explaining the exception condition
+ * @param wasSetter Was the attempting to access the setter the cause of the exception?
+ * @param persistentClass The class which is supposed to contain the property in question
+ * @param propertyName The name of the property.
+ */
+ public PropertyAccessException(
+ Throwable cause,
+ String message,
+ boolean wasSetter,
+ Class persistentClass,
+ String propertyName) {
+ super(message, cause);
this.persistentClass = persistentClass;
this.wasSetter = wasSetter;
this.propertyName = propertyName;
diff --git a/hibernate-core/src/main/java/org/hibernate/PropertyNotFoundException.java b/hibernate-core/src/main/java/org/hibernate/PropertyNotFoundException.java
index 1ac945f77f..b2498525fa 100644
--- a/hibernate-core/src/main/java/org/hibernate/PropertyNotFoundException.java
+++ b/hibernate-core/src/main/java/org/hibernate/PropertyNotFoundException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,11 +20,9 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
* Indicates that an expected getter or setter method could not be
* found on a class.
@@ -32,9 +30,12 @@ package org.hibernate;
* @author Gavin King
*/
public class PropertyNotFoundException extends MappingException {
-
- public PropertyNotFoundException(String s) {
- super(s);
+ /**
+ * Constructs a PropertyNotFoundException given the specified message.
+ *
+ * @param message A message explaining the exception condition
+ */
+ public PropertyNotFoundException(String message) {
+ super(message);
}
-
}
diff --git a/hibernate-core/src/main/java/org/hibernate/PropertyValueException.java b/hibernate-core/src/main/java/org/hibernate/PropertyValueException.java
index 241cd49063..9634fd5c0c 100644
--- a/hibernate-core/src/main/java/org/hibernate/PropertyValueException.java
+++ b/hibernate-core/src/main/java/org/hibernate/PropertyValueException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
@@ -36,12 +35,18 @@ import org.hibernate.internal.util.StringHelper;
* @author Gavin King
*/
public class PropertyValueException extends HibernateException {
-
private final String entityName;
private final String propertyName;
- public PropertyValueException(String s, String entityName, String propertyName) {
- super(s);
+ /**
+ * Constructs a PropertyValueException using the specified information.
+ *
+ * @param message A message explaining the exception condition
+ * @param entityName The name of the entity, containing the property
+ * @param propertyName The name of the property being accessed.
+ */
+ public PropertyValueException(String message, String entityName, String propertyName) {
+ super(message);
this.entityName = entityName;
this.propertyName = propertyName;
}
@@ -56,25 +61,6 @@ public class PropertyValueException extends HibernateException {
@Override
public String getMessage() {
- return super.getMessage() + ": " +
- StringHelper.qualify(entityName, propertyName);
- }
-
- /**
- * Return a well formed property path.
- * Basicaly, it will return parent.child
- *
- * @param parent parent in path
- * @param child child in path
- * @return parent-child path
- */
- public static String buildPropertyPath(String parent, String child) {
- return new StringBuilder(parent).append('.').append(child).toString();
+ return super.getMessage() + " : " + StringHelper.qualify( entityName, propertyName );
}
}
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/Query.java b/hibernate-core/src/main/java/org/hibernate/Query.java
index c8f202b4f7..3005aa96d0 100644
--- a/hibernate-core/src/main/java/org/hibernate/Query.java
+++ b/hibernate-core/src/main/java/org/hibernate/Query.java
@@ -77,6 +77,7 @@ import org.hibernate.type.Type;
*
* @author Gavin King
*/
+@SuppressWarnings("UnusedDeclaration")
public interface Query extends BasicQueryContract {
/**
* Get the query string.
@@ -99,6 +100,8 @@ public interface Query extends BasicQueryContract {
*
* @param maxResults the maximum number of rows
*
+ * @return {@code this}, for method chaining
+ *
* @see #getMaxResults()
*/
public Query setMaxResults(int maxResults);
@@ -117,6 +120,8 @@ public interface Query extends BasicQueryContract {
*
* @param firstResult a row number, numbered from 0
*
+ * @return {@code this}, for method chaining
+ *
* @see #getFirstResult()
*/
public Query setFirstResult(int firstResult);
@@ -159,6 +164,10 @@ public interface Query extends BasicQueryContract {
*
* For alias-specific locking, use {@link #setLockMode(String, LockMode)}.
*
+ * @param lockOptions The lock options to apply to the query.
+ *
+ * @return {@code this}, for method chaining
+ *
* @see #getLockOptions()
*/
public Query setLockOptions(LockOptions lockOptions);
@@ -173,7 +182,10 @@ public interface Query extends BasicQueryContract {
* speaking, for maximum portability, this method should only be used to mark that the rows corresponding to
* the given alias should be included in pessimistic locking ({@link LockMode#PESSIMISTIC_WRITE}).
*
- * @param alias a query alias, or this for a collection filter
+ * @param alias a query alias, or {@code "this"} for a collection filter
+ * @param lockMode The lock mode to apply.
+ *
+ * @return {@code this}, for method chaining
*
* @see #getLockOptions()
*/
@@ -194,21 +206,25 @@ public interface Query extends BasicQueryContract {
*
* @param comment The human-readable comment
*
+ * @return {@code this}, for method chaining
+ *
* @see #getComment()
*/
public Query setComment(String comment);
/**
- * Return the HQL select clause aliases (if any)
+ * Return the HQL select clause aliases, if any.
+ *
* @return an array of aliases as strings
*/
- public String[] getReturnAliases() throws HibernateException;
+ public String[] getReturnAliases();
/**
* Return the names of all named parameters of the query.
+ *
* @return the parameter names, in no particular order
*/
- public String[] getNamedParameters() throws HibernateException;
+ public String[] getNamedParameters();
/**
* Return the query results as an Iterator. If the query
@@ -219,9 +235,8 @@ public interface Query extends BasicQueryContract {
* SQL query returns identifiers only.
*
* @return the result iterator
- * @throws HibernateException
*/
- public Iterator iterate() throws HibernateException;
+ public Iterator iterate();
/**
* Return the query results as ScrollableResults. The
@@ -229,22 +244,24 @@ public interface Query extends BasicQueryContract {
* support for scrollable ResultSets.
*
* @see ScrollableResults
+ *
* @return the result iterator
- * @throws HibernateException
*/
- public ScrollableResults scroll() throws HibernateException;
+ public ScrollableResults scroll();
/**
- * Return the query results as ScrollableResults. The
- * scrollability of the returned results depends upon JDBC driver
- * support for scrollable ResultSets.
+ * Return the query results as ScrollableResults. The scrollability of the returned results
+ * depends upon JDBC driver support for scrollable ResultSets.
+ *
+ * @param scrollMode The scroll mode
+ *
+ * @return the result iterator
*
* @see ScrollableResults
* @see ScrollMode
- * @return the result iterator
- * @throws HibernateException
+ *
*/
- public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException;
+ public ScrollableResults scroll(ScrollMode scrollMode);
/**
* Return the query results as a List. If the query contains
@@ -252,44 +269,48 @@ public interface Query extends BasicQueryContract {
* of Object[].
*
* @return the result list
- * @throws HibernateException
*/
- public List list() throws HibernateException;
+ public List list();
/**
* Convenience method to return a single instance that matches
* the query, or null if the query returns no results.
*
* @return the single result or null
+ *
* @throws NonUniqueResultException if there is more than one matching result
*/
- public Object uniqueResult() throws HibernateException;
+ public Object uniqueResult();
/**
* Execute the update or delete statement.
- *
- * The semantics are compliant with the ejb3 Query.executeUpdate()
- * method.
+ *
+ * The semantics are compliant with the ejb3 Query.executeUpdate() method.
*
* @return The number of entities updated or deleted.
- * @throws HibernateException
*/
- public int executeUpdate() throws HibernateException;
+ public int executeUpdate();
/**
* Bind a value to a JDBC-style query parameter.
+ *
* @param position the position of the parameter in the query
* string, numbered from 0.
* @param val the possibly-null parameter value
* @param type the Hibernate type
+ *
+ * @return {@code this}, for method chaining
*/
public Query setParameter(int position, Object val, Type type);
/**
* Bind a value to a named query parameter.
+ *
* @param name the name of the parameter
* @param val the possibly-null parameter value
* @param type the Hibernate type
+ *
+ * @return {@code this}, for method chaining
*/
public Query setParameter(String name, Object val, Type type);
@@ -297,162 +318,535 @@ public interface Query extends BasicQueryContract {
* Bind a value to a JDBC-style query parameter. The Hibernate type of the parameter is
* first detected via the usage/position in the query and if not sufficient secondly
* guessed from the class of the given object.
+ *
* @param position the position of the parameter in the query
* string, numbered from 0.
* @param val the non-null parameter value
- * @throws org.hibernate.HibernateException if no type could be determined
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setParameter(int position, Object val) throws HibernateException;
+ public Query setParameter(int position, Object val);
/**
* Bind a value to a named query parameter. The Hibernate type of the parameter is
* first detected via the usage/position in the query and if not sufficient secondly
* guessed from the class of the given object.
+ *
* @param name the name of the parameter
* @param val the non-null parameter value
- * @throws org.hibernate.HibernateException if no type could be determined
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setParameter(String name, Object val) throws HibernateException;
+ public Query setParameter(String name, Object val);
/**
- * Bind values and types to positional parameters.
+ * Bind values and types to positional parameters. Allows binding more than one at a time; no real performance
+ * impact.
+ *
+ * The number of elements in each array should match. That is, element number-0 in types array corresponds to
+ * element-0 in the values array, etc,
+ *
+ * @param types The types
+ * @param values The values
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setParameters(Object[] values, Type[] types) throws HibernateException;
+ public Query setParameters(Object[] values, Type[] types);
/**
* Bind multiple values to a named query parameter. This is useful for binding
* a list of values to an expression such as foo.bar in (:value_list).
+ *
* @param name the name of the parameter
- * @param vals a collection of values to list
+ * @param values a collection of values to list
* @param type the Hibernate type of the values
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setParameterList(String name, Collection vals, Type type) throws HibernateException;
+ public Query setParameterList(String name, Collection values, Type type);
/**
* Bind multiple values to a named query parameter. The Hibernate type of the parameter is
* first detected via the usage/position in the query and if not sufficient secondly
* guessed from the class of the first object in the collection. This is useful for binding a list of values
* to an expression such as foo.bar in (:value_list).
+ *
* @param name the name of the parameter
- * @param vals a collection of values to list
+ * @param values a collection of values to list
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setParameterList(String name, Collection vals) throws HibernateException;
+ public Query setParameterList(String name, Collection values);
/**
* Bind multiple values to a named query parameter. This is useful for binding
* a list of values to an expression such as foo.bar in (:value_list).
+ *
* @param name the name of the parameter
- * @param vals a collection of values to list
+ * @param values a collection of values to list
* @param type the Hibernate type of the values
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setParameterList(String name, Object[] vals, Type type) throws HibernateException;
+ public Query setParameterList(String name, Object[] values, Type type);
/**
* Bind multiple values to a named query parameter. The Hibernate type of the parameter is
* first detected via the usage/position in the query and if not sufficient secondly
* guessed from the class of the first object in the array. This is useful for binding a list of values
* to an expression such as foo.bar in (:value_list).
+ *
* @param name the name of the parameter
- * @param vals a collection of values to list
+ * @param values a collection of values to list
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setParameterList(String name, Object[] vals) throws HibernateException;
+ public Query setParameterList(String name, Object[] values);
/**
* Bind the property values of the given bean to named parameters of the query,
* matching property names with parameter names and mapping property types to
- * Hibernate types using hueristics.
+ * Hibernate types using heuristics.
+ *
* @param bean any JavaBean or POJO
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setProperties(Object bean) throws HibernateException;
+ public Query setProperties(Object bean);
/**
* Bind the values of the given Map for each named parameters of the query,
* matching key names with parameter names and mapping value types to
- * Hibernate types using hueristics.
+ * Hibernate types using heuristics.
+ *
* @param bean a java.util.Map
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setProperties(Map bean) throws HibernateException;
+ public Query setProperties(Map bean);
+ /**
+ * Bind a positional String-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setString(int position, String val);
+
+ /**
+ * Bind a positional char-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setCharacter(int position, char val);
+
+ /**
+ * Bind a positional boolean-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBoolean(int position, boolean val);
+
+ /**
+ * Bind a positional byte-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setByte(int position, byte val);
+
+ /**
+ * Bind a positional short-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setShort(int position, short val);
+
+ /**
+ * Bind a positional int-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setInteger(int position, int val);
+
+ /**
+ * Bind a positional long-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setLong(int position, long val);
+
+ /**
+ * Bind a positional float-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setFloat(int position, float val);
+
+ /**
+ * Bind a positional double-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setDouble(int position, double val);
+
+ /**
+ * Bind a positional binary-valued parameter.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBinary(int position, byte[] val);
+
+ /**
+ * Bind a positional String-valued parameter using streaming.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setText(int position, String val);
+
+ /**
+ * Bind a positional binary-valued parameter using serialization.
+ *
+ * @param position The parameter position
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setSerializable(int position, Serializable val);
+
+ /**
+ * Bind a positional Locale-valued parameter.
+ *
+ * @param position The parameter position
+ * @param locale The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setLocale(int position, Locale locale);
+
+ /**
+ * Bind a positional BigDecimal-valued parameter.
+ *
+ * @param position The parameter position
+ * @param number The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBigDecimal(int position, BigDecimal number);
+
+ /**
+ * Bind a positional BigDecimal-valued parameter.
+ *
+ * @param position The parameter position
+ * @param number The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBigInteger(int position, BigInteger number);
+ /**
+ * Bind a positional Date-valued parameter using just the Date portion.
+ *
+ * @param position The parameter position
+ * @param date The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setDate(int position, Date date);
+
+ /**
+ * Bind a positional Date-valued parameter using just the Time portion.
+ *
+ * @param position The parameter position
+ * @param date The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setTime(int position, Date date);
+
+ /**
+ * Bind a positional Date-valued parameter using the full Timestamp.
+ *
+ * @param position The parameter position
+ * @param date The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setTimestamp(int position, Date date);
+ /**
+ * Bind a positional Calendar-valued parameter using the full Timestamp portion.
+ *
+ * @param position The parameter position
+ * @param calendar The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setCalendar(int position, Calendar calendar);
+
+ /**
+ * Bind a positional Calendar-valued parameter using just the Date portion.
+ *
+ * @param position The parameter position
+ * @param calendar The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setCalendarDate(int position, Calendar calendar);
+ /**
+ * Bind a named String-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setString(String name, String val);
+
+ /**
+ * Bind a named char-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setCharacter(String name, char val);
+
+ /**
+ * Bind a named boolean-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBoolean(String name, boolean val);
+
+ /**
+ * Bind a named byte-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setByte(String name, byte val);
+
+ /**
+ * Bind a named short-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setShort(String name, short val);
+
+ /**
+ * Bind a named int-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setInteger(String name, int val);
+
+ /**
+ * Bind a named long-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setLong(String name, long val);
+
+ /**
+ * Bind a named float-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setFloat(String name, float val);
+
+ /**
+ * Bind a named double-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setDouble(String name, double val);
+
+ /**
+ * Bind a named binary-valued parameter.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBinary(String name, byte[] val);
+
+ /**
+ * Bind a named String-valued parameter using streaming.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setText(String name, String val);
+
+ /**
+ * Bind a named binary-valued parameter using serialization.
+ *
+ * @param name The parameter name
+ * @param val The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setSerializable(String name, Serializable val);
+
+ /**
+ * Bind a named Locale-valued parameter.
+ *
+ * @param name The parameter name
+ * @param locale The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setLocale(String name, Locale locale);
+
+ /**
+ * Bind a named BigDecimal-valued parameter.
+ *
+ * @param name The parameter name
+ * @param number The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBigDecimal(String name, BigDecimal number);
+
+ /**
+ * Bind a named BigInteger-valued parameter.
+ *
+ * @param name The parameter name
+ * @param number The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setBigInteger(String name, BigInteger number);
- /**
- * Bind the date (time is truncated) of a given Date object to a named query parameter.
- *
+ /**
+ * Bind the date (time is truncated) of a given Date object to a named query parameter.
+ *
* @param name The name of the parameter
* @param date The date object
- */
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setDate(String name, Date date);
- /**
- * Bind the time (date is truncated) of a given Date object to a named query parameter.
- *
+ /**
+ * Bind the time (date is truncated) of a given Date object to a named query parameter.
+ *
* @param name The name of the parameter
* @param date The date object
- */
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setTime(String name, Date date);
- /**
- * Bind the date and the time of a given Date object to a named query parameter.
- *
+ /**
+ * Bind the date and the time of a given Date object to a named query parameter.
+ *
* @param name The name of the parameter
* @param date The date object
- */
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setTimestamp(String name, Date date);
+ /**
+ * Bind a named Calendar-valued parameter using the full Timestamp.
+ *
+ * @param name The parameter name
+ * @param calendar The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setCalendar(String name, Calendar calendar);
+
+ /**
+ * Bind a named Calendar-valued parameter using just the Date portion.
+ *
+ * @param name The parameter name
+ * @param calendar The bind value
+ *
+ * @return {@code this}, for method chaining
+ */
public Query setCalendarDate(String name, Calendar calendar);
/**
* Bind an instance of a mapped persistent class to a JDBC-style query parameter.
+ * Use {@link #setParameter(int, Object)} for null values.
+ *
* @param position the position of the parameter in the query
* string, numbered from 0.
* @param val a non-null instance of a persistent class
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setEntity(int position, Object val); // use setParameter for null values
+ public Query setEntity(int position, Object val);
/**
- * Bind an instance of a mapped persistent class to a named query parameter.
+ * Bind an instance of a mapped persistent class to a named query parameter. Use
+ * {@link #setParameter(String, Object)} for null values.
+ *
* @param name the name of the parameter
* @param val a non-null instance of a persistent class
+ *
+ * @return {@code this}, for method chaining
*/
- public Query setEntity(String name, Object val); // use setParameter for null values
+ public Query setEntity(String name, Object val);
/**
@@ -460,7 +854,7 @@ public interface Query extends BasicQueryContract {
* "shape" of the query result.
*
* @param transformer The transformer to apply
- * @return this (for method chaining)
+ * @return this (for method chaining)
*/
public Query setResultTransformer(ResultTransformer transformer);
diff --git a/hibernate-core/src/main/java/org/hibernate/QueryException.java b/hibernate-core/src/main/java/org/hibernate/QueryException.java
index c6658b81fd..fd20591a22 100644
--- a/hibernate-core/src/main/java/org/hibernate/QueryException.java
+++ b/hibernate-core/src/main/java/org/hibernate/QueryException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,53 +20,91 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+import org.jboss.logging.Logger;
/**
- * A problem occurred translating a Hibernate query to SQL
- * due to invalid query syntax, etc.
+ * A problem occurred translating a Hibernate query to SQL due to invalid query syntax, etc.
*/
public class QueryException extends HibernateException {
+ private static final Logger log = Logger.getLogger( QueryException.class );
private String queryString;
+ /**
+ * Constructs a QueryException using the specified exception message.
+ *
+ * @param message A message explaining the exception condition
+ */
public QueryException(String message) {
super(message);
}
- public QueryException(String message, Throwable e) {
- super(message, e);
+
+ /**
+ * Constructs a QueryException using the specified exception message and cause.
+ *
+ * @param message A message explaining the exception condition
+ * @param cause The underlying cause
+ */
+ public QueryException(String message, Throwable cause) {
+ super(message, cause);
}
+ /**
+ * Constructs a QueryException using the specified exception message and query-string.
+ *
+ * @param message A message explaining the exception condition
+ * @param queryString The query being evaluated when the exception occurred
+ */
public QueryException(String message, String queryString) {
super(message);
this.queryString = queryString;
}
- public QueryException(Exception e) {
- super(e);
+ /**
+ * Constructs a QueryException using the specified cause.
+ *
+ * @param cause The underlying cause
+ */
+ public QueryException(Exception cause) {
+ super(cause);
}
+
+ /**
+ * Retrieve the query being evaluated when the exception occurred. May be null, but generally should not.
+ *
+ * @return The query string
+ */
public String getQueryString() {
return queryString;
}
+ /**
+ * Set the query string. Even an option since often the part of the code generating the exception does not
+ * have access to the query overall.
+ *
+ * @param queryString The query string.
+ */
public void setQueryString(String queryString) {
+ if ( this.queryString != null ) {
+ log.debugf(
+ "queryString overriding non-null previous value [%s] : %s",
+ this.queryString,
+ queryString
+ );
+ }
this.queryString = queryString;
}
+ @Override
public String getMessage() {
String msg = super.getMessage();
- if ( queryString!=null ) msg += " [" + queryString + ']';
+ if ( queryString!=null ) {
+ msg += " [" + queryString + ']';
+ }
return msg;
}
}
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/QueryParameterException.java b/hibernate-core/src/main/java/org/hibernate/QueryParameterException.java
index 72d08eae15..92998c0029 100644
--- a/hibernate-core/src/main/java/org/hibernate/QueryParameterException.java
+++ b/hibernate-core/src/main/java/org/hibernate/QueryParameterException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,31 +20,21 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
-package org.hibernate;
-
+package org.hibernate;
/**
- * Parameter invalid or not found in the query
+ * Parameter invalid or not found in the query.
*
* @author Emmanuel Bernard
*/
public class QueryParameterException extends QueryException {
-
- public QueryParameterException(Exception e) {
- super( e );
- }
-
+ /**
+ * Constructs a QueryParameterException using the supplied exception message.
+ *
+ * @param message The message explaining the exception condition
+ */
public QueryParameterException(String message) {
super( message );
}
-
- public QueryParameterException(String message, Throwable e) {
- super( message, e );
- }
-
- public QueryParameterException(String message, String queryString) {
- super( message, queryString );
- }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/QueryTimeoutException.java b/hibernate-core/src/main/java/org/hibernate/QueryTimeoutException.java
index cc65680f0b..666833fbb3 100644
--- a/hibernate-core/src/main/java/org/hibernate/QueryTimeoutException.java
+++ b/hibernate-core/src/main/java/org/hibernate/QueryTimeoutException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2009, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,26 +20,26 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.sql.SQLException;
/**
- *
* Thrown when a database query timeout occurs.
*
* @author Scott Marlow
*/
-
public class QueryTimeoutException extends JDBCException {
-
- public QueryTimeoutException( String s, JDBCException je, String sql ) {
- super(s, je.getSQLException(), sql);
- }
-
- public QueryTimeoutException( String s, SQLException se, String sql ) {
- super(s, se, sql);
+ /**
+ * Constructs a QueryTimeoutException using the supplied information.
+ *
+ * @param message The message explaining the exception condition
+ * @param sqlException The underlying SQLException
+ * @param sql The sql being executed when the exception occurred.
+ */
+ public QueryTimeoutException(String message, SQLException sqlException, String sql) {
+ super(message, sqlException, sql);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/ReplicationMode.java b/hibernate-core/src/main/java/org/hibernate/ReplicationMode.java
index 4e18a2bad1..c299eca453 100644
--- a/hibernate-core/src/main/java/org/hibernate/ReplicationMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/ReplicationMode.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
@@ -37,6 +36,7 @@ public enum ReplicationMode {
* Throw an exception when a row already exists.
*/
EXCEPTION {
+ @Override
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
throw new AssertionFailure( "should not be called" );
}
@@ -45,6 +45,7 @@ public enum ReplicationMode {
* Ignore replicated entities when a row already exists.
*/
IGNORE {
+ @Override
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
return false;
}
@@ -53,6 +54,7 @@ public enum ReplicationMode {
* Overwrite existing rows when a row already exists.
*/
OVERWRITE {
+ @Override
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
return true;
}
@@ -61,17 +63,26 @@ public enum ReplicationMode {
* When a row already exists, choose the latest version.
*/
LATEST_VERSION {
+ @Override
+ @SuppressWarnings("unchecked")
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
- if ( versionType == null ) {
- return true; //always overwrite nonversioned data
- }
- return versionType.getComparator().compare( currentVersion, newVersion ) <= 0;
+ // always overwrite non-versioned data (because we don't know which is newer)
+ return versionType == null || versionType.getComparator().compare( currentVersion, newVersion ) <= 0;
}
};
+ /**
+ * Determine whether the mode dictates that the data being replicated should overwrite the data found.
+ *
+ * @param entity The entity being replicated
+ * @param currentVersion The version currently on the target database table.
+ * @param newVersion The replicating version
+ * @param versionType The version type
+ *
+ * @return {@code true} indicates the data should be overwritten; {@code false} indicates it should not.
+ */
public abstract boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType);
-
}
diff --git a/hibernate-core/src/main/java/org/hibernate/ResourceClosedException.java b/hibernate-core/src/main/java/org/hibernate/ResourceClosedException.java
index 800d478cf0..d1182344f4 100644
--- a/hibernate-core/src/main/java/org/hibernate/ResourceClosedException.java
+++ b/hibernate-core/src/main/java/org/hibernate/ResourceClosedException.java
@@ -29,11 +29,12 @@ package org.hibernate;
* @author Steve Ebersole
*/
public class ResourceClosedException extends HibernateException {
- public ResourceClosedException(String s) {
- super( s );
- }
-
- public ResourceClosedException(String string, Throwable root) {
- super( string, root );
+ /**
+ * Constructs a ResourceClosedException using the supplied message.
+ *
+ * @param message The message explaining the exception condition
+ */
+ public ResourceClosedException(String message) {
+ super( message );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/SQLQuery.java b/hibernate-core/src/main/java/org/hibernate/SQLQuery.java
index 4938546a27..b38ee8d83d 100755
--- a/hibernate-core/src/main/java/org/hibernate/SQLQuery.java
+++ b/hibernate-core/src/main/java/org/hibernate/SQLQuery.java
@@ -28,20 +28,33 @@ import org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn;
import org.hibernate.type.Type;
/**
- * Represents a "native sql" query and allows the user to define certain aspects about its execution, such as:
- *
result-set value mapping (see below)
- *
- * Tables used via {@link #addSynchronizedQuerySpace}, {@link #addSynchronizedEntityName} and
- * {@link #addSynchronizedEntityClass}. This allows Hibernate to properly know how to deal with auto-flush checking
- * as well as cached query results if the results of the query are being cached.
- *
- *
- *
- * In terms of result-set mapping, there are 3 approaches to defining:
- *
If this represents a named sql query, the mapping could be associated with the query as part of its metadata
- *
A pre-defined (defined in metadata and named) mapping can be associated with {@link #setResultSetMapping}
- *
Defined locally per the various {@link #addEntity}, {@link #addRoot}, {@link #addJoin}, {@link #addFetch} and {@link #addScalar} methods
+ * Represents a "native sql" query.
*
+ * Allows the user to define certain aspects about its execution, such as:
+ *
+ * result-set value mapping (see below)
+ *
+ *
+ * Tables used via {@link #addSynchronizedQuerySpace}, {@link #addSynchronizedEntityName} and
+ * {@link #addSynchronizedEntityClass}. This allows Hibernate to know how to properly deal with
+ * auto-flush checking as well as cached query results if the results of the query are being
+ * cached.
+ *
+ *
+ *
+ * In terms of result-set mapping, there are 3 approaches to defining:
+ *
+ * If this represents a named sql query, the mapping could be associated with the query as part
+ * of its metadata
+ *
+ *
+ * A pre-defined (defined in metadata and named) mapping can be associated with
+ * {@link #setResultSetMapping}
+ *
+ *
+ * Defined locally per the various {@link #addEntity}, {@link #addRoot}, {@link #addJoin},
+ * {@link #addFetch} and {@link #addScalar} methods
+ *
*
*
* @author Gavin King
@@ -74,6 +87,11 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
*/
public boolean isCallable();
+ /**
+ * Retrieve the returns associated with this query.
+ *
+ * @return The return descriptors
+ */
public List getQueryReturns();
/**
@@ -100,7 +118,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public SQLQuery addScalar(String columnAlias, Type type);
/**
- * Add a new root return mapping, returning a {@link RootReturn} to allow further definition
+ * Add a new root return mapping, returning a {@link RootReturn} to allow further definition.
*
* @param tableAlias The SQL table alias to map to this entity
* @param entityName The name of the entity.
@@ -112,7 +130,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public RootReturn addRoot(String tableAlias, String entityName);
/**
- * Add a new root return mapping, returning a {@link RootReturn} to allow further definition
+ * Add a new root return mapping, returning a {@link RootReturn} to allow further definition.
*
* @param tableAlias The SQL table alias to map to this entity
* @param entityType The java type of the entity.
@@ -136,7 +154,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public SQLQuery addEntity(String entityName);
/**
- * Declare a "root" entity
+ * Declare a "root" entity.
*
* @param tableAlias The SQL table alias
* @param entityName The entity name
@@ -146,7 +164,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public SQLQuery addEntity(String tableAlias, String entityName);
/**
- * Declare a "root" entity, specifying a lock mode
+ * Declare a "root" entity, specifying a lock mode.
*
* @param tableAlias The SQL table alias
* @param entityName The entity name
@@ -167,7 +185,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public SQLQuery addEntity(Class entityType);
/**
- * Declare a "root" entity
+ * Declare a "root" entity.
*
* @param tableAlias The SQL table alias
* @param entityType The java type of the entity to add as a root
@@ -177,7 +195,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public SQLQuery addEntity(String tableAlias, Class entityType);
/**
- * Declare a "root" entity, specifying a lock mode
+ * Declare a "root" entity, specifying a lock mode.
*
* @param tableAlias The SQL table alias
* @param entityName The entity name
@@ -226,7 +244,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public SQLQuery addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName);
/**
- * Declare a join fetch result, specifying a lock mode
+ * Declare a join fetch result, specifying a lock mode.
*
* @param tableAlias The SQL table alias for the data to be mapped to this fetch
* @param path The association path ([owner-alias].[property-name]).
@@ -252,11 +270,11 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
}
/**
- * Allows access to further control how root returns are mapped back from result sets
+ * Allows access to further control how root returns are mapped back from result sets.
*/
public static interface RootReturn {
/**
- * Set the lock mode for this return
+ * Set the lock mode for this return.
*
* @param lockMode The new lock mode.
*
@@ -265,7 +283,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public RootReturn setLockMode(LockMode lockMode);
/**
- * Name the column alias that identifies the entity's discriminator
+ * Name the column alias that identifies the entity's discriminator.
*
* @param columnAlias The discriminator column alias
*
@@ -274,7 +292,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public RootReturn setDiscriminatorAlias(String columnAlias);
/**
- * Add a simple property-to-one-column mapping
+ * Add a simple property-to-one-column mapping.
*
* @param propertyName The name of the property.
* @param columnAlias The name of the column
@@ -294,11 +312,11 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
}
/**
- * Allows access to further control how join fetch returns are mapped back from result sets
+ * Allows access to further control how join fetch returns are mapped back from result sets.
*/
public static interface FetchReturn {
/**
- * Set the lock mode for this return
+ * Set the lock mode for this return.
*
* @param lockMode The new lock mode.
*
@@ -307,7 +325,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
public FetchReturn setLockMode(LockMode lockMode);
/**
- * Add a simple property-to-one-column mapping
+ * Add a simple property-to-one-column mapping.
*
* @param propertyName The name of the property.
* @param columnAlias The name of the column
diff --git a/hibernate-core/src/main/java/org/hibernate/ScrollMode.java b/hibernate-core/src/main/java/org/hibernate/ScrollMode.java
index 9e89365a26..17d227748f 100755
--- a/hibernate-core/src/main/java/org/hibernate/ScrollMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/ScrollMode.java
@@ -27,58 +27,60 @@ package org.hibernate;
import java.sql.ResultSet;
/**
- * Specifies the type of JDBC scrollable result set to use
- * underneath a ScrollableResults
+ * Specifies the type of JDBC scrollable result set to use underneath a {@link ScrollableResults}.
*
* @author Gavin King
- * @see Query#scroll(ScrollMode)
- * @see ScrollableResults
*/
public enum ScrollMode {
/**
+ * Requests a scrollable result that is only scrollable forwards.
+ *
* @see java.sql.ResultSet#TYPE_FORWARD_ONLY
*/
FORWARD_ONLY( ResultSet.TYPE_FORWARD_ONLY ),
/**
+ * Requests a scrollable result which is sensitive to changes in the underlying data.
+ *
* @see java.sql.ResultSet#TYPE_SCROLL_SENSITIVE
*/
- SCROLL_SENSITIVE(
- ResultSet.TYPE_SCROLL_SENSITIVE
- ),
+ SCROLL_SENSITIVE( ResultSet.TYPE_SCROLL_SENSITIVE ),
+
/**
+ * Requests a scrollable result which is insensitive to changes in the underlying data.
+ *
* Note that since the Hibernate session acts as a cache, you
- * might need to expicitly evict objects, if you need to see
+ * might need to explicitly evict objects, if you need to see
* changes made by other transactions.
*
* @see java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE
*/
- SCROLL_INSENSITIVE(
- ResultSet.TYPE_SCROLL_INSENSITIVE
- );
+ SCROLL_INSENSITIVE( ResultSet.TYPE_SCROLL_INSENSITIVE );
+
private final int resultSetType;
private ScrollMode(int level) {
this.resultSetType = level;
}
-
/**
+ * Get the corresponding JDBC scroll type code constant value.
+ *
* @return the JDBC result set type code
*/
public int toResultSetType() {
return resultSetType;
}
-
+ /**
+ * Determine if {@code this} mode is "less than" the provided mode.
+ *
+ * @param other The provided mode
+ *
+ * @return {@code true} if this mode is less than the other.
+ */
public boolean lessThan(ScrollMode other) {
return this.resultSetType < other.resultSetType;
}
}
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/ScrollableResults.java b/hibernate-core/src/main/java/org/hibernate/ScrollableResults.java
index 0abc5cfa52..4cfd86010d 100644
--- a/hibernate-core/src/main/java/org/hibernate/ScrollableResults.java
+++ b/hibernate-core/src/main/java/org/hibernate/ScrollableResults.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
import java.math.BigDecimal;
@@ -44,179 +43,335 @@ import org.hibernate.type.Type;
* Contrary to JDBC, columns of results are numbered from zero.
*
* @see Query#scroll()
+ *
* @author Gavin King
*/
public interface ScrollableResults {
/**
- * Advance to the next result
- * @return true if there is another result
+ * Advance to the next result.
+ *
+ * @return {@code true} if there is another result
*/
- public boolean next() throws HibernateException;
+ public boolean next();
+
/**
- * Retreat to the previous result
- * @return true if there is a previous result
+ * Retreat to the previous result.
+ *
+ * @return {@code true} if there is a previous result
*/
- public boolean previous() throws HibernateException;
+ public boolean previous();
+
/**
- * Scroll an arbitrary number of locations
- * @param i a positive (forward) or negative (backward) number of rows
- * @return true if there is a result at the new location
+ * Scroll the specified number of positions from the current position.
+ *
+ * @param positions a positive (forward) or negative (backward) number of rows
+ *
+ * @return {@code true} if there is a result at the new location
*/
- public boolean scroll(int i) throws HibernateException;
+ public boolean scroll(int positions);
+
/**
- * Go to the last result
- * @return true if there are any results
+ * Go to the last result.
+ *
+ * @return {@code true} if there are any results
*/
- public boolean last() throws HibernateException;
+ public boolean last();
+
/**
- * Go to the first result
- * @return true if there are any results
+ * Go to the first result.
+ *
+ * @return {@code true} if there are any results
*/
- public boolean first() throws HibernateException;
+ public boolean first();
+
/**
- * Go to a location just before first result (this is the initial location)
+ * Go to a location just before first result, This is the location of the cursor on a newly returned
+ * scrollable result.
*/
- public void beforeFirst() throws HibernateException;
+ public void beforeFirst();
+
/**
- * Go to a location just after the last result
+ * Go to a location just after the last result.
*/
- public void afterLast() throws HibernateException;
+ public void afterLast();
+
/**
* Is this the first result?
*
- * @return true if this is the first row of results
- * @throws HibernateException
+ * @return {@code true} if this is the first row of results, otherwise {@code false}
*/
- public boolean isFirst() throws HibernateException;
+ public boolean isFirst();
+
/**
* Is this the last result?
*
- * @return true if this is the last row of results
- * @throws HibernateException
+ * @return {@code true} if this is the last row of results.
*/
- public boolean isLast() throws HibernateException;
+ public boolean isLast();
+
+ /**
+ * Get the current position in the results. The first position is number 0 (unlike JDBC).
+ *
+ * @return The current position number, numbered from 0; -1 indicates that there is no current row
+ */
+ public int getRowNumber();
+
+ /**
+ * Set the current position in the result set. Can be numbered from the first position (positive number) or
+ * the last row (negative number).
+ *
+ * @param rowNumber the row number. A positive number indicates a value numbered from the first row; a
+ * negative number indicates a value numbered from the last row.
+ *
+ * @return true if there is a row at that row number
+ */
+ public boolean setRowNumber(int rowNumber);
+
/**
* Release resources immediately.
*/
- public void close() throws HibernateException;
+ public void close();
+
/**
- * Get the current row of results
- * @return an object or array
+ * Get the current row of results.
+ *
+ * @return The array of results
*/
- public Object[] get() throws HibernateException;
+ public Object[] get();
+
/**
* Get the ith object in the current row of results, without
* initializing any other results in the row. This method may be used
* safely, regardless of the type of the column (ie. even for scalar
* results).
+ *
* @param i the column, numbered from zero
- * @return an object of any Hibernate type or null
+ *
+ * @return The requested result object; may return {@code null}
+ *
+ * @throws IndexOutOfBoundsException If i is an invalid index.
*/
- public Object get(int i) throws HibernateException;
+ public Object get(int i);
/**
- * Get the type of the ith column of results
+ * Get the type of the ith column of results.
+ *
* @param i the column, numbered from zero
+ *
* @return the Hibernate type
+ *
+ * @throws IndexOutOfBoundsException If i is an invalid index.
*/
public Type getType(int i);
/**
- * Convenience method to read an integer
+ * Convenience method to read an integer.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as an integer
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Integer getInteger(int col) throws HibernateException;
+ public Integer getInteger(int col);
+
/**
- * Convenience method to read a long
+ * Convenience method to read a long.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a long
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Long getLong(int col) throws HibernateException;
+ public Long getLong(int col);
+
/**
- * Convenience method to read a float
+ * Convenience method to read a float.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a float
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Float getFloat(int col) throws HibernateException;
+ public Float getFloat(int col);
+
/**
- * Convenience method to read a boolean
+ * Convenience method to read a boolean.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a boolean
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Boolean getBoolean(int col) throws HibernateException;
+ public Boolean getBoolean(int col);
+
/**
- * Convenience method to read a double
+ * Convenience method to read a double.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a double
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Double getDouble(int col) throws HibernateException;
+ public Double getDouble(int col);
+
/**
- * Convenience method to read a short
+ * Convenience method to read a short.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a short
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Short getShort(int col) throws HibernateException;
+ public Short getShort(int col);
+
/**
- * Convenience method to read a byte
+ * Convenience method to read a byte.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a byte
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Byte getByte(int col) throws HibernateException;
+ public Byte getByte(int col);
+
/**
- * Convenience method to read a character
+ * Convenience method to read a char.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a char
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Character getCharacter(int col) throws HibernateException;
+ public Character getCharacter(int col);
+
/**
- * Convenience method to read a binary
+ * Convenience method to read a binary (byte[]).
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a binary (byte[])
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public byte[] getBinary(int col) throws HibernateException;
+ public byte[] getBinary(int col);
+
/**
- * Convenience method to read text
+ * Convenience method to read a String using streaming.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a String
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public String getText(int col) throws HibernateException;
+ public String getText(int col);
+
/**
- * Convenience method to read a blob
+ * Convenience method to read a blob.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a Blob
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Blob getBlob(int col) throws HibernateException;
+ public Blob getBlob(int col);
+
/**
- * Convenience method to read a clob
+ * Convenience method to read a clob.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a Clob
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Clob getClob(int col) throws HibernateException;
+ public Clob getClob(int col);
+
/**
- * Convenience method to read a string
+ * Convenience method to read a string.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a String
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public String getString(int col) throws HibernateException;
+ public String getString(int col);
+
/**
- * Convenience method to read a big_decimal
+ * Convenience method to read a BigDecimal.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a BigDecimal
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public BigDecimal getBigDecimal(int col) throws HibernateException;
+ public BigDecimal getBigDecimal(int col);
+
/**
- * Convenience method to read a big_integer
+ * Convenience method to read a BigInteger.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a BigInteger
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public BigInteger getBigInteger(int col) throws HibernateException;
+ public BigInteger getBigInteger(int col);
+
/**
- * Convenience method to read a date, time or timestamp
+ * Convenience method to read a Date.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a Date
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Date getDate(int col) throws HibernateException;
+ public Date getDate(int col);
+
/**
- * Convenience method to read a locale
+ * Convenience method to read a Locale.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a Locale
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Locale getLocale(int col) throws HibernateException;
+ public Locale getLocale(int col);
+
/**
- * Convenience method to read a calendar or calendar_date
+ * Convenience method to read a Calendar.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a Calendar
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- public Calendar getCalendar(int col) throws HibernateException;
+ public Calendar getCalendar(int col);
+
/**
- * Convenience method to read a currency
+ * Convenience method to read a TimeZone.
+ *
+ * @param col The column, numbered from zero
+ *
+ * @return The column value as a TimeZone
+ *
+ * @throws IndexOutOfBoundsException If col is an invalid index.
*/
- //public Currency getCurrency(int col) throws HibernateException;
- /**
- * Convenience method to read a timezone
- */
- public TimeZone getTimeZone(int col) throws HibernateException;
- /**
- * Get the current location in the result set. The first
- * row is number 0, contrary to JDBC.
- * @return the row number, numbered from 0, or -1 if
- * there is no current row
- */
- public int getRowNumber() throws HibernateException;
- /**
- * Set the current location in the result set, numbered from either the
- * first row (row number 0), or the last row (row
- * number -1).
- * @param rowNumber the row number, numbered from the last row, in the
- * case of a negative row number
- * @return true if there is a row at that row number
- */
- public boolean setRowNumber(int rowNumber) throws HibernateException;
+ public TimeZone getTimeZone(int col);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/Session.java b/hibernate-core/src/main/java/org/hibernate/Session.java
index 5acdb50533..15735425e7 100644
--- a/hibernate-core/src/main/java/org/hibernate/Session.java
+++ b/hibernate-core/src/main/java/org/hibernate/Session.java
@@ -565,6 +565,7 @@ public interface Session extends SharedSessionContract {
* with a session (LockMode.NONE). This operation cascades to associated
* instances if the association is mapped with cascade="lock".
*
+ * @param entityName The name of the entity
* @param object a persistent or transient instance
* @param lockMode the lock level
*
@@ -771,7 +772,7 @@ public interface Session extends SharedSessionContract {
public Object get(String entityName, Serializable id, LockOptions lockOptions);
/**
- * Return the entity name for a persistent entity
+ * Return the entity name for a persistent entity.
*
* @param object a persistent entity
*
@@ -932,6 +933,7 @@ public interface Session extends SharedSessionContract {
* execution returns the result of the {@link ReturningWork#execute} call.
*
* @param work The work to be performed.
+ * @param The type of the result returned from the work
*
* @return the result from calling {@link ReturningWork#execute}.
*
@@ -1020,7 +1022,15 @@ public interface Session extends SharedSessionContract {
* Contains locking details (LockMode, Timeout and Scope).
*/
public interface LockRequest {
+ /**
+ * Constant usable as a time out value that indicates no wait semantics should be used in
+ * attempting to acquire locks.
+ */
static final int PESSIMISTIC_NO_WAIT = 0;
+ /**
+ * Constant usable as a time out value that indicates that attempting to acquire locks should be allowed to
+ * wait forever (apply no timeout).
+ */
static final int PESSIMISTIC_WAIT_FOREVER = -1;
/**
@@ -1073,8 +1083,19 @@ public interface Session extends SharedSessionContract {
*/
LockRequest setScope(boolean scope);
- void lock(String entityName, Object object) throws HibernateException;
+ /**
+ * Perform the requested locking.
+ *
+ * @param entityName The name of the entity to lock
+ * @param object The instance of the entity to lock
+ */
+ void lock(String entityName, Object object);
- public void lock(Object object) throws HibernateException;
+ /**
+ * Perform the requested locking.
+ *
+ * @param object The instance of the entity to lock
+ */
+ void lock(Object object);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/SessionBuilder.java b/hibernate-core/src/main/java/org/hibernate/SessionBuilder.java
index ace9310773..6ef8941d74 100644
--- a/hibernate-core/src/main/java/org/hibernate/SessionBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/SessionBuilder.java
@@ -39,7 +39,7 @@ public interface SessionBuilder {
public Session openSession();
/**
- * Adds a specific interceptor to the session options
+ * Adds a specific interceptor to the session options.
*
* @param interceptor The interceptor to use.
*
@@ -61,7 +61,7 @@ public interface SessionBuilder {
public SessionBuilder noInterceptor();
/**
- * Adds a specific connection to the session options
+ * Adds a specific connection to the session options.
*
* @param connection The connection to use.
*
@@ -70,7 +70,7 @@ public interface SessionBuilder {
public SessionBuilder connection(Connection connection);
/**
- * Use a specific connection release mode for these session options
+ * Use a specific connection release mode for these session options.
*
* @param connectionReleaseMode The connection release mode to use.
*
@@ -79,7 +79,7 @@ public interface SessionBuilder {
public SessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode);
/**
- * Should the session built automatically join in any ongoing JTA transactions
+ * Should the session built automatically join in any ongoing JTA transactions.
*
* @param autoJoinTransactions Should JTA transactions be automatically joined
*
@@ -88,7 +88,7 @@ public interface SessionBuilder {
public SessionBuilder autoJoinTransactions(boolean autoJoinTransactions);
/**
- * Should the session be automatically closed after transaction completion
+ * Should the session be automatically closed after transaction completion.
*
* @param autoClose Should the session be automatically closed
*
diff --git a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
index 92935d3dad..42b6b49659 100644
--- a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
@@ -54,14 +54,33 @@ import org.hibernate.stat.Statistics;
* @author Steve Ebersole
*/
public interface SessionFactory extends Referenceable, Serializable {
-
+ /**
+ * Aggregator of special options used to build the SessionFactory.
+ */
public interface SessionFactoryOptions {
+ /**
+ * The service registry to use in building the factory.
+ *
+ * @return The service registry to use.
+ */
public StandardServiceRegistry getServiceRegistry();
+
+ /**
+ * Get the interceptor to use by default for all sessions opened from this factory.
+ *
+ * @return The interceptor to use factory wide. May be {@code null}
+ */
public Interceptor getInterceptor();
public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy();
public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver();
public SessionFactoryObserver[] getSessionFactoryObservers();
public EntityNameResolver[] getEntityNameResolvers();
+
+ /**
+ * Get the delegate for handling entity-not-found exception conditions.
+ *
+ * @return The specific EntityNotFoundDelegate to use, May be {@code null}
+ */
public EntityNotFoundDelegate getEntityNotFoundDelegate();
}
@@ -181,7 +200,7 @@ public interface SessionFactory extends Referenceable, Serializable {
public Map getAllClassMetadata();
/**
- * Get the {@link CollectionMetadata} for all mapped collections
+ * Get the {@link CollectionMetadata} for all mapped collections.
*
* @return a map from String to CollectionMetadata
*
@@ -381,7 +400,7 @@ public interface SessionFactory extends Referenceable, Serializable {
public boolean containsFetchProfileDefinition(String name);
/**
- * Retrieve this factory's {@link TypeHelper}
+ * Retrieve this factory's {@link TypeHelper}.
*
* @return The factory's {@link TypeHelper}
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/SessionFactoryObserver.java b/hibernate-core/src/main/java/org/hibernate/SessionFactoryObserver.java
index 2ccfefad38..2d22e5fb05 100644
--- a/hibernate-core/src/main/java/org/hibernate/SessionFactoryObserver.java
+++ b/hibernate-core/src/main/java/org/hibernate/SessionFactoryObserver.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,9 +20,9 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/SharedSessionBuilder.java b/hibernate-core/src/main/java/org/hibernate/SharedSessionBuilder.java
index dfadd06a3e..b814cfa696 100644
--- a/hibernate-core/src/main/java/org/hibernate/SharedSessionBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/SharedSessionBuilder.java
@@ -26,41 +26,41 @@ package org.hibernate;
import java.sql.Connection;
/**
- * Specialized {@link SessionBuilder} with access to stuff from another session
+ * Specialized {@link SessionBuilder} with access to stuff from another session.
*
* @author Steve Ebersole
*/
public interface SharedSessionBuilder extends SessionBuilder {
/**
- * Signifies the interceptor from the original session should be used to create the new session
+ * Signifies the interceptor from the original session should be used to create the new session.
*
* @return {@code this}, for method chaining
*/
public SharedSessionBuilder interceptor();
/**
- * Signifies that the connection from the original session should be used to create the new session
+ * Signifies that the connection from the original session should be used to create the new session.
*
* @return {@code this}, for method chaining
*/
public SharedSessionBuilder connection();
/**
- * Signifies that the connection release mode from the original session should be used to create the new session
+ * Signifies that the connection release mode from the original session should be used to create the new session.
*
* @return {@code this}, for method chaining
*/
public SharedSessionBuilder connectionReleaseMode();
/**
- * Signifies that the autoJoinTransaction flag from the original session should be used to create the new session
+ * Signifies that the autoJoinTransaction flag from the original session should be used to create the new session.
*
* @return {@code this}, for method chaining
*/
public SharedSessionBuilder autoJoinTransactions();
/**
- * Signifies that the autoClose flag from the original session should be used to create the new session
+ * Signifies that the autoClose flag from the original session should be used to create the new session.
*
* @return {@code this}, for method chaining
*
@@ -71,14 +71,14 @@ public interface SharedSessionBuilder extends SessionBuilder {
public SharedSessionBuilder autoClose();
/**
- * Signifies that the flushBeforeCompletion flag from the original session should be used to create the new session
+ * Signifies that the flushBeforeCompletion flag from the original session should be used to create the new session.
*
* @return {@code this}, for method chaining
*/
public SharedSessionBuilder flushBeforeCompletion();
/**
- * Signifies that the transaction context from the original session should be used to create the new session
+ * Signifies that the transaction context from the original session should be used to create the new session.
*
* @return {@code this}, for method chaining
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java
index cc3692194e..33f76243cf 100644
--- a/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java
+++ b/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java
@@ -28,7 +28,7 @@ import java.io.Serializable;
import org.hibernate.procedure.ProcedureCall;
/**
- * Contract methods shared between {@link Session} and {@link StatelessSession}
+ * Contract methods shared between {@link Session} and {@link StatelessSession}.
*
* @author Steve Ebersole
*/
@@ -107,7 +107,7 @@ public interface SharedSessionContract extends Serializable {
public ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses);
/**
- * Creates a call to a stored procedure with specific result set entity mappings
+ * Creates a call to a stored procedure with specific result set entity mappings.
*
* @param procedureName The name of the procedure.
* @param resultSetMappings The explicit result set mapping(s) to use for mapping the results
@@ -117,7 +117,7 @@ public interface SharedSessionContract extends Serializable {
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings);
/**
- * Create {@link Criteria} instance for the given class (entity or subclasses/implementors)
+ * Create {@link Criteria} instance for the given class (entity or subclasses/implementors).
*
* @param persistentClass The class, which is an entity, or has entity subclasses/implementors
*
diff --git a/hibernate-core/src/main/java/org/hibernate/SimpleNaturalIdLoadAccess.java b/hibernate-core/src/main/java/org/hibernate/SimpleNaturalIdLoadAccess.java
index 89900922a9..3cc6d544a1 100644
--- a/hibernate-core/src/main/java/org/hibernate/SimpleNaturalIdLoadAccess.java
+++ b/hibernate-core/src/main/java/org/hibernate/SimpleNaturalIdLoadAccess.java
@@ -24,7 +24,7 @@
package org.hibernate;
/**
- * Loads an entity by its natural identifier
+ * Loads an entity by its natural identifier.
*
* @author Eric Dalquist
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/StaleObjectStateException.java b/hibernate-core/src/main/java/org/hibernate/StaleObjectStateException.java
index a88cf688f7..e10ccd6cb2 100644
--- a/hibernate-core/src/main/java/org/hibernate/StaleObjectStateException.java
+++ b/hibernate-core/src/main/java/org/hibernate/StaleObjectStateException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,17 +20,16 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
import org.hibernate.pretty.MessageHelper;
/**
- * A StaleStateException that carries information
- * about a particular entity instance that was the source
- * of the failure.
+ * A specialized StaleStateException that carries information about the particular entity
+ * instance that was the source of the failure.
*
* @author Gavin King
*/
@@ -38,9 +37,15 @@ public class StaleObjectStateException extends StaleStateException {
private final String entityName;
private final Serializable identifier;
- public StaleObjectStateException(String persistentClass, Serializable identifier) {
+ /**
+ * Constructs a StaleObjectStateException using the supplied information.
+ *
+ * @param entityName The name of the entity
+ * @param identifier The identifier of the entity
+ */
+ public StaleObjectStateException(String entityName, Serializable identifier) {
super("Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)");
- this.entityName = persistentClass;
+ this.entityName = entityName;
this.identifier = identifier;
}
@@ -53,8 +58,7 @@ public class StaleObjectStateException extends StaleStateException {
}
public String getMessage() {
- return super.getMessage() + ": " +
- MessageHelper.infoString(entityName, identifier);
+ return super.getMessage() + " : " + MessageHelper.infoString( entityName, identifier );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/StaleStateException.java b/hibernate-core/src/main/java/org/hibernate/StaleStateException.java
index 43ecebae72..f7ace1a9f0 100755
--- a/hibernate-core/src/main/java/org/hibernate/StaleStateException.java
+++ b/hibernate-core/src/main/java/org/hibernate/StaleStateException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,26 +20,26 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
- * Thrown when a version number or timestamp check failed, indicating that the
- * Session contained stale data (when using long transactions
- * with versioning). Also occurs if we try delete or update a row that does
- * not exist.
- *
- * Note that this exception often indicates that the user failed to specify the
- * correct unsaved-value strategy for a class!
+ * Thrown when a version number or timestamp check failed, indicating that the Session contained
+ * stale data (when using long transactions with versioning). Also occurs if we try delete or update
+ * a row that does not exist.
+ *
+ * Note that this exception often indicates that the user failed to specify the correct
+ * {@code unsaved-value} strategy for an entity
*
- * @see StaleObjectStateException
* @author Gavin King
*/
public class StaleStateException extends HibernateException {
-
- public StaleStateException(String s) {
- super(s);
+ /**
+ * Constructs a StaleStateException using the supplied message.
+ *
+ * @param message The message explaining the exception condition
+ */
+ public StaleStateException(String message) {
+ super(message);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/StatelessSession.java b/hibernate-core/src/main/java/org/hibernate/StatelessSession.java
index a5732fcf3b..b6129c35ca 100755
--- a/hibernate-core/src/main/java/org/hibernate/StatelessSession.java
+++ b/hibernate-core/src/main/java/org/hibernate/StatelessSession.java
@@ -52,6 +52,8 @@ public interface StatelessSession extends SharedSessionContract {
* Insert a row.
*
* @param entity a new transient instance
+ *
+ * @return The identifier of the inserted entity
*/
public Serializable insert(Object entity);
@@ -60,6 +62,7 @@ public interface StatelessSession extends SharedSessionContract {
*
* @param entityName The entityName for the entity to be inserted
* @param entity a new transient instance
+ *
* @return the identifier of the instance
*/
public Serializable insert(String entityName, Object entity);
@@ -97,6 +100,9 @@ public interface StatelessSession extends SharedSessionContract {
/**
* Retrieve a row.
*
+ * @param entityName The name of the entity to retrieve
+ * @param id The id of the entity to retrieve
+ *
* @return a detached entity instance
*/
public Object get(String entityName, Serializable id);
@@ -104,6 +110,9 @@ public interface StatelessSession extends SharedSessionContract {
/**
* Retrieve a row.
*
+ * @param entityClass The class of the entity to retrieve
+ * @param id The id of the entity to retrieve
+ *
* @return a detached entity instance
*/
public Object get(Class entityClass, Serializable id);
@@ -111,6 +120,10 @@ public interface StatelessSession extends SharedSessionContract {
/**
* Retrieve a row, obtaining the specified lock mode.
*
+ * @param entityName The name of the entity to retrieve
+ * @param id The id of the entity to retrieve
+ * @param lockMode The lock mode to apply to the entity
+ *
* @return a detached entity instance
*/
public Object get(String entityName, Serializable id, LockMode lockMode);
@@ -118,6 +131,10 @@ public interface StatelessSession extends SharedSessionContract {
/**
* Retrieve a row, obtaining the specified lock mode.
*
+ * @param entityClass The class of the entity to retrieve
+ * @param id The id of the entity to retrieve
+ * @param lockMode The lock mode to apply to the entity
+ *
* @return a detached entity instance
*/
public Object get(Class entityClass, Serializable id, LockMode lockMode);
@@ -164,6 +181,8 @@ public interface StatelessSession extends SharedSessionContract {
* application should not close the connection.
*
* @deprecated just missed when deprecating same method from {@link Session}
+ *
+ * @return The connection associated with this stateless session
*/
@Deprecated
public Connection connection();
diff --git a/hibernate-core/src/main/java/org/hibernate/StatelessSessionBuilder.java b/hibernate-core/src/main/java/org/hibernate/StatelessSessionBuilder.java
index 5e735ef5b7..83343b4fd6 100644
--- a/hibernate-core/src/main/java/org/hibernate/StatelessSessionBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/StatelessSessionBuilder.java
@@ -39,7 +39,7 @@ public interface StatelessSessionBuilder {
public StatelessSession openStatelessSession();
/**
- * Adds a specific connection to the session options
+ * Adds a specific connection to the session options.
*
* @param connection The connection to use.
*
diff --git a/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java b/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java
index fa8239dd6a..560b1adfd8 100644
--- a/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java
+++ b/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java
@@ -26,26 +26,30 @@ package org.hibernate;
import java.util.Collection;
/**
+ * A unifying interface for queries which can define tables (query spaces) to synchronize on.
+ *
+ * These query spaces affect the process of auto-flushing by determining which entities will be
+ * processed by auto-flush based on the table to which those entities are mapped and which are
+ * determined to have pending state changes.
+ *
+ * In a similar manner, these query spaces also affect how query result caching can recognize invalidated results.
+ *
* @author Steve Ebersole
*/
public interface SynchronizeableQuery {
/**
- * Obtain the list of query spaces (table names) the query is synchronized on. These spaces affect the process
- * of auto-flushing by determining which entities will be processed by auto-flush based on the table to
- * which those entities are mapped and which are determined to have pending state changes.
+ * Obtain the list of query spaces the query is synchronized on.
*
* @return The list of query spaces upon which the query is synchronized.
*/
public Collection getSynchronizedQuerySpaces();
/**
- * Adds a query space (table name) for (a) auto-flush checking and (b) query result cache invalidation checking
+ * Adds a query space.
*
* @param querySpace The query space to be auto-flushed for this query.
*
- * @return this, for method chaining
- *
- * @see #getSynchronizedQuerySpaces()
+ * @return {@code this}, for method chaining
*/
public SynchronizeableQuery addSynchronizedQuerySpace(String querySpace);
@@ -55,11 +59,9 @@ public interface SynchronizeableQuery {
*
* @param entityName The name of the entity upon whose defined query spaces we should additionally synchronize.
*
- * @return this, for method chaining
+ * @return {@code this}, for method chaining
*
* @throws MappingException Indicates the given name could not be resolved as an entity
- *
- * @see #getSynchronizedQuerySpaces()
*/
public SynchronizeableQuery addSynchronizedEntityName(String entityName) throws MappingException;
@@ -69,11 +71,9 @@ public interface SynchronizeableQuery {
*
* @param entityClass The class of the entity upon whose defined query spaces we should additionally synchronize.
*
- * @return this, for method chaining
+ * @return {@code this}, for method chaining
*
* @throws MappingException Indicates the given class could not be resolved as an entity
- *
- * @see #getSynchronizedQuerySpaces()
*/
public SynchronizeableQuery addSynchronizedEntityClass(Class entityClass) throws MappingException;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/TransactionException.java b/hibernate-core/src/main/java/org/hibernate/TransactionException.java
index 6982d8ae06..61a2bb11e5 100644
--- a/hibernate-core/src/main/java/org/hibernate/TransactionException.java
+++ b/hibernate-core/src/main/java/org/hibernate/TransactionException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,25 +20,31 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
* Indicates that a transaction could not be begun, committed
* or rolled back.
*
- * @see Transaction
* @author Anton van Straaten
*/
-
public class TransactionException extends HibernateException {
-
- public TransactionException(String message, Throwable root) {
- super(message,root);
+ /**
+ * Constructs a TransactionException using the specified information.
+ *
+ * @param message The message explaining the exception condition
+ * @param cause The underlying cause
+ */
+ public TransactionException(String message, Throwable cause) {
+ super(message,cause);
}
+ /**
+ * Constructs a TransactionException using the specified information.
+ *
+ * @param message The message explaining the exception condition
+ */
public TransactionException(String message) {
super(message);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/TransientObjectException.java b/hibernate-core/src/main/java/org/hibernate/TransientObjectException.java
index c20a7ce20a..f51070a552 100644
--- a/hibernate-core/src/main/java/org/hibernate/TransientObjectException.java
+++ b/hibernate-core/src/main/java/org/hibernate/TransientObjectException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,22 +20,22 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
- * Thrown when the user passes a transient instance to a Session
- * method that expects a persistent instance.
+ * Thrown when the user passes a transient instance to a Session method that expects a persistent instance.
*
* @author Gavin King
*/
-
public class TransientObjectException extends HibernateException {
-
- public TransientObjectException(String s) {
- super(s);
+ /**
+ * Constructs a TransientObjectException using the supplied message.
+ *
+ * @param message The message explaining the exception condition
+ */
+ public TransientObjectException(String message) {
+ super(message);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/TransientPropertyValueException.java b/hibernate-core/src/main/java/org/hibernate/TransientPropertyValueException.java
index da3deb59e8..eec3347269 100644
--- a/hibernate-core/src/main/java/org/hibernate/TransientPropertyValueException.java
+++ b/hibernate-core/src/main/java/org/hibernate/TransientPropertyValueException.java
@@ -82,18 +82,9 @@ public class TransientPropertyValueException extends TransientObjectException {
return propertyName;
}
-
- /**
- * Return the exception message.
- * @return the exception message.
- */
@Override
public String getMessage() {
- return new StringBuilder( super.getMessage() )
- .append( ": " )
- .append( StringHelper.qualify( propertyOwnerEntityName, propertyName ) )
- .append( " -> " )
- .append( transientEntityName )
- .toString();
+ return super.getMessage() + " : "
+ + StringHelper.qualify( propertyOwnerEntityName, propertyName ) + " -> " + transientEntityName;
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/TypeHelper.java b/hibernate-core/src/main/java/org/hibernate/TypeHelper.java
index a76b2bd512..e70b04e1f6 100644
--- a/hibernate-core/src/main/java/org/hibernate/TypeHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/TypeHelper.java
@@ -107,5 +107,13 @@ public interface TypeHelper {
*/
public Type custom(Class userTypeClass, Properties properties);
+ /**
+ * Retrieve the type representing an ANY mapping.
+ *
+ * @param metaType The meta type for the ANY
+ * @param identifierType The identifier type for the ANY
+ *
+ * @return The type, or null
+ */
public Type any(Type metaType, Type identifierType);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/TypeMismatchException.java b/hibernate-core/src/main/java/org/hibernate/TypeMismatchException.java
index a72fe40d60..394c3ec8c0 100644
--- a/hibernate-core/src/main/java/org/hibernate/TypeMismatchException.java
+++ b/hibernate-core/src/main/java/org/hibernate/TypeMismatchException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,26 +20,21 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
-package org.hibernate;
-
+package org.hibernate;
/**
- * Used when a user provided type does not match the expected one
+ * Used when a user provided type does not match the expected one.
*
* @author Emmanuel Bernard
*/
public class TypeMismatchException extends HibernateException {
- public TypeMismatchException(Throwable root) {
- super( root );
- }
-
- public TypeMismatchException(String s) {
- super( s );
- }
-
- public TypeMismatchException(String string, Throwable root) {
- super( string, root );
+ /**
+ * Constructs a TypeMismatchException using the supplied message.
+ *
+ * @param message The message explaining the exception condition
+ */
+ public TypeMismatchException(String message) {
+ super( message );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java b/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java
index 20cf6cc02b..7055efce9a 100644
--- a/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java
+++ b/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,11 +20,9 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
-
/**
* Used to indicate a request against an unknown profile name.
*
@@ -33,6 +31,11 @@ package org.hibernate;
public class UnknownProfileException extends HibernateException {
private final String name;
+ /**
+ * Constructs an UnknownProfileException for the given name.
+ *
+ * @param name The profile name that was unknown.
+ */
public UnknownProfileException(String name) {
super( "Unknow fetch profile [" + name + "]" );
this.name = name;
diff --git a/hibernate-core/src/main/java/org/hibernate/UnresolvableObjectException.java b/hibernate-core/src/main/java/org/hibernate/UnresolvableObjectException.java
index b9dd9b6221..1d19e27b5a 100644
--- a/hibernate-core/src/main/java/org/hibernate/UnresolvableObjectException.java
+++ b/hibernate-core/src/main/java/org/hibernate/UnresolvableObjectException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,9 +20,9 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
import org.hibernate.pretty.MessageHelper;
@@ -34,34 +34,53 @@ import org.hibernate.pretty.MessageHelper;
* @author Gavin King
*/
public class UnresolvableObjectException extends HibernateException {
-
private final Serializable identifier;
private final String entityName;
- public UnresolvableObjectException(Serializable identifier, String clazz) {
- this("No row with the given identifier exists", identifier, clazz);
+ /**
+ * Constructs an UnresolvableObjectException using the specified information.
+ *
+ * @param identifier The identifier of the entity which could not be resolved
+ * @param entityName The name of the entity which could not be resolved
+ */
+ public UnresolvableObjectException(Serializable identifier, String entityName) {
+ this( "No row with the given identifier exists", identifier, entityName );
}
- UnresolvableObjectException(String message, Serializable identifier, String clazz) {
+
+ protected UnresolvableObjectException(String message, Serializable identifier, String clazz) {
super(message);
this.identifier = identifier;
this.entityName = clazz;
}
- public Serializable getIdentifier() {
- return identifier;
+
+ /**
+ * Factory method for building and throwing an UnresolvableObjectException if the entity is null.
+ *
+ * @param entity The entity to check for nullness
+ * @param identifier The identifier of the entity
+ * @param entityName The name of the entity
+ *
+ * @throws UnresolvableObjectException Thrown if entity is null
+ */
+ public static void throwIfNull(Object entity, Serializable identifier, String entityName)
+ throws UnresolvableObjectException {
+ if ( entity == null ) {
+ throw new UnresolvableObjectException( identifier, entityName );
+ }
}
- public String getMessage() {
- return super.getMessage() + ": " +
- MessageHelper.infoString(entityName, identifier);
+ public Serializable getIdentifier() {
+ return identifier;
}
public String getEntityName() {
return entityName;
}
- public static void throwIfNull(Object o, Serializable id, String clazz)
- throws UnresolvableObjectException {
- if (o==null) throw new UnresolvableObjectException(id, clazz);
+ @Override
+ public String getMessage() {
+ return super.getMessage() + ": " +
+ MessageHelper.infoString(entityName, identifier);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/Version.java b/hibernate-core/src/main/java/org/hibernate/Version.java
index 93a422651c..84581bad5a 100644
--- a/hibernate-core/src/main/java/org/hibernate/Version.java
+++ b/hibernate-core/src/main/java/org/hibernate/Version.java
@@ -33,14 +33,33 @@ import org.hibernate.internal.CoreMessageLogger;
* @author Steve Ebersole
*/
public class Version {
+ private Version() {
+ }
+
+ /**
+ * Access to the Hibernate version.
+ *
+ * IMPL NOTE : Real value is injected by the build.
+ *
+ * @return The Hibernate version
+ */
public static String getVersionString() {
return "[WORKING]";
}
+ /**
+ * Logs the Hibernate version (using {@link #getVersionString()}) to the logging system.
+ */
public static void logVersion() {
Logger.getMessageLogger( CoreMessageLogger.class, Version.class.getName() ).version( getVersionString() );
}
+ /**
+ * Prints the Hibernate version (using {@link #getVersionString()}) to SYSOUT. Defined as the main-class in
+ * the hibernate-core jar
+ *
+ * @param args n/a
+ */
public static void main(String[] args) {
System.out.println( "Hibernate Core {" + getVersionString() + "}" );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/WrongClassException.java b/hibernate-core/src/main/java/org/hibernate/WrongClassException.java
index 6946fea3b2..9df2d95e95 100644
--- a/hibernate-core/src/main/java/org/hibernate/WrongClassException.java
+++ b/hibernate-core/src/main/java/org/hibernate/WrongClassException.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,50 +20,47 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate;
+
import java.io.Serializable;
/**
- * Thrown when Session.load() selects a row with
- * the given primary key (identifier value) but the row's
- * discriminator value specifies a subclass that is not
- * assignable to the class requested by the user.
+ * Thrown when loading an entity (by identifier) results in a value that cannot be treated as the subclass
+ * type requested by the caller.
*
* @author Gavin King
*/
public class WrongClassException extends HibernateException {
-
private final Serializable identifier;
private final String entityName;
- public WrongClassException(String msg, Serializable identifier, String clazz) {
- super(msg);
+ /**
+ * Constructs a WrongClassException using the supplied information.
+ *
+ * @param message A message explaining the exception condition
+ * @param identifier The identifier of the entity
+ * @param entityName The entity-type requested
+ */
+ public WrongClassException(String message, Serializable identifier, String entityName) {
+ super(
+ String.format(
+ "Object [id=%s] was not of the specified subclass [%s] : %s",
+ identifier,
+ entityName,
+ message
+ )
+ );
this.identifier = identifier;
- this.entityName = clazz;
- }
- public Serializable getIdentifier() {
- return identifier;
- }
-
- public String getMessage() {
- return "Object with id: " +
- identifier +
- " was not of the specified subclass: " +
- entityName +
- " (" + super.getMessage() + ")" ;
+ this.entityName = entityName;
}
public String getEntityName() {
return entityName;
}
+ public Serializable getIdentifier() {
+ return identifier;
+ }
}
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java b/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java
index 09b694ea1d..e6e18e9acf 100644
--- a/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java
+++ b/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java
@@ -204,11 +204,13 @@ public class UnresolvedEntityInsertActions {
if ( entityEntry.getStatus() != Status.MANAGED && entityEntry.getStatus() != Status.READ_ONLY ) {
throw new IllegalArgumentException( "EntityEntry did not have status MANAGED or READ_ONLY: " + entityEntry );
}
+
+ final boolean traceEnabled = LOG.isTraceEnabled();
// Find out if there are any unresolved insertions that are waiting for the
// specified entity to be resolved.
Set dependentActions = dependentActionsByTransientEntity.remove( managedEntity );
if ( dependentActions == null ) {
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev(
"No unresolved entity inserts that depended on [{0}]",
MessageHelper.infoString( entityEntry.getEntityName(), entityEntry.getId() )
@@ -217,7 +219,7 @@ public class UnresolvedEntityInsertActions {
return Collections.emptySet(); //NOTE EARLY EXIT!
}
Set resolvedActions = new IdentitySet( );
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev(
"Unresolved inserts before resolving [{0}]: [{1}]",
MessageHelper.infoString( entityEntry.getEntityName(), entityEntry.getId() ),
@@ -225,7 +227,7 @@ public class UnresolvedEntityInsertActions {
);
}
for ( AbstractEntityInsertAction dependentAction : dependentActions ) {
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev(
"Resolving insert [{0}] dependency on [{1}]",
MessageHelper.infoString( dependentAction.getEntityName(), dependentAction.getId() ),
@@ -235,7 +237,7 @@ public class UnresolvedEntityInsertActions {
NonNullableTransientDependencies dependencies = dependenciesByAction.get( dependentAction );
dependencies.resolveNonNullableTransientEntity( managedEntity );
if ( dependencies.isEmpty() ) {
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev(
"Resolving insert [{0}] (only depended on [{1}])",
dependentAction,
@@ -247,7 +249,7 @@ public class UnresolvedEntityInsertActions {
resolvedActions.add( dependentAction );
}
}
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev(
"Unresolved inserts after resolving [{0}]: [{1}]",
MessageHelper.infoString( entityEntry.getEntityName(), entityEntry.getId() ),
diff --git a/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java b/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java
index d44c3b4f96..737544c69f 100644
--- a/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java
+++ b/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java
@@ -28,9 +28,8 @@ import java.io.Serializable;
import org.hibernate.HibernateException;
/**
- * An operation which may be scheduled for later execution.
- * Usually, the operation is a database insert/update/delete,
- * together with required second-level cache management.
+ * An operation which may be scheduled for later execution. Usually, the operation is a database
+ * insert/update/delete, together with required second-level cache management.
*
* @author Gavin King
* @author Steve Ebersole
@@ -51,7 +50,7 @@ public interface Executable {
public void beforeExecutions() throws HibernateException;
/**
- * Execute this action
+ * Execute this action.
*
* @throws HibernateException Indicates a problem during execution.
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/action/spi/package-info.java b/hibernate-core/src/main/java/org/hibernate/action/spi/package-info.java
new file mode 100644
index 0000000000..b364028e4c
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/action/spi/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * Defines SPI hooks into the {@link org.hibernate.engine.spi.ActionQueue}. Mainly for registering custom
+ * {@link AfterTransactionCompletionProcess} and {@link BeforeTransactionCompletionProcess} hooks.
+ */
+package org.hibernate.action.spi;
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java b/hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java
index af2e72b8ca..94c5eb0329 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,9 +32,8 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Property Access type
- *
- * Prefer the standard {@link javax.persistence.Access} annotation
+ * Property Access type. Prefer the standard {@link javax.persistence.Access} annotation; however,
+ * {@code @Access} is limited to field/property access definitions.
*
* @author Emmanuel Bernard
*
@@ -44,5 +44,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Deprecated
public @interface AccessType {
+ /**
+ * The access strategy name.
+ */
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDef.java b/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDef.java
index e7cac8a031..6df8303ec1 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDef.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDef.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import static java.lang.annotation.ElementType.FIELD;
@@ -42,8 +43,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention( RUNTIME )
public @interface AnyMetaDef {
/**
- * If defined, assign a global meta definition name to be used in an @Any or @ManyToAny annotation
- * If not defined, the metadata applies to the current property or field
+ * If defined, assign a global meta definition name to be used in an @Any or @ManyToAny annotation. If
+ * not defined, the metadata applies to the current property or field.
*/
String name() default "";
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDefs.java b/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDefs.java
index 0de690efa7..6db78268da 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDefs.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/AnyMetaDefs.java
@@ -38,5 +38,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@java.lang.annotation.Target( { PACKAGE, TYPE } )
@Retention( RUNTIME )
public @interface AnyMetaDefs {
+ /**
+ * The collective set of any meta-defs.
+ */
AnyMetaDef[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/AttributeAccessor.java b/hibernate-core/src/main/java/org/hibernate/annotations/AttributeAccessor.java
index 32991f4865..0b33363101 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/AttributeAccessor.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/AttributeAccessor.java
@@ -55,7 +55,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface AttributeAccessor {
/**
- * Names the {@link org.hibernate.property.PropertyAccessor} strategy
+ * Names the {@link org.hibernate.property.PropertyAccessor} strategy.
*/
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/BatchSize.java b/hibernate-core/src/main/java/org/hibernate/annotations/BatchSize.java
index 414af5199c..49c3e625ef 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/BatchSize.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/BatchSize.java
@@ -56,7 +56,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface BatchSize {
/**
- * Strictly positive integer
+ * Strictly positive integer.
*/
int size();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Cache.java b/hibernate-core/src/main/java/org/hibernate/annotations/Cache.java
index d388c68548..4f94be82be 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Cache.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Cache.java
@@ -32,7 +32,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Add caching strategy to a root entity or a collection
+ * Add caching strategy to a root entity or a collection.
*
* @author Emmanuel Bernard
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CacheConcurrencyStrategy.java b/hibernate-core/src/main/java/org/hibernate/annotations/CacheConcurrencyStrategy.java
index 10d15d2384..ab2c26aaa6 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/CacheConcurrencyStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CacheConcurrencyStrategy.java
@@ -26,15 +26,38 @@ package org.hibernate.annotations;
import org.hibernate.cache.spi.access.AccessType;
/**
- * Cache concurrency strategy
+ * Cache concurrency strategy.
*
* @author Emmanuel Bernard
*/
public enum CacheConcurrencyStrategy {
+ /**
+ * Indicates no concurrency strategy should be applied.
+ */
NONE( null ),
+ /**
+ * Indicates that read-only strategy should be applied.
+ *
+ * @see AccessType#READ_ONLY
+ */
READ_ONLY( AccessType.READ_ONLY ),
+ /**
+ * Indicates that the non-strict read-write strategy should be applied.
+ *
+ * @see AccessType#NONSTRICT_READ_WRITE
+ */
NONSTRICT_READ_WRITE( AccessType.NONSTRICT_READ_WRITE ),
+ /**
+ * Indicates that the read-write strategy should be applied.
+ *
+ * @see AccessType#READ_WRITE
+ */
READ_WRITE( AccessType.READ_WRITE ),
+ /**
+ * Indicates that the transaction strategy should be applied.
+ *
+ * @see AccessType#TRANSACTIONAL
+ */
TRANSACTIONAL( AccessType.TRANSACTIONAL );
private final AccessType accessType;
@@ -43,13 +66,26 @@ public enum CacheConcurrencyStrategy {
this.accessType = accessType;
}
- private boolean isMatch(String name) {
- return ( accessType != null && accessType.getExternalName().equalsIgnoreCase( name ) )
- || name().equalsIgnoreCase( name );
+ /**
+ * Get the AccessType corresponding to this concurrency strategy.
+ *
+ * @return The corresponding concurrency strategy. Note that this will return {@code null} for
+ * {@link #NONE}
+ */
+ public AccessType toAccessType() {
+ return accessType;
}
+ /**
+ * Conversion from {@link AccessType} to {@link CacheConcurrencyStrategy}.
+ *
+ * @param accessType The access type to convert
+ *
+ * @return The corresponding enum value. {@link #NONE} is returned by default if unable to
+ * recognize {@code accessType} or if {@code accessType} is {@code null}.
+ */
public static CacheConcurrencyStrategy fromAccessType(AccessType accessType) {
- if (null == accessType) {
+ if ( null == accessType ) {
return NONE;
}
@@ -72,6 +108,13 @@ public enum CacheConcurrencyStrategy {
}
}
+ /**
+ * Parse an external representation of a CacheConcurrencyStrategy value.
+ *
+ * @param name The external representation
+ *
+ * @return The corresponding enum value, or {@code null} if not match was found.
+ */
public static CacheConcurrencyStrategy parse(String name) {
if ( READ_ONLY.isMatch( name ) ) {
return READ_ONLY;
@@ -93,7 +136,8 @@ public enum CacheConcurrencyStrategy {
}
}
- public AccessType toAccessType() {
- return accessType;
+ private boolean isMatch(String name) {
+ return ( accessType != null && accessType.getExternalName().equalsIgnoreCase( name ) )
+ || name().equalsIgnoreCase( name );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CacheModeType.java b/hibernate-core/src/main/java/org/hibernate/annotations/CacheModeType.java
index bd35ba9dec..d9fa888121 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/CacheModeType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CacheModeType.java
@@ -23,6 +23,7 @@
*/
package org.hibernate.annotations;
+import org.hibernate.CacheMode;
/**
* Enumeration for the different interaction modes between the session and
@@ -31,11 +32,83 @@ package org.hibernate.annotations;
* @author Emmanuel Bernard
* @author Carlos Gonzalez-Cadenas
*/
-
public enum CacheModeType {
- GET,
- IGNORE,
- NORMAL,
- PUT,
- REFRESH
-}
\ No newline at end of file
+ /**
+ * Corresponds to {@link CacheMode#GET}.
+ *
+ * @see CacheMode#GET
+ */
+ GET( CacheMode.GET ),
+
+ /**
+ * Corresponds to {@link CacheMode#IGNORE}.
+ *
+ * @see CacheMode#IGNORE
+ */
+ IGNORE( CacheMode.IGNORE ),
+
+ /**
+ * Corresponds to {@link CacheMode#NORMAL}.
+ *
+ * @see CacheMode#NORMAL
+ */
+ NORMAL( CacheMode.NORMAL ),
+
+ /**
+ * Corresponds to {@link CacheMode#PUT}.
+ *
+ * @see CacheMode#PUT
+ */
+ PUT( CacheMode.PUT ),
+
+ /**
+ * Corresponds to {@link CacheMode#REFRESH}.
+ *
+ * @see CacheMode#REFRESH
+ */
+ REFRESH( CacheMode.REFRESH );
+
+ private final CacheMode cacheMode;
+
+ private CacheModeType(CacheMode cacheMode) {
+ this.cacheMode = cacheMode;
+ }
+
+ public CacheMode getCacheMode() {
+ return cacheMode;
+ }
+
+ /**
+ * Conversion from {@link CacheMode} to {@link CacheModeType}.
+ *
+ * @param cacheMode The cache mode to convert
+ *
+ * @return The corresponding enum value. Will be {@code null} if the given {@code accessType} is {@code null}.
+ */
+ public static CacheModeType fromCacheMode(CacheMode cacheMode) {
+ if ( null == cacheMode ) {
+ return null;
+ }
+
+ switch ( cacheMode ) {
+ case NORMAL: {
+ return NORMAL;
+ }
+ case GET: {
+ return GET;
+ }
+ case PUT: {
+ return PUT;
+ }
+ case REFRESH: {
+ return REFRESH;
+ }
+ case IGNORE: {
+ return IGNORE;
+ }
+ default: {
+ throw new IllegalArgumentException( "Unrecognized CacheMode : " + cacheMode );
+ }
+ }
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Cascade.java b/hibernate-core/src/main/java/org/hibernate/annotations/Cascade.java
index 406adb7948..1c5f35d895 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Cascade.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Cascade.java
@@ -40,5 +40,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface Cascade {
+ /**
+ * The cascade value.
+ */
CascadeType[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java b/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java
index 2767b824c2..96ad7ec1f7 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java
@@ -23,25 +23,62 @@
*/
package org.hibernate.annotations;
-
/**
- * Cascade types (can override default JPA cascades
+ * Cascade types (can override default JPA cascades).
*/
public enum CascadeType {
+ /**
+ * Includes all types listed here.
+ */
ALL,
+ /**
+ * Corresponds to {@link javax.persistence.CascadeType#PERSIST}.
+ */
PERSIST,
+ /**
+ * Corresponds to {@link javax.persistence.CascadeType#MERGE}.
+ */
MERGE,
+ /**
+ * Corresponds to {@link javax.persistence.CascadeType#REMOVE}.
+ */
REMOVE,
+ /**
+ * Corresponds to {@link javax.persistence.CascadeType#REFRESH}.
+ */
REFRESH,
+ /**
+ * Corresponds to the Hibernate native DELETE action.
+ */
DELETE,
+ /**
+ * Corresponds to the Hibernate native SAVE_UPDATE (direct reattachment) action.
+ */
SAVE_UPDATE,
+ /**
+ * Corresponds to the Hibernate native REPLICATE action.
+ */
REPLICATE,
- /** @deprecated use @OneToOne(orphanRemoval=true) or @OneToMany(orphanRemoval=true) */
+ /**
+ * Hibernate originally handled orphan removal as a specialized cascade.
+ *
+ * @deprecated use @OneToOne(orphanRemoval=true) or @OneToMany(orphanRemoval=true)
+ */
@Deprecated
DELETE_ORPHAN,
+ /**
+ * Corresponds to the Hibernate native LOCK action.
+ */
LOCK,
- /** @deprecated use javax.persistence.CascadeType.DETACH */
+ /**
+ * JPA originally planned on calling DETACH EVICT.
+ *
+ * @deprecated use javax.persistence.CascadeType.DETACH
+ */
@Deprecated
EVICT,
+ /**
+ * Corresponds to {@link javax.persistence.CascadeType#REFRESH}.
+ */
DETACH
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Check.java b/hibernate-core/src/main/java/org/hibernate/annotations/Check.java
index 8230af6e35..447fa56687 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Check.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Check.java
@@ -32,12 +32,15 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Arbitrary SQL CHECK constraints which can be defined at the class, property or collection level
+ * Arbitrary SQL CHECK constraints which can be defined at the class, property or collection level.
*
* @author Emmanuel Bernard
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
public @interface Check {
+ /**
+ * The check constraints string.
+ */
String constraints();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java
index 54aee08fa8..37b2fdd0fc 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.persistence.Column;
@@ -31,7 +32,8 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Describe an identifier column for a bag (ie an idbag)
+ * Describe an identifier column for a bag (ie an idbag).
+ *
* EXPERIMENTAL: the structure of this annotation might slightly change (generator() mix strategy and generator
*
* @author Emmanuel Bernard
@@ -39,10 +41,18 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface CollectionId {
- /** Collection id column(s) */
+ /**
+ * Collection id column(s).
+ */
Column[] columns();
- /** id type, type.type() must be set */
+
+ /**
+ * id type, type.type() must be set.
+ */
Type type();
- /** generator name: 'identity' or a defined generator name */
+
+ /**
+ * The generator name. For example 'identity' or a defined generator name
+ */
String generator();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionType.java b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionType.java
index 5bbe42d538..31c5c759f4 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionType.java
@@ -42,11 +42,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface CollectionType {
/**
- * Names the type (either {@link org.hibernate.type.CollectionType} or
- * {@link org.hibernate.usertype.UserCollectionType} implementation class. Could also name a
- * custom type defined via a {@link TypeDef @TypeDef}
- *
- * @return The implementation class to use.
+ * Names the type.
+ *
+ * Could name the implementation class (an implementation of {@link org.hibernate.type.CollectionType} or
+ * {@link org.hibernate.usertype.UserCollectionType}). Could also name a custom type defined via a
+ * {@link TypeDef @TypeDef}
*/
String type();
@@ -54,8 +54,6 @@ public @interface CollectionType {
* Specifies configuration information for the type. Note that if the named type is a
* {@link org.hibernate.usertype.UserCollectionType}, it must also implement
* {@link org.hibernate.usertype.ParameterizedType} in order to receive these values.
- *
- * @return The configuration parameters.
*/
Parameter[] parameters() default {};
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java b/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java
index 0d9c1c4486..870215a734 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java
@@ -43,20 +43,20 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface ColumnTransformer {
/**
- * (Logical) column name for which the expression is used
+ * (Logical) column name for which the expression is used.
*
* This can be left out if the property is bound to a single column
*/
String forColumn() default "";
/**
- * Custom SQL expression used to read from the column
+ * Custom SQL expression used to read from the column.
*/
String read() default "";
/**
- * Custom SQL expression used to write to the column.
- * The write expression must contain exactly one '?' placeholder for the value.
+ * Custom SQL expression used to write to the column. The write expression must contain exactly
+ * one '?' placeholder for the value.
*/
String write() default "";
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformers.java b/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformers.java
index 6bd9681fe5..1d86d24b50 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformers.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformers.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import static java.lang.annotation.ElementType.FIELD;
@@ -37,5 +38,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@java.lang.annotation.Target({FIELD,METHOD})
@Retention(RUNTIME)
public @interface ColumnTransformers {
+ /**
+ * The aggregated transformers.
+ */
ColumnTransformer[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Columns.java b/hibernate-core/src/main/java/org/hibernate/annotations/Columns.java
index 2e597074a5..28c70acdd4 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Columns.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Columns.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.persistence.Column;
@@ -38,5 +39,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface Columns {
+ /**
+ * The aggregated columns.
+ */
Column[] columns();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorFormula.java b/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorFormula.java
index c272298480..7020c4df8d 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorFormula.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorFormula.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -42,5 +43,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE})
@Retention(RUNTIME)
public @interface DiscriminatorFormula {
+ /**
+ * The formula string.
+ */
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorOptions.java b/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorOptions.java
index 3a1c2da57d..8d9888cc26 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorOptions.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/DiscriminatorOptions.java
@@ -38,18 +38,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface DiscriminatorOptions {
/**
- * "Forces" Hibernate to specify the allowed discriminator values, even when retrieving all instances of the root class.
- *
- * @return {@code true} in case the discriminator value should be forces, {@code false} otherwise. Default is {@code false}.
+ * "Forces" Hibernate to specify the allowed discriminator values, even when retrieving all instances of
+ * the root class. {@code true} indicates that the discriminator value should be forced; Default is
+ * {@code false}.
*/
boolean force() default false;
/**
- * Set this to {@code false}, if your discriminator column is also part of a mapped composite identifier.
- * It tells Hibernate not to include the column in SQL INSERTs.
- *
- * @return {@code true} in case the discriminator value should be included in inserts, {@code false} otherwise.
- * Default is {@code true}.
+ * Set this to {@code false} if your discriminator column is also part of a mapped composite identifier.
+ * It tells Hibernate not to include the column in SQL INSERTs. Default is {@code true}.
*/
boolean insert() default true;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/DynamicInsert.java b/hibernate-core/src/main/java/org/hibernate/annotations/DynamicInsert.java
index 11446e8725..730a98844c 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/DynamicInsert.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/DynamicInsert.java
@@ -38,5 +38,9 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target( TYPE )
@Retention( RUNTIME )
public @interface DynamicInsert {
+ /**
+ * Should dynamic insertion be used for this entity? {@code true} says dynamic insertion will be used.
+ * Default is {@code true} (since generally this annotation is not used unless the user wants dynamic insertion).
+ */
boolean value() default true;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/DynamicUpdate.java b/hibernate-core/src/main/java/org/hibernate/annotations/DynamicUpdate.java
index b873ce9974..66297af5e9 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/DynamicUpdate.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/DynamicUpdate.java
@@ -42,5 +42,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target( TYPE )
@Retention( RUNTIME )
public @interface DynamicUpdate {
+ /**
+ * Should dynamic update generation be used for this entity? {@code true} says the update sql will be dynamic
+ * generated. Default is {@code true} (since generally this annotation is not used unless the user wants dynamic
+ * generation).
+ */
boolean value() default true;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Entity.java b/hibernate-core/src/main/java/org/hibernate/annotations/Entity.java
new file mode 100644
index 0000000000..00527d5092
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Entity.java
@@ -0,0 +1,86 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Extends {@link javax.persistence.Entity} with Hibernate features.
+ *
+ * @author Emmanuel Bernard
+ *
+ * @deprecated See individual attributes for intended replacements. To be removed in 4.1
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+@Deprecated
+public @interface Entity {
+ /**
+ * Is this entity mutable (read only) or not.
+ *
+ * @deprecated use {@link org.hibernate.annotations.Immutable}
+ */
+ @Deprecated
+ boolean mutable() default true;
+ /**
+ * Needed column only in SQL on insert.
+ * @deprecated use {@link DynamicInsert} instead
+ */
+ @Deprecated
+ boolean dynamicInsert() default false;
+ /**
+ * Needed column only in SQL on update.
+ * @deprecated Use {@link DynamicUpdate} instead
+ */
+ @Deprecated
+ boolean dynamicUpdate() default false;
+ /**
+ * Do a select to retrieve the entity before any potential update.
+ * @deprecated Use {@link SelectBeforeUpdate} instead
+ */
+ @Deprecated
+ boolean selectBeforeUpdate() default false;
+ /**
+ * polymorphism strategy for this entity.
+ * @deprecated use {@link Polymorphism} instead
+ */
+ @Deprecated
+ PolymorphismType polymorphism() default PolymorphismType.IMPLICIT;
+ /**
+ * optimistic locking strategy.
+ * @deprecated use {@link OptimisticLocking} instead.
+ */
+ @Deprecated
+ OptimisticLockType optimisticLock() default OptimisticLockType.VERSION;
+ /**
+ * persister of this entity, default is hibernate internal one.
+ * @deprecated use {@link Persister} instead
+ */
+ @Deprecated
+ String persister() default "";
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Fetch.java b/hibernate-core/src/main/java/org/hibernate/annotations/Fetch.java
index afbeaa5ec6..598033e26e 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Fetch.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Fetch.java
@@ -21,19 +21,23 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
+package org.hibernate.annotations;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Define the fetching strategy used for the given association
+ * Define the fetching strategy used for the given association.
*
* @author Emmanuel Bernard
*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Fetch {
+ /**
+ * The style of fetch to use.
+ */
FetchMode value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FetchMode.java b/hibernate-core/src/main/java/org/hibernate/annotations/FetchMode.java
index 703e8ecdc0..84e25db1f4 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FetchMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FetchMode.java
@@ -21,25 +21,25 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
-
+package org.hibernate.annotations;
/**
- * Fetch options on associations
+ * Fetch options on associations. Defines more of the "how" of fetching, whereas JPA {@link javax.persistence.FetchType}
+ * focuses on the "when".
*
* @author Emmanuel Bernard
*/
public enum FetchMode {
/**
- * use a select for each individual entity, collection, or join load
+ * use a select for each individual entity, collection, or join load.
*/
SELECT,
/**
- * use an outer join to load the related entities, collections or joins
+ * use an outer join to load the related entities, collections or joins.
*/
JOIN,
/**
- * use a subselect query to load the additional collections
+ * use a subselect query to load the additional collections.
*/
SUBSELECT
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfile.java b/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfile.java
index 6dd1e086b2..9a91467be1 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfile.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfile.java
@@ -21,10 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
-// $Id$
-
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -40,17 +38,35 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ TYPE, PACKAGE })
@Retention(RUNTIME)
public @interface FetchProfile {
+ /**
+ * The name of the fetch profile.
+ */
String name();
+ /**
+ * The association fetch overrides.
+ */
FetchOverride[] fetchOverrides();
+ /**
+ * Descriptor for a particular association override.
+ */
@Target({ TYPE, PACKAGE })
@Retention(RUNTIME)
- @interface FetchOverride {
+ @interface FetchOverride {
+ /**
+ * The entity containing the association whose fetch is being overridden.
+ */
Class> entity();
+ /**
+ * The association whose fetch is being overridden.
+ */
String association();
+ /**
+ * The fetch mode to apply to the association.
+ */
FetchMode mode();
}
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfiles.java b/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfiles.java
index a52c290343..0b093c6742 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfiles.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FetchProfiles.java
@@ -21,10 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
-// $Id$
-
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -33,10 +31,15 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
+ * Collects together multiple fetch profiles.
+ *
* @author Hardy Ferentschik
*/
@Target({ TYPE, PACKAGE })
@Retention(RUNTIME)
public @interface FetchProfiles {
- public abstract FetchProfile[] value();
-}
\ No newline at end of file
+ /**
+ * The aggregated fetch profiles.
+ */
+ public FetchProfile[] value();
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Filter.java b/hibernate-core/src/main/java/org/hibernate/annotations/Filter.java
index 997baccfc5..eea2379bac 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Filter.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Filter.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,7 +32,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Add filters to an entity or a target entity of a collection
+ * Add filters to an entity or a target entity of a collection.
*
* @author Emmanuel Bernard
* @author Matthew Inger
@@ -41,8 +42,24 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE, METHOD, FIELD})
@Retention(RUNTIME)
public @interface Filter {
+ /**
+ * The filter name.
+ */
String name();
+
+ /**
+ * The filter condition. If empty, the default condition from the correspondingly named {@link FilterDef} is used.
+ */
String condition() default "";
+
+ /**
+ * Do we need to determine all points within the condition fragment that are alias injection points? Or
+ * are injection points already marked?
+ */
boolean deduceAliasInjectionPoints() default true;
+
+ /**
+ * The alias descriptors for injection.
+ */
SqlFragmentAlias[] aliases() default {};
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java b/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java
index 252a4a6a21..df5e311664 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java
@@ -30,7 +30,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Filter definition
+ * Filter definition. Defines a name, default condition and parameter types (if any).
*
* @author Matthew Inger
* @author Emmanuel Bernard
@@ -38,9 +38,18 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface FilterDef {
+ /**
+ * The filter name.
+ */
String name();
+ /**
+ * The default filter condition.
+ */
String defaultCondition() default "";
+ /**
+ * The filter parameter definitions.
+ */
ParamDef[] parameters() default {};
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FilterDefs.java b/hibernate-core/src/main/java/org/hibernate/annotations/FilterDefs.java
index a407e1c721..7dc2032c5d 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FilterDefs.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FilterDefs.java
@@ -30,7 +30,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Array of filter definitions
+ * Array of filter definitions.
*
* @author Matthew Inger
* @author Emmanuel Bernard
@@ -38,5 +38,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({PACKAGE, TYPE})
@Retention(RUNTIME)
public @interface FilterDefs {
+ /**
+ * The aggregated filter definitions.
+ */
FilterDef[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTable.java b/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTable.java
index 0d304ecae5..8921baed26 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTable.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTable.java
@@ -1,45 +1,60 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-
-//$Id$
-package org.hibernate.annotations;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Add filters to a join table collection
- *
- * @author Emmanuel Bernard
- * @author Rob Worsnop
- */
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface FilterJoinTable {
- String name();
- String condition() default "";
- boolean deduceAliasInjectionPoints() default true;
- SqlFragmentAlias[] aliases() default {};
-}
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Add filters to a join table collection.
+ *
+ * @author Emmanuel Bernard
+ * @author Rob Worsnop
+ */
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface FilterJoinTable {
+ /**
+ * The filter name.
+ */
+ String name();
+
+ /**
+ * The filter condition. If empty, the default condition from the correspondingly named {@link FilterDef} is used.
+ */
+ String condition() default "";
+
+ /**
+ * Do we need to determine all points within the condition fragment that are alias injection points? Or
+ * are injection points already marked?
+ */
+ boolean deduceAliasInjectionPoints() default true;
+
+ /**
+ * The alias descriptors for injection.
+ */
+ SqlFragmentAlias[] aliases() default {};
+}
\ No newline at end of file
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTables.java b/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTables.java
index 568a37783e..741b551843 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTables.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FilterJoinTables.java
@@ -21,19 +21,23 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
+package org.hibernate.annotations;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Add multiple @FilterJoinTable to a collection
+ * Add multiple {@code @FilterJoinTable} to a collection.
*
* @author Emmanuel Bernard
*/
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface FilterJoinTables {
+ /**
+ * The aggregated filters.
+ */
FilterJoinTable[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Filters.java b/hibernate-core/src/main/java/org/hibernate/annotations/Filters.java
index 89432ad680..9777a3bec5 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Filters.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Filters.java
@@ -31,7 +31,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Add multiple @Filters
+ * Add multiple {@code @Filters}.
*
* @author Emmanuel Bernard
* @author Matthew Inger
@@ -40,5 +40,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE, METHOD, FIELD})
@Retention(RUNTIME)
public @interface Filters {
+ /**
+ * The aggregated filters.
+ */
Filter[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java b/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java
index c50190b8b9..69bc487d83 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java
@@ -23,38 +23,37 @@
*/
package org.hibernate.annotations;
-
/**
* Enumeration extending javax.persistence flush modes.
*
* @author Carlos Gonz�lez-Cadenas
*/
-
public enum FlushModeType {
/**
- * see {@link org.hibernate.FlushMode#ALWAYS}
+ * Corresponds to {@link org.hibernate.FlushMode#ALWAYS}.
*/
ALWAYS,
/**
- * see {@link org.hibernate.FlushMode#AUTO}
+ * Corresponds to {@link org.hibernate.FlushMode#AUTO}.
*/
AUTO,
/**
- * see {@link org.hibernate.FlushMode#COMMIT}
+ * Corresponds to {@link org.hibernate.FlushMode#COMMIT}.
*/
COMMIT,
/**
- * see {@link org.hibernate.FlushMode#NEVER}
+ * Corresponds to {@link org.hibernate.FlushMode#NEVER}.
+ *
* @deprecated use MANUAL, will be removed in a subsequent release
*/
+ @Deprecated
NEVER,
/**
- * see {@link org.hibernate.FlushMode#MANUAL}
+ * Corresponds to {@link org.hibernate.FlushMode#MANUAL}.
*/
MANUAL,
-
/**
- * Current flush mode of the persistence context at the time the query is executed
+ * Current flush mode of the persistence context at the time the query is executed.
*/
PERSISTENCE_CONTEXT
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java b/hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java
index c1a77410d8..c1963ec162 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -30,12 +31,14 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+/**
+ * Define the foreign key name.
+ *
+ * @deprecated Prefer the JPA 2.1 introduced {@link javax.persistence.ForeignKey} instead.
+ */
@Target({FIELD, METHOD, TYPE})
@Retention(RUNTIME)
-
-/**
- * Define the foreign key name
- */
+@Deprecated
public @interface ForeignKey {
/**
* Name of the foreign key. Used in OneToMany, ManyToOne, and OneToOne
@@ -48,4 +51,4 @@ public @interface ForeignKey {
* in other relationships
*/
String inverseName() default "";
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java b/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java
index 813d8fd94b..9639d00619 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Formula.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -62,5 +63,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface Formula {
+ /**
+ * The formula string.
+ */
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java b/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java
index 0899c5f059..3885c78ef5 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java
@@ -21,19 +21,23 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
+package org.hibernate.annotations;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * The annotated property is generated by the database
+ * The annotated property is generated by the database.
*
* @author Emmanuel Bernard
*/
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Generated {
+ /**
+ * The enum value representing when the value is generated.
+ */
GenerationTime value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/GenerationTime.java b/hibernate-core/src/main/java/org/hibernate/annotations/GenerationTime.java
index bf54b0ba6e..ecc98c53df 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/GenerationTime.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/GenerationTime.java
@@ -21,16 +21,24 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
-
+package org.hibernate.annotations;
/**
- * When should the generation occurs
+ * At what time(s) will the generation occur?
*
* @author Emmanuel Bernard
*/
public enum GenerationTime {
+ /**
+ * Indicates the value is never generated.
+ */
NEVER,
+ /**
+ * Indicates the value is generated on insert.
+ */
INSERT,
+ /**
+ * Indicates the value is generated on insert and on update.
+ */
ALWAYS
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java b/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java
index bbe0967916..64e66a53ac 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java
@@ -32,8 +32,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Generator annotation describing any kind of Hibernate
- * generator in a detyped manner
+ * Generator annotation describing any kind of Hibernate generator in a generic (de-typed) manner.
*
* @author Emmanuel Bernard
*/
@@ -41,16 +40,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface GenericGenerator {
/**
- * unique generator name
+ * unique generator name.
*/
String name();
/**
- * Generator strategy either a predefined Hibernate
- * strategy or a fully qualified class name.
+ * Generator strategy either a predefined Hibernate strategy or a fully qualified class name.
*/
String strategy();
/**
- * Optional generator parameters
+ * Optional generator parameters.
*/
Parameter[] parameters() default {};
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerators.java b/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerators.java
index 7ed4cc2249..28e8fa82cc 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerators.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerators.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -30,13 +31,16 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Array of generic generator definitions
+ * Array of generic generator definitions.
*
* @author Paul Cowan
*/
@Target({PACKAGE, TYPE})
@Retention(RUNTIME)
public @interface GenericGenerators {
+ /**
+ * The aggregated generators.
+ */
GenericGenerator[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Index.java b/hibernate-core/src/main/java/org/hibernate/annotations/Index.java
index 6779606255..5b6a9ea0db 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Index.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Index.java
@@ -30,16 +30,23 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Define a DB index
+ * Define a DB index.
*
* @author Emmanuel Bernard
+ *
* @deprecated Using {@link javax.persistence.Index} instead.
*/
@Target({FIELD, METHOD})
@Retention(RUNTIME)
@Deprecated
public @interface Index {
+ /**
+ * The index name.
+ */
String name();
+ /**
+ * The column(s) that are indexed.
+ */
String[] columnNames() default {};
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java b/hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java
index 5c1689452e..88c228ccc2 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -30,20 +31,34 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Describe an index column of a List
- * Prefer the standard {@link javax.persistence.OrderColumn} annotation
+ * Describe an index column of a List.
*
* @author Matthew Inger
+ *
+ * @deprecated Prefer the standard JPA {@link javax.persistence.OrderColumn} annotation and the Hibernate specific
+ * {@link ListIndexBase} (for replacing {@link #base()}).
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
+@Deprecated
public @interface IndexColumn {
- /** column name */
+ /**
+ * The column name.
+ */
String name();
- /** index in DB start from base */
+
+ /**
+ * The starting index value. Zero (0) by default, since Lists indexes start at zero (0).
+ */
int base() default 0;
- /** is the index nullable */
+
+ /**
+ * Is the column nullable?
+ */
boolean nullable() default true;
- /** column definition, default to an appropriate integer */
+
+ /**
+ * An explicit column definition.
+ */
String columnDefinition() default "";
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnOrFormula.java b/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnOrFormula.java
index cf77887675..c34438393e 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnOrFormula.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnOrFormula.java
@@ -21,9 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
-
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.persistence.JoinColumn;
@@ -33,11 +32,21 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
+ * Allows joins based on column or a formula. One of {@link #formula()} or {@link #column()} should be
+ * specified, but not both.
+ *
* @author Sharath Reddy
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface JoinColumnOrFormula {
+ /**
+ * The formula to use in joining.
+ */
JoinFormula formula() default @JoinFormula(value="", referencedColumnName="");
+
+ /**
+ * The column to use in joining.
+ */
JoinColumn column() default @JoinColumn();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnsOrFormulas.java b/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnsOrFormulas.java
index d73fe41420..c69bb4a1c0 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnsOrFormulas.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/JoinColumnsOrFormulas.java
@@ -31,10 +31,15 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
+ * Collection of {@code @JoinColumnOrFormula} definitions.
+ *
* @author Sharath Reddy
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface JoinColumnsOrFormulas {
+ /**
+ * The aggregated values.
+ */
JoinColumnOrFormula [] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/JoinFormula.java b/hibernate-core/src/main/java/org/hibernate/annotations/JoinFormula.java
index 07a7b122cb..1dc87debdd 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/JoinFormula.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/JoinFormula.java
@@ -21,8 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,14 +31,21 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * JoinFormula. To be used as a replacement for @JoinColumn in most places
- * The formula has to be a valid SQL fragment
+ * To be used as a replacement for {@code @JoinColumn} in most places. The formula has to be a valid
+ * SQL fragment
*
* @author Sharath Reddy
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface JoinFormula {
+ /**
+ * The formula.
+ */
String value();
+
+ /**
+ * The column this formula references.
+ */
String referencedColumnName() default "";
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollection.java b/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollection.java
index 81c7f66213..5098cdf5ee 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollection.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollection.java
@@ -29,12 +29,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Define the lazy status of a collection
+ * Define the lazy status of a collection.
*
* @author Emmanuel Bernard
*/
-@Target({ ElementType.METHOD, ElementType.FIELD })
+@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface LazyCollection {
+ /**
+ * The laziness option for the collection.
+ */
LazyCollectionOption value();
-}
+}
\ No newline at end of file
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollectionOption.java b/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollectionOption.java
index da06858880..86661c6dd6 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollectionOption.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/LazyCollectionOption.java
@@ -21,19 +21,24 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
-
+package org.hibernate.annotations;
/**
- * Lazy options available for a collection
+ * Lazy options available for a collection.
*
* @author Emmanuel Bernard
*/
public enum LazyCollectionOption {
- /** eagerly load it */
+ /**
+ * Eagerly load it.
+ */
FALSE,
- /** load it when the state is requested */
+ /**
+ * Load it when the state is requested.
+ */
TRUE,
- /** prefer extra queries over fill collection loading */
+ /**
+ * Prefer extra queries over full collection loading.
+ */
EXTRA
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOne.java b/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOne.java
index a41e2ac4c4..92dbbbfc9b 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOne.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOne.java
@@ -21,20 +21,23 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
+package org.hibernate.annotations;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Define the lazy status of a ToOne association
- * (ie OneToOne or ManyToOne)
+ * Define the laziness options available for a ToOne (ie OneToOne or ManyToOne) association.
*
* @author Emmanuel Bernard
*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface LazyToOne {
+ /**
+ * Specify the laziness option.
+ */
LazyToOneOption value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOneOption.java b/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOneOption.java
index b7b8df229b..eaaeccdef6 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOneOption.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/LazyToOneOption.java
@@ -21,26 +21,30 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
-
+package org.hibernate.annotations;
/**
- * Lazy options available for a ToOne association
+ * Lazy options available for a ToOne association.
*
* @author Emmanuel Bernard
*/
public enum LazyToOneOption {
- /** eagerly load the association */
+ /**
+ * Eagerly load the association.
+ */
FALSE,
/**
- * Lazy, give back a proxy which will be loaded when the state is requested
- * This should be the prefered option
+ * Lazy, give back a proxy which will be loaded when the state is requested.
+ *
+ * This should be the preferred option.
*/
PROXY,
- /** Lazy, give back the real object loaded when a reference is requested
- * (Bytecode enhancement is mandatory for this option, fall back to PROXY
- * if the class is not enhanced)
- * This option should be avoided unless you can't afford the use of proxies
+ /**
+ * Lazy, give back the real object loaded when a reference is requested.
+ *
+ * Bytecode enhancement is mandatory for this option. Falls back to {@link #PROXY}
+ * if the class is not enhanced. This option should be avoided unless you can't afford
+ * the use of proxies
*/
NO_PROXY
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ListIndexBase.java b/hibernate-core/src/main/java/org/hibernate/annotations/ListIndexBase.java
new file mode 100644
index 0000000000..db3e8cf17d
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/ListIndexBase.java
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+/**
+ * Defines the start index value for a list index as stored on the database. This base is subtracted from the
+ * incoming database value on reads to determine the List position; it is added to the List position index when
+ * writing to the database.
+ *
+ * By default list indexes are stored starting at zero.
+ *
+ * Generally used in conjunction with {@link javax.persistence.OrderColumn}.
+ *
+ * @see javax.persistence.OrderColumn
+ *
+ * @author Steve Ebersole
+ */
+public @interface ListIndexBase {
+ /**
+ * The list index base. Default is 0.
+ */
+ int value() default 0;
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Loader.java b/hibernate-core/src/main/java/org/hibernate/annotations/Loader.java
index 57c74fa282..8e2e3b2619 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Loader.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Loader.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,7 +32,8 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Loader Annotation for overwriting Hibernate default FIND method
+ * Used to override how Hibernate performs load operations. naming a named query to use instead of
+ * its generated SELECT SQL.
*
* @author L�szl� Benke
*/
@@ -39,7 +41,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention( RUNTIME )
public @interface Loader {
/**
- * namedQuery to use for loading
+ * THe namedQuery to use for loading.
*/
String namedQuery() default "";
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/MapKeyType.java b/hibernate-core/src/main/java/org/hibernate/annotations/MapKeyType.java
index 4d07fd7805..d3392e2e98 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/MapKeyType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/MapKeyType.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import static java.lang.annotation.ElementType.FIELD;
@@ -36,5 +37,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@java.lang.annotation.Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface MapKeyType {
+ /**
+ * The map key type definition.
+ */
Type value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/MetaValue.java b/hibernate-core/src/main/java/org/hibernate/annotations/MetaValue.java
index e9428b019d..ec435e66c9 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/MetaValue.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/MetaValue.java
@@ -33,12 +33,12 @@ package org.hibernate.annotations;
*/
public @interface MetaValue {
/**
- * entity type
+ * The entity type.
*/
Class targetEntity();
/**
- * discriminator value stored in database
+ * The corresponding discriminator value stored in database.
*/
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQueries.java b/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQueries.java
index f9a2ce6c12..7df7eb4e68 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQueries.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQueries.java
@@ -30,13 +30,16 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Extends {@link javax.persistence.NamedNativeQueries} to hold hibernate NamedNativeQuery
- * objects
+ * A grouping of Hibernate-specific {@link NamedNativeQuery} definitions. Effectively extends the named native
+ * query definitions made available through {@link javax.persistence.NamedNativeQueries}.
*
* @author Emmanuel Bernard
*/
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface NamedNativeQueries {
+ /**
+ * The grouping of Hibernate named native SQL queries.
+ */
NamedNativeQuery[] value();
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQuery.java b/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQuery.java
index 8c90153d52..fdf4beba2a 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQuery.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/NamedNativeQuery.java
@@ -30,36 +30,77 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Extends {@link javax.persistence.NamedNativeQuery} with Hibernate features
+ * Extends {@link javax.persistence.NamedNativeQuery} with Hibernate features.
*
* @author Emmanuel Bernard
+ *
+ * @see org.hibernate.SQLQuery
*/
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface NamedNativeQuery {
+ /**
+ * The name. It is a named query after all :)
+ */
String name();
+ /**
+ * The SQL query string.
+ */
String query();
+ /**
+ * The result Class. Should not be used in conjunction with {@link #resultSetMapping()}
+ */
Class resultClass() default void.class;
- String resultSetMapping() default ""; // name of SQLResultSetMapping
- /** the flush mode for the query */
+ /**
+ * The name of a SQLResultSetMapping to use. Should not be used in conjunction with {@link #resultClass()}.
+ */
+ String resultSetMapping() default "";
+
+ /**
+ * The flush mode for the query.
+ */
FlushModeType flushMode() default FlushModeType.PERSISTENCE_CONTEXT;
- /** mark the query as cacheable or not */
+
+ /**
+ * Whether the query (results) is cacheable or not. Default is {@code false}, that is not cacheable.
+ */
boolean cacheable() default false;
- /** the cache region to use */
+
+ /**
+ * If the query results are cacheable, name the query cache region to use.
+ */
String cacheRegion() default "";
- /** the number of rows fetched by the JDBC Driver per roundtrip */
+
+ /**
+ * The number of rows fetched by the JDBC Driver per trip.
+ */
int fetchSize() default -1;
- /**the query timeout in seconds*/
+
+ /**
+ * The query timeout (in seconds). Default is no timeout.
+ */
int timeout() default -1;
+ /**
+ * Does the SQL ({@link #query()}) represent a call to a procedure/function?
+ */
boolean callable() default false;
- /**comment added to the SQL query, useful for the DBA */
+
+ /**
+ * A comment added to the SQL query. Useful when engaging with DBA.
+ */
String comment() default "";
- /**the cache mode used for this query*/
+
+ /**
+ * The cache mode used for this query. This refers to entities/collections returned from the query.
+ */
CacheModeType cacheMode() default CacheModeType.NORMAL;
- /**marks whether the results are fetched in read-only mode or not*/
+
+ /**
+ * Whether the results should be read-only. Default is {@code false}.
+ */
boolean readOnly() default false;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/NamedQueries.java b/hibernate-core/src/main/java/org/hibernate/annotations/NamedQueries.java
index caee4694e0..f5f90130e0 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/NamedQueries.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/NamedQueries.java
@@ -30,8 +30,8 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Extends {@link javax.persistence.NamedQueries} to hold hibernate NamedQuery
- * objects
+ * A grouping of Hibernate-specific {@link NamedQuery} definitions. Effectively extends the named query
+ * definitions made available through {@link javax.persistence.NamedQueries}.
*
* @author Emmanuel Bernard
* @author Carlos Gonz�lez-Cadenas
@@ -39,5 +39,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface NamedQueries {
+ /**
+ * The grouping of named queries.
+ */
NamedQuery[] value();
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/NamedQuery.java b/hibernate-core/src/main/java/org/hibernate/annotations/NamedQuery.java
index cf8abdc83f..8a73574c38 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/NamedQuery.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/NamedQuery.java
@@ -31,61 +31,63 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Extends {@link javax.persistence.NamedQuery} with Hibernate features
+ * Extends {@link javax.persistence.NamedQuery} with Hibernate features.
*
* @author Carlos Gonzalez-Cadenas
+ *
+ * @see org.hibernate.Query
*/
@Target( { TYPE, PACKAGE })
@Retention(RUNTIME)
public @interface NamedQuery {
/**
- * @return returns the name of this {@code NamedQuery}
+ * The name of this {@code NamedQuery}.
*/
String name();
/**
- * @return returns the query string for this {@code NamedQuery}
+ * The query string for this {@code NamedQuery}.
*/
String query();
/**
- * @return returns the flush mode for this query
+ * The flush mode for this query.
*/
FlushModeType flushMode() default FlushModeType.PERSISTENCE_CONTEXT;
/**
- * @return returns whether this query is cacheable or not
+ * Whether the query (results) is cacheable or not. Default is {@code false}, that is not cacheable.
*/
boolean cacheable() default false;
/**
- * @return returns the the cache region to use
+ * If the query results are cacheable, name the query cache region to use.
*/
String cacheRegion() default "";
/**
- * @return returns the number of rows fetched by the JDBC Driver per database round-trip
+ * The number of rows fetched by the JDBC Driver per trip.
*/
int fetchSize() default -1;
/**
- * @return return the query timeout in seconds
+ * The query timeout (in seconds). Default is no timeout.
*/
int timeout() default -1;
/**
- * @return returns the comment added to the SQL query (useful for the DBA)
+ * A comment added to the generated SQL query. Useful when engaging with DBA.
*/
String comment() default "";
/**
- * @return returns the cache mode used for this query
+ * The cache mode used for this query. This refers to entities/collections returned from the query.
*/
CacheModeType cacheMode() default CacheModeType.NORMAL;
/**
- * @return returns whether the results are fetched in read-only mode or not. Default is {@code false}
+ * Whether the results should be read-only. Default is {@code false}.
*/
boolean readOnly() default false;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/NaturalId.java b/hibernate-core/src/main/java/org/hibernate/annotations/NaturalId.java
index 84cf003f0f..b5e35d77d0 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/NaturalId.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/NaturalId.java
@@ -34,15 +34,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
* This specifies that a property is part of the natural id of the entity.
*
* @author Nicol�s Lichtmaier
+ *
* @see NaturalIdCache
*/
@Target( { METHOD, FIELD } )
@Retention( RUNTIME )
public @interface NaturalId {
/**
- * Is this natural id mutable (or immutable)?
- *
- * @return {@code true} indicates the natural id is mutable; {@code false} (the default) that it is immutable.
+ * Whether the natural id is mutable (or immutable)? {@code false} (the default) indicates it is immutable;
+ * {@code true} indicates it is mutable.
*/
boolean mutable() default false;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/NotFound.java b/hibernate-core/src/main/java/org/hibernate/annotations/NotFound.java
index 18e7484e77..8f795911b6 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/NotFound.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/NotFound.java
@@ -38,5 +38,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target( { METHOD, FIELD })
@Retention(RUNTIME)
public @interface NotFound {
+ /**
+ * The action to perform when an associated entity is not found. By default an exception is thrown.
+ */
NotFoundAction action() default NotFoundAction.EXCEPTION;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/NotFoundAction.java b/hibernate-core/src/main/java/org/hibernate/annotations/NotFoundAction.java
index c2fbb985f5..7460471e7b 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/NotFoundAction.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/NotFoundAction.java
@@ -25,17 +25,18 @@ package org.hibernate.annotations;
/**
- * Actoin to use when an element is not found in DB while beeing expected
+ * Possible actions when an associated entity is not found in the database. Often seen with "legacy" foreign-key
+ * schemes which do not use {@code NULL} to indicate a missing reference, instead using a "magic value".
*
* @author Emmanuel Bernard
*/
public enum NotFoundAction {
/**
- * raise an exception when an element is not found (default and recommended)
+ * Raise an exception when an element is not found (default and recommended).
*/
EXCEPTION,
/**
- * ignore the element when not found in DB
+ * Ignore the element when not found in database.
*/
IGNORE
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/OnDelete.java b/hibernate-core/src/main/java/org/hibernate/annotations/OnDelete.java
index 12d2bf414a..2278bed2fb 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/OnDelete.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/OnDelete.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -32,7 +33,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Strategy to use on collections, arrays and on joined subclasses delete
+ * Strategy to use on collections, arrays and on joined subclasses delete.
+ *
* OnDelete of secondary tables currently not supported.
*
* @author Emmanuel Bernard
@@ -40,5 +42,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({METHOD, FIELD, TYPE})
@Retention(RUNTIME)
public @interface OnDelete {
+ /**
+ * The on-delete action.
+ */
OnDeleteAction action();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/OnDeleteAction.java b/hibernate-core/src/main/java/org/hibernate/annotations/OnDeleteAction.java
index af53d0077d..3b839878c3 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/OnDeleteAction.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/OnDeleteAction.java
@@ -23,19 +23,18 @@
*/
package org.hibernate.annotations;
-
/**
- * Possible actions on deletes
+ * Possible actions for on-delete.
*
* @author Emmanuel Bernard
*/
public enum OnDeleteAction {
/**
- * the default
+ * Take no action. The default.
*/
NO_ACTION,
/**
- * use cascade delete capabilities of the DD
+ * Use cascade delete capabilities of the database foreign-key.
*/
CASCADE
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLock.java b/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLock.java
index 876efa84c6..ce3492d044 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLock.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLock.java
@@ -30,6 +30,7 @@ import java.lang.annotation.Target;
/**
* Whether or not a change of the annotated property will trigger a entity version increment.
+ *
* If the annotation is not present, the property is involved in the optimistic lock strategy (default).
*
* @author Logi Ragnarsson
@@ -38,7 +39,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface OptimisticLock {
/**
- * @return If {@code true}, the annotated property change will not trigger a version increment.
+ * Whether the annotated property should be included in optimistic locking determinations for the owner.
*/
boolean excluded();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLockType.java b/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLockType.java
index a6df6dd3a0..ce2ca87306 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLockType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLockType.java
@@ -23,28 +23,30 @@
*/
package org.hibernate.annotations;
-
/**
- * Optimistic locking strategy
- * VERSION is the default and recommended one
+ * Possible optimistic locking strategies.
*
* @author Emmanuel Bernard
*/
public enum OptimisticLockType {
/**
- * no optimistic locking
+ * Perform no optimistic locking.
*/
NONE,
/**
- * use a column version
+ * Perform optimistic locking using a dedicated version column.
+ *
+ * @see javax.persistence.Version
*/
VERSION,
/**
- * dirty columns are compared
+ * Perform optimistic locking based on *dirty* fields as part of an expanded WHERE clause restriction for the
+ * UPDATE/DELETE SQL statement.
*/
DIRTY,
/**
- * all columns are compared
+ * Perform optimistic locking based on *all* fields as part of an expanded WHERE clause restriction for the
+ * UPDATE/DELETE SQL statement.
*/
ALL
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLocking.java b/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLocking.java
index 49278d2aca..564c6faba2 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLocking.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/OptimisticLocking.java
@@ -38,5 +38,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target( TYPE )
@Retention( RUNTIME )
public @interface OptimisticLocking {
+ /**
+ * Defines the style of optimistic locking for the entity.
+ */
OptimisticLockType type() default OptimisticLockType.VERSION;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/OrderBy.java b/hibernate-core/src/main/java/org/hibernate/annotations/OrderBy.java
index 70f4595f8b..38a5f3acf2 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/OrderBy.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/OrderBy.java
@@ -30,13 +30,23 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Order a collection using SQL ordering (not HQL ordering)
+ * Order a collection using SQL ordering (not HQL ordering).
+ *
+ * Different from {@link javax.persistence.OrderBy} in that this expects SQL fragment, JPA OrderBy expects a
+ * valid JPQL order-by fragment.
*
* @author Emmanuel Bernard
+ * @author Steve Ebersole
+ *
+ * @see javax.persistence.OrderBy
+ * @see SortComparator
+ * @see SortNatural
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface OrderBy {
- /** SQL orderby clause */
+ /**
+ * SQL ordering clause.
+ */
String clause();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ParamDef.java b/hibernate-core/src/main/java/org/hibernate/annotations/ParamDef.java
index 57e457b098..d3bd662511 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/ParamDef.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/ParamDef.java
@@ -22,20 +22,29 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * A parameter definition
+ * A parameter definition.
*
* @author Emmanuel Bernard
*/
@Target({})
@Retention(RUNTIME)
public @interface ParamDef {
+ /**
+ * The name of the parameter definition.
+ */
String name();
+ /**
+ * The type being defined, Typically this is the fully-qualified name of the {@link org.hibernate.type.Type},
+ * {@link org.hibernate.usertype.UserType} or {@link org.hibernate.usertype.CompositeUserType} implementation
+ * class.
+ */
String type();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Parameter.java b/hibernate-core/src/main/java/org/hibernate/annotations/Parameter.java
index 596292f020..9141a74af3 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Parameter.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Parameter.java
@@ -28,14 +28,20 @@ import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Parameter (basically key/value pattern)
+ * Generic parameter (basically a key/value combination) used to parametrize other annotations.
*
* @author Emmanuel Bernard
*/
@Target({})
@Retention(RUNTIME)
public @interface Parameter {
+ /**
+ * The parameter name.
+ */
String name();
+ /**
+ * The parameter value.
+ */
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Parent.java b/hibernate-core/src/main/java/org/hibernate/annotations/Parent.java
index 7407a50268..3f8d398666 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Parent.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Parent.java
@@ -30,7 +30,7 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Reference the property as a pointer back to the owner (generally the owning entity)
+ * Reference the property as a pointer back to the owner (generally the owning entity).
*
* @author Emmanuel Bernard
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Persister.java b/hibernate-core/src/main/java/org/hibernate/annotations/Persister.java
index 73897a5246..749978a37c 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Persister.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Persister.java
@@ -36,7 +36,7 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Persister {
/**
- * @return The custom persister class
+ * The custom persister class.
*/
Class> impl();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Polymorphism.java b/hibernate-core/src/main/java/org/hibernate/annotations/Polymorphism.java
index 1be03925e5..08790562ab 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Polymorphism.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Polymorphism.java
@@ -37,5 +37,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target( TYPE )
@Retention( RUNTIME )
public @interface Polymorphism {
+ /**
+ * Specifies the polymorphism type.
+ */
PolymorphismType type() default PolymorphismType.IMPLICIT;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/PolymorphismType.java b/hibernate-core/src/main/java/org/hibernate/annotations/PolymorphismType.java
index 3b59889690..0d8558584c 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/PolymorphismType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/PolymorphismType.java
@@ -23,19 +23,18 @@
*/
package org.hibernate.annotations;
-
/**
- * Type of available polymorphism for a particular entity
+ * Type of available polymorphism for a particular entity.
*
* @author Emmanuel Bernard
*/
public enum PolymorphismType {
/**
- * default, this entity is retrieved if any of its super entity is asked
+ * This entity is retrieved if any of its super entity are retrieved. The default,
*/
IMPLICIT,
/**
- * this entity is retrieved only if explicitly asked
+ * This entity is retrieved only if explicitly asked.
*/
EXPLICIT
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Proxy.java b/hibernate-core/src/main/java/org/hibernate/annotations/Proxy.java
index 7e11c5637f..380f832a7d 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Proxy.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Proxy.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -29,7 +30,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Lazy and proxy configuration of a particular class
+ * Lazy and proxy configuration of a particular class.
*
* @author Emmanuel Bernard
*/
@@ -37,12 +38,12 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface Proxy {
/**
- * Whether this class is lazy or not (default to true)
+ * Whether this class is lazy or not. Default to true.
*/
boolean lazy() default true;
/**
- * Proxy class or interface used. Default entity class name.
+ * Proxy class or interface used. Default is to use the entity class name.
*/
Class proxyClass() default void.class;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/QueryHints.java b/hibernate-core/src/main/java/org/hibernate/annotations/QueryHints.java
index 19635cd12c..d16e8015a5 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/QueryHints.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/QueryHints.java
@@ -24,21 +24,90 @@
package org.hibernate.annotations;
/**
- *
+ * Consolidation of hints available to Hibernate JPA queries. Mainly used to define features available on
+ * Hibernate queries that have no corollary in JPA queries.
*/
public class QueryHints {
+ /**
+ * Disallow instantiation.
+ */
+ private QueryHints() {
+ }
+ /**
+ * The cache mode to use.
+ *
+ * @see org.hibernate.Query#setCacheMode
+ * @see org.hibernate.SQLQuery#setCacheMode
+ */
public static final String CACHE_MODE = "org.hibernate.cacheMode";
+
+ /**
+ * The cache region to use.
+ *
+ * @see org.hibernate.Query#setCacheRegion
+ * @see org.hibernate.SQLQuery#setCacheRegion
+ */
public static final String CACHE_REGION = "org.hibernate.cacheRegion";
+
+ /**
+ * Are the query results cacheable?
+ *
+ * @see org.hibernate.Query#setCacheable
+ * @see org.hibernate.SQLQuery#setCacheable
+ */
public static final String CACHEABLE = "org.hibernate.cacheable";
+
+ /**
+ * Is the query callable? Note: only valid for named native sql queries.
+ */
public static final String CALLABLE = "org.hibernate.callable";
+
+ /**
+ * Defines a comment to be applied to the SQL sent to the database.
+ *
+ * @see org.hibernate.Query#setComment
+ * @see org.hibernate.SQLQuery#setComment
+ */
public static final String COMMENT = "org.hibernate.comment";
+
+ /**
+ * Defines the JDBC fetch size to use.
+ *
+ * @see org.hibernate.Query#setFetchSize
+ * @see org.hibernate.SQLQuery#setFetchSize
+ */
public static final String FETCH_SIZE = "org.hibernate.fetchSize";
+
+ /**
+ * The flush mode to associate with the execution of the query.
+ *
+ * @see org.hibernate.Query#setFlushMode
+ * @see org.hibernate.SQLQuery#setFlushMode
+ * @see org.hibernate.Session#setFlushMode
+ */
public static final String FLUSH_MODE = "org.hibernate.flushMode";
+
+ /**
+ * Should entities returned from the query be set in read only mode?
+ *
+ * @see org.hibernate.Query#setReadOnly
+ * @see org.hibernate.SQLQuery#setReadOnly
+ * @see org.hibernate.Session#setReadOnly
+ */
public static final String READ_ONLY = "org.hibernate.readOnly";
+
+ /**
+ * Apply a Hibernate query timeout, which is defined in seconds.
+ *
+ * @see org.hibernate.Query#setTimeout
+ * @see org.hibernate.SQLQuery#setTimeout
+ */
public static final String TIMEOUT_HIBERNATE = "org.hibernate.timeout";
+
+ /**
+ * Apply a JPA query timeout, which is defined in milliseconds.
+ */
public static final String TIMEOUT_JPA = "javax.persistence.query.timeout";
- private QueryHints() {
- }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ResultCheckStyle.java b/hibernate-core/src/main/java/org/hibernate/annotations/ResultCheckStyle.java
index f0667636a2..8904909ecd 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/ResultCheckStyle.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/ResultCheckStyle.java
@@ -23,18 +23,17 @@
*/
package org.hibernate.annotations;
-
/**
- * Possible checks on Sql Insert, Delete, Update
+ * Possible styles of checking return codes on SQL INSERT, UPDATE and DELETE queries.
*
* @author L�szl� Benke
*/
public enum ResultCheckStyle {
/**
- * Do not perform checking. Either user simply does not want checking, or is
- * indicating a {@link java.sql.CallableStatement} execution in which the
- * checks are being performed explicitly and failures are handled through
- * propogation of {@link java.sql.SQLException}s.
+ * Do not perform checking. Might mean that the user really just does not want any checking. Might
+ * also mean that the user is expecting a failure to be indicated by a {@link java.sql.SQLException} being
+ * thrown (presumably from a {@link java.sql.CallableStatement} which is performing explicit checks and
+ * propagating failures back through the driver).
*/
NONE,
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/RowId.java b/hibernate-core/src/main/java/org/hibernate/annotations/RowId.java
index 5405f20689..2556e30707 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/RowId.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/RowId.java
@@ -29,7 +29,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Support for {@literal ROWID} mapping feature of Hibernate.
+ * Support for {@code ROWID} mapping feature of Hibernate.
*
* @author Steve Ebersole
*/
@@ -37,9 +37,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface RowId {
/**
- * Names the {@literal ROWID} identifier
- *
- * @return The {@literal ROWID} identifier
+ * Names the {@code ROWID} identifier.
*/
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SQLDelete.java b/hibernate-core/src/main/java/org/hibernate/annotations/SQLDelete.java
index db50b21540..8066b07ed0 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SQLDelete.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SQLDelete.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,7 +32,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * SqlDelete Annotation for overwriting Hibernate default DELETE method
+ * Custom SQL statement for delete of an entity/collection.
*
* @author L�szl� Benke
*/
@@ -39,12 +40,12 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention( RUNTIME )
public @interface SQLDelete {
/**
- * Procedure name or DELETE STATEMENT
+ * Procedure name or SQL DELETE statement.
*/
String sql();
/**
- * Is the statement using stored procedure or not
+ * Is the statement callable (aka a {@link java.sql.CallableStatement})?
*/
boolean callable() default false;
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SQLDeleteAll.java b/hibernate-core/src/main/java/org/hibernate/annotations/SQLDeleteAll.java
index 96ed9b9d8c..236024ada8 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SQLDeleteAll.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SQLDeleteAll.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -31,7 +32,7 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
/**
- * SqlDelete Annotation for overwriting Hibernate default DELETE ALL method
+ * Custom SQL statement for delete of all of a collection's elements.
*
* @author L�szl� Benke
*/
@@ -39,12 +40,12 @@ import static java.lang.annotation.ElementType.TYPE;
@Retention( RetentionPolicy.RUNTIME )
public @interface SQLDeleteAll {
/**
- * Procedure name or DELETE STATEMENT
+ * Procedure name or SQL DELETE statement.
*/
String sql();
/**
- * Is the statement using stored procedure or not
+ * Is the statement callable (aka a {@link java.sql.CallableStatement})?
*/
boolean callable() default false;
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SQLInsert.java b/hibernate-core/src/main/java/org/hibernate/annotations/SQLInsert.java
index ea668043e1..ce2553c212 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SQLInsert.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SQLInsert.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,7 +32,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * SqlInsert Annotation for overwriting Hibernate default INSERT INTO method
+ * Custom SQL statement for insertion of an entity/collection.
*
* @author L�szl� Benke
*/
@@ -39,12 +40,12 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention( RUNTIME )
public @interface SQLInsert {
/**
- * Procedure name or INSERT STATEMENT
+ * Procedure name or SQL INSERT statement.
*/
String sql();
/**
- * Is the statement using stored procedure or not
+ * Is the statement callable (aka a {@link java.sql.CallableStatement})?
*/
boolean callable() default false;
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SQLUpdate.java b/hibernate-core/src/main/java/org/hibernate/annotations/SQLUpdate.java
index ea5e2ba260..9a10f42c0d 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SQLUpdate.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SQLUpdate.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,21 +32,20 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * SqlUpdate Annotation for overwriting Hibernate default UPDATE method
+ * Custom SQL statement for update of an entity/collection.
*
* @author L�szl� Benke
*/
@Target( {TYPE, FIELD, METHOD} )
@Retention( RUNTIME )
public @interface SQLUpdate {
-
/**
- * Procedure name or UPDATE STATEMENT
+ * Procedure name or SQL UPDATE statement.
*/
String sql();
/**
- * Is the statement using stored procedure or not
+ * Is the statement callable (aka a {@link java.sql.CallableStatement})?
*/
boolean callable() default false;
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SelectBeforeUpdate.java b/hibernate-core/src/main/java/org/hibernate/annotations/SelectBeforeUpdate.java
index 5e4464ed17..9c4fe2c9fa 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SelectBeforeUpdate.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SelectBeforeUpdate.java
@@ -38,5 +38,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target( TYPE )
@Retention( RUNTIME )
public @interface SelectBeforeUpdate {
+ /**
+ * {@code true} (which is the default when this annotation is present) indicates that
+ * {@code select-before-update} processing should occur. {@code false} indicates
+ * {@code select-before-update} processing should not occur.
+ */
boolean value() default true;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Sort.java b/hibernate-core/src/main/java/org/hibernate/annotations/Sort.java
index 0070dcb9a2..3dd90115e6 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Sort.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Sort.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -30,22 +31,27 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Collection sort
- * (Java level sorting)
+ * Collection sort (in-memory sorting). Different that ordering, which is applied during the SQL select.
*
* @author Emmanuel Bernard
+ *
+ * @see OrderBy
+ *
+ * @deprecated Use {@link SortComparator} or {@link SortNatural} instead depending on need.
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
+@Deprecated
public @interface Sort {
/**
- * sort type
+ * The type of sorting to use. The default is to not use sorting.
*/
SortType type() default SortType.UNSORTED;
- /**
- * Sort comparator implementation
- */
- //TODO find a way to use Class
+ /**
+ * Specifies the comparator to use. Only valid when {@link #type} specifies {@link SortType#COMPARATOR}.
+ *
+ * TODO find a way to use Class -> see HHH-8164
+ */
Class comparator() default void.class;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SortComparator.java b/hibernate-core/src/main/java/org/hibernate/annotations/SortComparator.java
new file mode 100644
index 0000000000..6ed0c2710a
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SortComparator.java
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+import java.util.Comparator;
+
+/**
+ * Specifies in-memory Set/Map sorting using a specified {@link Comparator} for sorting.
+ *
+ * NOTE : Sorting is different than ordering (see {@link OrderBy}) which is applied during the SQL SELECT.
+ *
+ * For sorting based on natural sort order, use {@link SortNatural} instead. It is illegal to combine
+ * {@link SortComparator} and {@link SortNatural}.
+ *
+ * @see OrderBy
+ * @see SortComparator
+ *
+ * @author Steve Ebersole
+ */
+public @interface SortComparator {
+ /**
+ * Specifies the comparator class to use.
+ */
+ Class extends Comparator>> value();
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SortNatural.java b/hibernate-core/src/main/java/org/hibernate/annotations/SortNatural.java
new file mode 100644
index 0000000000..9fc285dedc
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SortNatural.java
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+/**
+ * Specifies in-memory Set/Map sorting using natural sorting.
+ *
+ * NOTE : Sorting is different than ordering (see {@link OrderBy}) which is applied during the SQL SELECT.
+ *
+ * For sorting based on a comparator, use {@link SortComparator} instead. It is illegal to combine
+ *{@link SortComparator} and SortNatural.
+ *
+ * @see OrderBy
+ * @see SortComparator
+ *
+ * @author Steve Ebersole
+ */
+public @interface SortNatural {
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SortType.java b/hibernate-core/src/main/java/org/hibernate/annotations/SortType.java
index b33c772189..b8f0ea4baa 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SortType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SortType.java
@@ -23,14 +23,25 @@
*/
package org.hibernate.annotations;
-
/**
- * Sort strategies
+ * Possible collection sorting strategies.
*
* @author Emmanuel Bernard
+ *
+ * @deprecated Since {@link Sort} is deprecated.
*/
+@Deprecated
public enum SortType {
+ /**
+ * The collection is unsorted.
+ */
UNSORTED,
+ /**
+ * The collection is sorted using its natural sorting.
+ */
NATURAL,
+ /**
+ * The collection is sorted using a supplied comparator.
+ */
COMPARATOR
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Source.java b/hibernate-core/src/main/java/org/hibernate/annotations/Source.java
index 5152d04198..30d575beef 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Source.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Source.java
@@ -21,8 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,13 +31,16 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Optional annotation in conjunction with {@link javax.persistence.Version} and timestamp version properties.
- * The annotation value decides where the timestamp is generated.
+ * Optional annotation in conjunction with {@link javax.persistence.Version} and timestamp version properties
+ * indicating the source of the timestamp value.
*
* @author Hardy Ferentschik
*/
@Target({ METHOD, FIELD })
@Retention(RUNTIME)
public @interface Source {
+ /**
+ * How is the timestamp generated? Default is a JVM generated value.
+ */
SourceType value() default SourceType.VM;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java b/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
index 907d1722f2..f9468923a8 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
@@ -21,10 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.annotations;
-
/**
* Where should Hibernate retrieve the value from? From the database, or from the current JVM?
*
@@ -34,19 +32,24 @@ public enum SourceType {
/**
* Get the timestamp from the current VM.
*/
- VM("timestamp"),
+ VM( "timestamp" ),
/**
* Get the timestamp from the database.
*/
- DB("dbtimestamp");
+ DB( "dbtimestamp" );
private final String typeName;
- SourceType(String typeName ) {
+ private SourceType(String typeName ) {
this.typeName = typeName;
}
+ /**
+ * Get the corresponding Hibernate {@link org.hibernate.type.VersionType} name.
+ *
+ * @return The corresponding type name.
+ */
public String typeName() {
return typeName;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SqlFragmentAlias.java b/hibernate-core/src/main/java/org/hibernate/annotations/SqlFragmentAlias.java
index 62d4ce9c7a..ce34022fdc 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SqlFragmentAlias.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SqlFragmentAlias.java
@@ -29,15 +29,27 @@ import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
/**
- * Describe aliases for filters
+ * Describe aliases for filters.
*
* @author Rob Worsnop
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface SqlFragmentAlias {
+ /**
+ * The alias within the fragment.
+ */
String alias();
+
+ /**
+ * The table corresponding to the alias.
+ */
String table() default "";
+
+ /**
+ * The entity class associated with the alias.
+ */
Class entity() default void.class;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Subselect.java b/hibernate-core/src/main/java/org/hibernate/annotations/Subselect.java
index 28cd043006..8ed3cd758d 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Subselect.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Subselect.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -29,12 +30,17 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Map an immutable and read-only entity to a given SQL subselect expression:
- * @author Sharath Reddy
+ * Map an immutable and read-only entity to a given SQL select expression.
*
+ * @see Synchronize
+ *
+ * @author Sharath Reddy
*/
@Target(TYPE)
@Retention(RUNTIME)
public @interface Subselect {
+ /**
+ * The query.
+ */
String value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Synchronize.java b/hibernate-core/src/main/java/org/hibernate/annotations/Synchronize.java
index 25e99e0958..fcdb41bedc 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Synchronize.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Synchronize.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -32,7 +33,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
* Ensures that auto-flush happens correctly and that queries against the derived
* entity do not return stale data.
*
- * Mostly used with Subselect.
+ * Mostly used with {@link Subselect}.
*
* @author Sharath Reddy
*/
@@ -40,7 +41,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface Synchronize {
/**
- * Table names
+ * Table names.
*/
- String [] value();
+ String[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Table.java b/hibernate-core/src/main/java/org/hibernate/annotations/Table.java
index f4c1119b6a..43338e0dc1 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Table.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Table.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -29,7 +30,7 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Complementary information to a table either primary or secondary
+ * Complementary information to a table either primary or secondary.
*
* @author Emmanuel Bernard
*/
@@ -37,23 +38,22 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface Table {
/**
- * name of the targeted table
+ * name of the targeted table.
*/
String appliesTo();
/**
- * Indexes
+ * Indexes.
*/
Index[] indexes() default {};
/**
- * define a table comment
+ * define a table comment.
*/
String comment() default "";
/**
- * Defines the Foreign Key name of a secondary table
- * pointing back to the primary table
+ * Defines the Foreign Key name of a secondary table pointing back to the primary table.
*/
ForeignKey foreignKey() default @ForeignKey( name="" );
@@ -86,21 +86,21 @@ public @interface Table {
boolean optional() default true;
/**
- * Defines a custom SQL insert statement
+ * Defines a custom SQL insert statement.
*
* Only applies to secondary tables
*/
SQLInsert sqlInsert() default @SQLInsert(sql="");
/**
- * Defines a custom SQL update statement
+ * Defines a custom SQL update statement.
*
* Only applies to secondary tables
*/
SQLUpdate sqlUpdate() default @SQLUpdate(sql="");
/**
- * Defines a custom SQL delete statement
+ * Defines a custom SQL delete statement.
*
* Only applies to secondary tables
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Tables.java b/hibernate-core/src/main/java/org/hibernate/annotations/Tables.java
index 2df5b35e47..6159ec2ceb 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Tables.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Tables.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -29,13 +30,15 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Plural of Table
+ * A grouping of tables.
*
* @author Emmanuel Bernard
- * @see Table
*/
@Target({TYPE})
@Retention(RUNTIME)
public @interface Tables {
+ /**
+ * The table grouping.
+ */
Table[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Target.java b/hibernate-core/src/main/java/org/hibernate/annotations/Target.java
index 480b273161..72dab62eb6 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Target.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Target.java
@@ -21,18 +21,22 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
+package org.hibernate.annotations;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
- * Define an explicit target,a voiding reflection and generics resolving
+ * Define an explicit target, avoiding reflection and generics resolving.
*
* @author Emmanuel Bernard
*/
@java.lang.annotation.Target({ElementType.FIELD, ElementType.METHOD})
@Retention( RetentionPolicy.RUNTIME )
public @interface Target {
+ /**
+ * The target entity type.
+ */
Class value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java
index c92e6e8864..1ad19ad6ff 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java
@@ -1,50 +1,58 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.annotations;
-import java.lang.annotation.Retention;
-
-import org.hibernate.EntityMode;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Define a tuplizer for an entity or a component
- * @author Emmanuel Bernard
- */
-@java.lang.annotation.Target( {TYPE, FIELD, METHOD} )
-@Retention( RUNTIME )
-public @interface Tuplizer {
- /** tuplizer implementation */
- Class impl();
- /**
- * either pojo, dynamic-map
- * @deprecated should use #entityModeType instead
- */
- @Deprecated
- String entityMode() default "pojo";
- EntityMode entityModeType() default EntityMode.POJO;
-}
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+import java.lang.annotation.Retention;
+
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import org.hibernate.EntityMode;
+/**
+ * Define a tuplizer for an entity or a component.
+ *
+ * @author Emmanuel Bernard
+ */
+@java.lang.annotation.Target( {TYPE, FIELD, METHOD} )
+@Retention( RUNTIME )
+public @interface Tuplizer {
+ /**
+ * Tuplizer implementation.
+ */
+ Class impl();
+
+ /**
+ * either pojo, dynamic-map or dom4j.
+ * @deprecated should use #entityModeType instead
+ */
+ @Deprecated
+ String entityMode() default "pojo";
+
+ /**
+ * The entity mode.
+ */
+ EntityMode entityModeType() default EntityMode.POJO;
+}
\ No newline at end of file
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizers.java b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizers.java
index 78924b842d..6a14061d01 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizers.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizers.java
@@ -21,17 +21,22 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
+package org.hibernate.annotations;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
- * Define a set of tuplizer for an entity or a component
+ * Grouping of tuplizers.
+ *
* @author Emmanuel Bernard
*/
@java.lang.annotation.Target( {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD} )
@Retention( RetentionPolicy.RUNTIME )
public @interface Tuplizers {
+ /**
+ * The grouping of tuplizers.
+ */
Tuplizer[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Type.java b/hibernate-core/src/main/java/org/hibernate/annotations/Type.java
index 3ca6583dc0..a3fc6d3ea7 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Type.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Type.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -30,14 +31,30 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * hibernate type
+ * Defines a Hibernate type mapping.
+ *
+ * @see org.hibernate.type.Type
+ * @see org.hibernate.usertype.UserType
+ * @see org.hibernate.usertype.CompositeUserType
+ *
+ * @see TypeDef
*
* @author Emmanuel Bernard
+ * @author Steve Ebersole
*/
@Target({FIELD, METHOD})
@Retention(RUNTIME)
public @interface Type {
+ /**
+ * The Hibernate type name. Usually the fully qualified name of an implementation class for
+ * {@link org.hibernate.type.Type}, {@link org.hibernate.usertype.UserType} or
+ * {@link org.hibernate.usertype.CompositeUserType}. May also refer to a type definition by name
+ * {@link TypeDef#name()}
+ */
String type();
+ /**
+ * Any configuration parameters for the named type.
+ */
Parameter[] parameters() default {};
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/TypeDef.java b/hibernate-core/src/main/java/org/hibernate/annotations/TypeDef.java
index 8b2d355266..f25825fec9 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/TypeDef.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/TypeDef.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -30,15 +31,38 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Type definition
+ * A type definition. Much like {@link Type}, but here we can centralize the definition under a name and
+ * refer to that name elsewhere.
+ *
+ * @see org.hibernate.type.Type
+ * @see org.hibernate.usertype.UserType
+ * @see org.hibernate.usertype.CompositeUserType
+ *
+ * @see Type
*
* @author Emmanuel Bernard
+ * @author Steve Ebersole
*/
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface TypeDef {
+ /**
+ * The type name. This is the name that would be used in other locations.
+ */
String name() default "";
- Class> defaultForType() default void.class;
+
+ /**
+ * The type implementation class.
+ */
Class> typeClass();
+
+ /**
+ * Name a java type for which this defined type should be the default mapping.
+ */
+ Class> defaultForType() default void.class;
+
+ /**
+ * Any configuration parameters for this type definition.
+ */
Parameter[] parameters() default {};
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/TypeDefs.java b/hibernate-core/src/main/java/org/hibernate/annotations/TypeDefs.java
index 9e562b4246..55542ad01b 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/TypeDefs.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/TypeDefs.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -30,12 +31,15 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Type definition array
+ * Grouping of type definitions.
*
* @author Emmanuel Bernard
*/
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface TypeDefs {
+ /**
+ * The grouping of type defs.
+ */
TypeDef[] value();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Where.java b/hibernate-core/src/main/java/org/hibernate/annotations/Where.java
index 3d60347b43..bd3e032d57 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/Where.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/Where.java
@@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.annotations;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -31,13 +32,16 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Where clause to add to the element Entity or target entity of a collection
- * The clause is written in SQL
+ * Where clause to add to the element Entity or target entity of a collection. The clause is written in SQL.
+ * A common use case here is for soft-deletes.
*
* @author Emmanuel Bernard
*/
@Target({TYPE, METHOD, FIELD})
@Retention(RUNTIME)
public @interface Where {
+ /**
+ * The where-clause predicate.
+ */
String clause();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/WhereJoinTable.java b/hibernate-core/src/main/java/org/hibernate/annotations/WhereJoinTable.java
index 9b9adf3d7d..f6f8357da9 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/WhereJoinTable.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/WhereJoinTable.java
@@ -21,20 +21,24 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.annotations;
+package org.hibernate.annotations;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Where clause to add to the colleciton join table
- * The clause is written in SQL
+ * Where clause to add to the collection join table. The clause is written in SQL. Just as with
+ * {@link Where}, a common use case is for implementing soft-deletes.
*
* @author Emmanuel Bernard
*/
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface WhereJoinTable {
+ /**
+ * The where-clause predicate.
+ */
String clause();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/package-info.java b/hibernate-core/src/main/java/org/hibernate/annotations/package-info.java
new file mode 100644
index 0000000000..a01041a44b
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Package containing all the Hibernate specific annotations.
+ */
+package org.hibernate.annotations;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java
index d7d9387225..1fd7854b2a 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java
@@ -26,8 +26,11 @@ package org.hibernate.boot.registry;
import org.hibernate.service.ServiceRegistry;
/**
- * Specialization of the {@link org.hibernate.service.ServiceRegistry} contract mainly to make the
- * {@link StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(BootstrapServiceRegistry)} signature type-safe
+ * Provides the most basic services needed. Class loading, etc.
+ *
+ * Specialized mainly for type safety.
+ *
+ * @see BootstrapServiceRegistryBuilder
*
* @author Steve Ebersole
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java
index 0108042470..ec3da4699c 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java
@@ -39,13 +39,15 @@ import org.hibernate.integrator.internal.IntegratorServiceImpl;
import org.hibernate.integrator.spi.Integrator;
/**
- * Builder for bootstrap {@link org.hibernate.service.ServiceRegistry} instances.
+ * Builder for {@link BootstrapServiceRegistry} instances. Provides registry for services needed for
+ * most operations. This includes {@link Integrator} handling and ClassLoader handling.
+ *
+ * Additionally responsible for building and managing the {@link org.hibernate.boot.registry.selector.spi.StrategySelector}
*
* @author Steve Ebersole
* @author Brett Meyer
*
- * @see BootstrapServiceRegistryImpl
- * @see StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistry)
+ * @see StandardServiceRegistryBuilder
*/
public class BootstrapServiceRegistryBuilder {
private final LinkedHashSet providedIntegrators = new LinkedHashSet();
@@ -53,12 +55,11 @@ public class BootstrapServiceRegistryBuilder {
private ClassLoaderService providedClassLoaderService;
private StrategySelectorBuilder strategySelectorBuilder = new StrategySelectorBuilder();
-
-
/**
* Add an {@link Integrator} to be applied to the bootstrap registry.
*
* @param integrator The integrator to add.
+ *
* @return {@code this}, for method chaining
*/
public BootstrapServiceRegistryBuilder with(Integrator integrator) {
@@ -67,7 +68,7 @@ public class BootstrapServiceRegistryBuilder {
}
/**
- * Adds a provided {@link ClassLoader} for use in class-loading and resource-lookup
+ * Adds a provided {@link ClassLoader} for use in class-loading and resource-lookup.
*
* @param classLoader The class loader to use
*
@@ -82,9 +83,9 @@ public class BootstrapServiceRegistryBuilder {
}
/**
- * Adds a provided {@link ClassLoaderService} for use in class-loading and resource-lookup
+ * Adds a provided {@link ClassLoaderService} for use in class-loading and resource-lookup.
*
- * @param classLoader The class loader to use
+ * @param classLoaderService The class loader service to use
*
* @return {@code this}, for method chaining
*/
@@ -94,9 +95,10 @@ public class BootstrapServiceRegistryBuilder {
}
/**
- * Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry
+ * Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry.
*
* @param classLoader The class loader to use
+ *
* @return {@code this}, for method chaining
*
* @deprecated Use {@link #with(ClassLoader)} instead
@@ -108,9 +110,10 @@ public class BootstrapServiceRegistryBuilder {
}
/**
- * Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry
+ * Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry.
*
* @param classLoader The class loader to use
+ *
* @return {@code this}, for method chaining
*
* @deprecated Use {@link #with(ClassLoader)} instead
@@ -122,9 +125,10 @@ public class BootstrapServiceRegistryBuilder {
}
/**
- * Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry
+ * Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry.
*
* @param classLoader The class loader to use
+ *
* @return {@code this}, for method chaining
*
* @deprecated Use {@link #with(ClassLoader)} instead
@@ -136,9 +140,10 @@ public class BootstrapServiceRegistryBuilder {
}
/**
- * Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry
+ * Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry.
*
* @param classLoader The class loader to use
+ *
* @return {@code this}, for method chaining
*
* @deprecated Use {@link #with(ClassLoader)} instead
@@ -150,11 +155,13 @@ public class BootstrapServiceRegistryBuilder {
}
/**
- * Applies a named strategy implementation to the bootstrap registry
+ * Applies a named strategy implementation to the bootstrap registry.
*
* @param strategy The strategy
* @param name The registered name
* @param implementation The strategy implementation Class
+ * @param Defines the strategy type and makes sure that the strategy and implementation are of
+ * compatible types.
*
* @return {@code this}, for method chaining
*
@@ -176,7 +183,7 @@ public class BootstrapServiceRegistryBuilder {
* @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class)
*/
@SuppressWarnings( {"UnusedDeclaration"})
- public BootstrapServiceRegistryBuilder withStrategySelectors(AvailabilityAnnouncer availabilityAnnouncer) {
+ public BootstrapServiceRegistryBuilder withStrategySelectors(AvailabilityAnnouncer availabilityAnnouncer) {
for ( Availability availability : availabilityAnnouncer.getAvailabilities() ) {
this.strategySelectorBuilder.addExplicitAvailability( availability );
}
@@ -200,7 +207,8 @@ public class BootstrapServiceRegistryBuilder {
}
classLoaderService = new ClassLoaderServiceImpl( classLoaders );
- } else {
+ }
+ else {
classLoaderService = providedClassLoaderService;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java
index ceeb6cb1e6..0f663102a6 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java
@@ -30,7 +30,9 @@ import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
- * Contract for an initiator of services that target the standard {@link org.hibernate.service.ServiceRegistry}
+ * Contract for an initiator of services that target the standard {@link org.hibernate.service.ServiceRegistry}.
+ *
+ * @param The type of the service initiated.
*
* @author Steve Ebersole
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java
index c6eb7bb5a3..b941ca0c2b 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java
@@ -28,7 +28,6 @@ import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.internal.ConfigLoader;
@@ -53,6 +52,9 @@ import org.hibernate.service.spi.ServiceContributor;
* @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
*/
public class StandardServiceRegistryBuilder {
+ /**
+ * The default resource name for a hibernate configuration xml file.
+ */
public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml";
private final Map settings;
@@ -63,7 +65,7 @@ public class StandardServiceRegistryBuilder {
private final ConfigLoader configLoader;
/**
- * Create a default builder
+ * Create a default builder.
*/
public StandardServiceRegistryBuilder() {
this( new BootstrapServiceRegistryBuilder().build() );
@@ -96,8 +98,10 @@ public class StandardServiceRegistryBuilder {
}
/**
- * Read settings from a {@link Properties} file. Differs from {@link #configure()} and {@link #configure(String)}
- * in that here we read a {@link Properties} file while for {@link #configure} we read the XML variant.
+ * Read settings from a {@link java.util.Properties} file by resource name.
+ *
+ * Differs from {@link #configure()} and {@link #configure(String)} in that here we expect to read a
+ * {@link java.util.Properties} file while for {@link #configure} we read the XML variant.
*
* @param resourceName The name by which to perform a resource look up for the properties file.
*
@@ -113,7 +117,7 @@ public class StandardServiceRegistryBuilder {
}
/**
- * Read setting information from an XML file using the standard resource location
+ * Read setting information from an XML file using the standard resource location.
*
* @return this, for method chaining
*
@@ -126,7 +130,7 @@ public class StandardServiceRegistryBuilder {
}
/**
- * Read setting information from an XML file using the named resource location
+ * Read setting information from an XML file using the named resource location.
*
* @param resourceName The named resource
*
@@ -136,7 +140,7 @@ public class StandardServiceRegistryBuilder {
*/
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryBuilder configure(String resourceName) {
- JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName );
+ final JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName );
for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
settings.put( xmlProperty.getName(), xmlProperty.getValue() );
}
@@ -145,7 +149,7 @@ public class StandardServiceRegistryBuilder {
}
/**
- * Apply a setting value
+ * Apply a setting value.
*
* @param settingName The name of the setting
* @param value The value to use.
@@ -159,7 +163,7 @@ public class StandardServiceRegistryBuilder {
}
/**
- * Apply a groups of setting values
+ * Apply a groups of setting values.
*
* @param settings The incoming settings to apply
*
@@ -185,7 +189,7 @@ public class StandardServiceRegistryBuilder {
}
/**
- * Adds a user-provided service
+ * Adds a user-provided service.
*
* @param serviceRole The role of the service being added
* @param service The service implementation
@@ -198,8 +202,14 @@ public class StandardServiceRegistryBuilder {
return this;
}
+ /**
+ * Build the StandardServiceRegistry.
+ *
+ * @return The StandardServiceRegistry.
+ */
+ @SuppressWarnings("unchecked")
public StandardServiceRegistry build() {
- Map,?> settingsCopy = new HashMap();
+ final Map,?> settingsCopy = new HashMap();
settingsCopy.putAll( settings );
Environment.verifyProperties( settingsCopy );
ConfigurationHelper.resolvePlaceHolders( settingsCopy );
@@ -220,8 +230,10 @@ public class StandardServiceRegistryBuilder {
}
private void applyServiceContributors() {
- LinkedHashSet serviceContributors =
- bootstrapServiceRegistry.getService( ClassLoaderService.class ).loadJavaServices( ServiceContributor.class );
+ final LinkedHashSet serviceContributors =
+ bootstrapServiceRegistry.getService( ClassLoaderService.class )
+ .loadJavaServices( ServiceContributor.class );
+
for ( ServiceContributor serviceContributor : serviceContributors ) {
serviceContributor.contribute( this );
}
@@ -230,6 +242,11 @@ public class StandardServiceRegistryBuilder {
/**
* Temporarily exposed since Configuration is still around and much code still uses Configuration. This allows
* code to configure the builder and access that to configure Configuration object (used from HEM atm).
+ *
+ * @return The settings map.
+ *
+ * @deprecated Temporarily exposed since Configuration is still around and much code still uses Configuration.
+ * This allows code to configure the builder and access that to configure Configuration object (used from HEM atm).
*/
@Deprecated
public Map getSettings() {
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java
index 3f43b04789..9b241bec24 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java
@@ -42,6 +42,7 @@ import org.jboss.logging.Logger;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.internal.util.ClassLoaderHelper;
/**
* Standard implementation of the service for interacting with class loaders
@@ -137,7 +138,7 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
private static ClassLoader locateTCCL() {
try {
- return Thread.currentThread().getContextClassLoader();
+ return ClassLoaderHelper.getContextClassLoader();
}
catch ( Exception e ) {
return null;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java
index cc4cbe4d02..25b94c726b 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java
@@ -31,15 +31,16 @@ import java.util.List;
import org.hibernate.service.Service;
/**
- * A service for interacting with class loaders
+ * A service for interacting with class loaders.
*
* @author Steve Ebersole
*/
public interface ClassLoaderService extends Service {
/**
- * Locate a class by name
+ * Locate a class by name.
*
* @param className The name of the class to locate
+ * @param The returned class type.
*
* @return The class reference
*
@@ -48,7 +49,7 @@ public interface ClassLoaderService extends Service {
public Class classForName(String className);
/**
- * Locate a resource by name (classpath lookup)
+ * Locate a resource by name (classpath lookup).
*
* @param name The resource name.
*
@@ -57,7 +58,7 @@ public interface ClassLoaderService extends Service {
public URL locateResource(String name);
/**
- * Locate a resource by name (classpath lookup) and gets its stream
+ * Locate a resource by name (classpath lookup) and gets its stream.
*
* @param name The resource name.
*
@@ -66,7 +67,7 @@ public interface ClassLoaderService extends Service {
public InputStream locateResourceStream(String name);
/**
- * Locate a series of resource by name (classpath lookup)
+ * Locate a series of resource by name (classpath lookup).
*
* @param name The resource name.
*
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java
index ce02f02f99..c34d16e874 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java
@@ -25,16 +25,27 @@ package org.hibernate.boot.registry.classloading.spi;
import org.hibernate.HibernateException;
/**
- * Indicates a problem performing class loading
+ * Indicates a problem performing class loading.
*
* @author Steve Ebersole
*/
public class ClassLoadingException extends HibernateException {
- public ClassLoadingException(String string, Throwable root) {
- super( string, root );
+ /**
+ * Constructs a ClassLoadingException using the specified message and cause.
+ *
+ * @param message A message explaining the exception condition.
+ * @param cause The underlying cause
+ */
+ public ClassLoadingException(String message, Throwable cause) {
+ super( message, cause );
}
- public ClassLoadingException(String s) {
- super( s );
+ /**
+ * Constructs a ClassLoadingException using the specified message.
+ *
+ * @param message A message explaining the exception condition.
+ */
+ public ClassLoadingException(String message) {
+ super( message );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/package-info.java
new file mode 100644
index 0000000000..14ba6b53aa
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * The class loading service SPI.
+ */
+package org.hibernate.boot.registry.classloading.spi;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/package-info.java
new file mode 100644
index 0000000000..88b77afdc4
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/package-info.java
@@ -0,0 +1,7 @@
+/**
+ * Defines service registry contracts application are likely to want to utilize for
+ * configuring Hibernate behavior.
+ *
+ * {@link BootstrapServiceRegistry} is the
+ */
+package org.hibernate.boot.registry;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java
index 658bbb7bed..20de189f6f 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java
@@ -24,10 +24,34 @@
package org.hibernate.boot.registry.selector;
/**
+ * Describes the availability of a named strategy implementation. A strategy + selector name should resolve
+ * to a single implementation.
+ *
+ * todo : better name?
+ *
+ * @param The type of the strategy described by this implementation availability.
+ *
* @author Steve Ebersole
*/
-public interface Availability {
- public Class getStrategyRole();
+public interface Availability {
+ /**
+ * The strategy role. Best practice says this should be an interface.
+ *
+ * @return The strategy contract/role.
+ */
+ public Class getStrategyRole();
+
+ /**
+ * Any registered names for this strategy availability.
+ *
+ * @return The registered selection names.
+ */
public Iterable getSelectorNames();
- public Class getStrategyImplementation();
+
+ /**
+ * The strategy implementation class.
+ *
+ * @return The strategy implementation.
+ */
+ public Class extends T> getStrategyImplementation();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java
index eddc5b3e7e..bcc365a887 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java
@@ -25,12 +25,17 @@ package org.hibernate.boot.registry.selector;
/**
* Responsible for announcing the availability of strategy selector(s). Can be registered directly with the
- * {@link org.hibernate.boot.registry.BootstrapServiceRegistry} or located via discovery
+ * {@link org.hibernate.boot.registry.BootstrapServiceRegistry} or located via discovery.
*
* todo : better name?
*
* @author Steve Ebersole
*/
public interface AvailabilityAnnouncer {
+ /**
+ * Get all availabilities announced by this announcer.
+ *
+ * @return All announced availabilities
+ */
public Iterable getAvailabilities();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java
index ad515ce1ab..ff536956ab 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java
@@ -26,31 +26,49 @@ package org.hibernate.boot.registry.selector;
import java.util.Arrays;
/**
+ * A simple implementation of Availability.
+ *
+ * @param The strategy type.
+ *
* @author Steve Ebersole
*/
-public class SimpleAvailabilityImpl implements Availability {
- private final Class strategyRole;
- private final Class strategyImplementation;
+public class SimpleAvailabilityImpl implements Availability {
+ private final Class strategyRole;
+ private final Class extends T> strategyImplementation;
private final Iterable selectorNames;
+ /**
+ * Constructs a SimpleAvailabilityImpl.
+ *
+ * @param strategyRole The strategy contract
+ * @param strategyImplementation The strategy implementation class
+ * @param selectorNames The selection/registration names for this implementation
+ */
public SimpleAvailabilityImpl(
- Class strategyRole,
- Class strategyImplementation,
+ Class strategyRole,
+ Class extends T> strategyImplementation,
Iterable selectorNames) {
this.strategyRole = strategyRole;
this.strategyImplementation = strategyImplementation;
this.selectorNames = selectorNames;
}
+ /**
+ * Constructs a SimpleAvailabilityImpl.
+ *
+ * @param strategyRole The strategy contract
+ * @param strategyImplementation The strategy implementation class
+ * @param selectorNames The selection/registration names for this implementation
+ */
public SimpleAvailabilityImpl(
- Class strategyRole,
- Class strategyImplementation,
+ Class strategyRole,
+ Class extends T> strategyImplementation,
String... selectorNames) {
this( strategyRole, strategyImplementation, Arrays.asList( selectorNames ) );
}
@Override
- public Class getStrategyRole() {
+ public Class getStrategyRole() {
return strategyRole;
}
@@ -60,7 +78,7 @@ public class SimpleAvailabilityImpl implements Availability {
}
@Override
- public Class getStrategyImplementation() {
+ public Class extends T> getStrategyImplementation() {
return strategyImplementation;
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java
index f163635050..0850823954 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java
@@ -99,6 +99,8 @@ import org.hibernate.hql.spi.PersistentTableBulkIdStrategy;
import org.hibernate.hql.spi.TemporaryTableBulkIdStrategy;
/**
+ * Builder for StrategySelector instances.
+ *
* @author Steve Ebersole
*/
public class StrategySelectorBuilder {
@@ -106,15 +108,31 @@ public class StrategySelectorBuilder {
private final List explicitAvailabilities = new ArrayList();
+ /**
+ * Adds an explicit (as opposed to discovered) strategy availability.
+ *
+ * @param strategy The strategy
+ * @param implementation The strategy implementation
+ * @param name The registered name
+ * @param The type of the strategy. Used to make sure that the strategy and implementation are type
+ * compatible.
+ */
@SuppressWarnings("unchecked")
public void addExplicitAvailability(Class strategy, Class extends T> implementation, String name) {
- addExplicitAvailability( new SimpleAvailabilityImpl( strategy, implementation, name ) );
+ addExplicitAvailability( new SimpleAvailabilityImpl( strategy, implementation, name ) );
}
- public void addExplicitAvailability(Availability availability) {
+ /**
+ * Adds an explicit (as opposed to discovered) strategy availability.
+ *
+ * @param availability The strategy implementation availability.
+ * @param The type of the strategy. Used to make sure that the strategy and implementation are type
+ * compatible.
+ */
+ public void addExplicitAvailability(Availability availability) {
if ( !availability.getStrategyRole().isInterface() ) {
// not good form...
- log.debug( "Registering non-interface strategy implementation : " + availability.getStrategyRole().getName() );
+ log.debug( "Registering non-interface strategy : " + availability.getStrategyRole().getName() );
}
if ( ! availability.getStrategyRole().isAssignableFrom( availability.getStrategyImplementation() ) ) {
@@ -127,8 +145,16 @@ public class StrategySelectorBuilder {
explicitAvailabilities.add( availability );
}
+ /**
+ * Builds the selector.
+ *
+ * @param classLoaderService The class loading service used to (attempt to) resolve any un-registered
+ * strategy implementations.
+ *
+ * @return The selector.
+ */
public StrategySelector buildSelector(ClassLoaderService classLoaderService) {
- StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
+ final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
// build the baseline...
addDialects( strategySelector );
@@ -152,7 +178,7 @@ public class StrategySelectorBuilder {
}
@SuppressWarnings("unchecked")
- private void applyFromAvailability(StrategySelectorImpl strategySelector, Availability availability) {
+ private void applyFromAvailability(StrategySelectorImpl strategySelector, Availability availability) {
for ( String name : availability.getSelectorNames() ) {
strategySelector.registerStrategyImplementor(
availability.getStrategyRole(),
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java
index 9d7c6b98e4..69d3e003b8 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java
@@ -35,6 +35,8 @@ import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
/**
+ * Standard implementation of the StrategySelector contract.
+ *
* @author Steve Ebersole
*/
public class StrategySelectorImpl implements StrategySelector {
@@ -45,6 +47,11 @@ public class StrategySelectorImpl implements StrategySelector {
private final ClassLoaderService classLoaderService;
+ /**
+ * Constructs a StrategySelectorImpl using the given class loader service.
+ *
+ * @param classLoaderService The class loader service usable by this StrategySelectorImpl instance.
+ */
public StrategySelectorImpl(ClassLoaderService classLoaderService) {
this.classLoaderService = classLoaderService;
}
@@ -57,7 +64,7 @@ public class StrategySelectorImpl implements StrategySelector {
namedStrategyImplementorByStrategyMap.put( strategy, namedStrategyImplementorMap );
}
- Class old = namedStrategyImplementorMap.put( name, implementation );
+ final Class old = namedStrategyImplementorMap.put( name, implementation );
if ( old == null ) {
log.trace(
String.format(
@@ -83,7 +90,7 @@ public class StrategySelectorImpl implements StrategySelector {
@Override
public void unRegisterStrategyImplementor(Class strategy, Class extends T> implementation) {
- Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
+ final Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
if ( namedStrategyImplementorMap == null ) {
log.debug( "Named strategy map did not exist on call to un-register" );
return;
@@ -106,7 +113,7 @@ public class StrategySelectorImpl implements StrategySelector {
@Override
@SuppressWarnings("unchecked")
public Class extends T> selectStrategyImplementor(Class strategy, String name) {
- Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
+ final Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
if ( namedStrategyImplementorMap != null ) {
final Class registered = namedStrategyImplementorMap.get( name );
if ( registered != null ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java
index 095e5ca34b..be46a2f644 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java
@@ -1 +1,5 @@
-package org.hibernate.boot.registry.selector;
\ No newline at end of file
+/**
+ * Defines a feature-set around named registration of implementations of various contracts and the ability
+ * to select those implementations.
+ */
+package org.hibernate.boot.registry.selector;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java
index 01b63580be..118bda69a0 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java
@@ -26,14 +26,27 @@ package org.hibernate.boot.registry.selector.spi;
import org.hibernate.HibernateException;
/**
+ * Indicates a problem performing the selection/resolution.
+ *
* @author Steve Ebersole
*/
public class StrategySelectionException extends HibernateException {
+ /**
+ * Constructs a StrategySelectionException using the specified message.
+ *
+ * @param message A message explaining the exception condition.
+ */
public StrategySelectionException(String message) {
super( message );
}
- public StrategySelectionException(String message, Throwable root) {
- super( message, root );
+ /**
+ * Constructs a StrategySelectionException using the specified message and cause.
+ *
+ * @param message A message explaining the exception condition.
+ * @param cause The underlying cause.
+ */
+ public StrategySelectionException(String message, Throwable cause) {
+ super( message, cause );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java
index 21012a25fb..5438f940ca 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java
@@ -37,6 +37,8 @@ public interface StrategySelector extends Service {
* @param strategy The strategy contract.
* @param name The registration name
* @param implementation The implementation Class
+ * @param The type of the strategy. Used to make sure that the strategy and implementation are type
+ * compatible.
*/
public void registerStrategyImplementor(Class strategy, String name, Class extends T> implementation);
@@ -46,6 +48,8 @@ public interface StrategySelector extends Service {
*
* @param strategy The strategy contract.
* @param implementation The implementation Class
+ * @param The type of the strategy. Used to make sure that the strategy and implementation are type
+ * compatible.
*/
public void unRegisterStrategyImplementor(Class strategy, Class extends T> implementation);
@@ -54,6 +58,8 @@ public interface StrategySelector extends Service {
*
* @param strategy The type of strategy to be resolved.
* @param name The name of the strategy to locate; might be either a registered name or the implementation FQN.
+ * @param The type of the strategy. Used to make sure that the strategy and implementation are type
+ * compatible.
*
* @return The named strategy implementation class.
*/
@@ -65,6 +71,8 @@ public interface StrategySelector extends Service {
*
* @param strategy The type (interface) of the strategy to be resolved.
* @param strategyReference The reference to the strategy for which we need to resolve an instance.
+ * @param The type of the strategy. Used to make sure that the strategy and implementation are type
+ * compatible.
*
* @return The strategy instance
*/
@@ -91,6 +99,8 @@ public interface StrategySelector extends Service {
* @param strategy The type (interface) of the strategy to be resolved.
* @param strategyReference The reference to the strategy for which we need to resolve an instance.
* @param defaultValue THe default value to use if strategyReference is null
+ * @param The type of the strategy. Used to make sure that the strategy and implementation are type
+ * compatible.
*
* @return The strategy instance
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/package-info.java
new file mode 100644
index 0000000000..ccad0b4e71
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Defines actual contract used for strategy selection : {@link StrategySelector}.
+ */
+package org.hibernate.boot.registry.selector.spi;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
index 2c36c31f1c..a71318d31f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
@@ -111,6 +111,7 @@ import org.hibernate.annotations.GenericGenerators;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
+import org.hibernate.annotations.ListIndexBase;
import org.hibernate.annotations.ManyToAny;
import org.hibernate.annotations.MapKeyType;
import org.hibernate.annotations.NaturalId;
@@ -125,6 +126,8 @@ import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Parent;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.Sort;
+import org.hibernate.annotations.SortComparator;
+import org.hibernate.annotations.SortNatural;
import org.hibernate.annotations.Source;
import org.hibernate.annotations.Tuplizer;
import org.hibernate.annotations.Tuplizers;
@@ -1466,7 +1469,8 @@ public final class AnnotationBinder {
* ordering does not matter
*/
- if ( LOG.isTraceEnabled() ) {
+ final boolean traceEnabled = LOG.isTraceEnabled();
+ if ( traceEnabled ) {
LOG.tracev( "Processing annotations of {0}.{1}" , propertyHolder.getEntityName(), inferredData.getPropertyName() );
}
@@ -1532,7 +1536,7 @@ public final class AnnotationBinder {
+ propertyHolder.getEntityName()
);
}
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "{0} is a version property", inferredData.getPropertyName() );
}
RootClass rootClass = ( RootClass ) propertyHolder.getPersistentClass();
@@ -1558,7 +1562,7 @@ public final class AnnotationBinder {
SimpleValue simpleValue = ( SimpleValue ) prop.getValue();
simpleValue.setNullValue( "undefined" );
rootClass.setOptimisticLockMode( Versioning.OPTIMISTIC_LOCK_VERSION );
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Version name: {0}, unsavedValue: {1}", rootClass.getVersion().getName(),
( (SimpleValue) rootClass.getVersion().getValue() ).getNullValue() );
}
@@ -1701,6 +1705,9 @@ public final class AnnotationBinder {
entityBinder.getSecondaryTables(),
mappings
);
+ if ( property.isAnnotationPresent( ListIndexBase.class ) ) {
+ indexColumn.setBase( ( property.getAnnotation( ListIndexBase.class ) ).value() );
+ }
}
else {
//if @IndexColumn is not there, the generated IndexColumn is an implicit column and not used.
@@ -1722,14 +1729,16 @@ public final class AnnotationBinder {
collectionBinder.setIndexColumn( indexColumn );
collectionBinder.setMapKey( property.getAnnotation( MapKey.class ) );
collectionBinder.setPropertyName( inferredData.getPropertyName() );
- BatchSize batchAnn = property.getAnnotation( BatchSize.class );
- collectionBinder.setBatchSize( batchAnn );
- javax.persistence.OrderBy ejb3OrderByAnn = property.getAnnotation( javax.persistence.OrderBy.class );
- OrderBy orderByAnn = property.getAnnotation( OrderBy.class );
- collectionBinder.setEjb3OrderBy( ejb3OrderByAnn );
- collectionBinder.setSqlOrderBy( orderByAnn );
- Sort sortAnn = property.getAnnotation( Sort.class );
- collectionBinder.setSort( sortAnn );
+
+ collectionBinder.setBatchSize( property.getAnnotation( BatchSize.class ) );
+
+ collectionBinder.setJpaOrderBy( property.getAnnotation( javax.persistence.OrderBy.class ) );
+ collectionBinder.setSqlOrderBy( property.getAnnotation( OrderBy.class ) );
+
+ collectionBinder.setSort( property.getAnnotation( Sort.class ) );
+ collectionBinder.setNaturalSort( property.getAnnotation( SortNatural.class ) );
+ collectionBinder.setComparatorSort( property.getAnnotation( SortComparator.class ) );
+
Cache cachAnn = property.getAnnotation( Cache.class );
collectionBinder.setCache( cachAnn );
collectionBinder.setPropertyHolder( propertyHolder );
@@ -2091,12 +2100,12 @@ public final class AnnotationBinder {
if ( naturalIdAnn != null ) {
if ( joinColumns != null ) {
for ( Ejb3Column column : joinColumns ) {
- column.addUniqueKey( StringHelper.randomFixedLengthHex("UK_"), inSecondPass );
+ column.addUniqueKey( column.getTable().getNaturalIdUniqueKeyName(), inSecondPass );
}
}
else {
for ( Ejb3Column column : columns ) {
- column.addUniqueKey( StringHelper.randomFixedLengthHex("UK_"), inSecondPass );
+ column.addUniqueKey( column.getTable().getNaturalIdUniqueKeyName(), inSecondPass );
}
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java b/hibernate-core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
index 89a6a676ee..d7a3efac6b 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
@@ -61,12 +61,15 @@ public abstract class CollectionSecondPass implements SecondPass {
public void doSecondPass(java.util.Map persistentClasses)
throws MappingException {
- LOG.debugf( "Second pass for collection: %s", collection.getRole() );
+ final boolean debugEnabled = LOG.isDebugEnabled();
+ if ( debugEnabled ) {
+ LOG.debugf( "Second pass for collection: %s", collection.getRole() );
+ }
secondPass( persistentClasses, localInheritedMetas ); // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
collection.createAllKeys();
- if ( LOG.isDebugEnabled() ) {
+ if ( debugEnabled ) {
String msg = "Mapped collection key: " + columns( collection.getKey() );
if ( collection.isIndexed() )
msg += ", index: " + columns( ( (IndexedCollection) collection ).getIndex() );
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
index 43d7af4585..8f3557f6e6 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
@@ -1190,7 +1190,9 @@ public class Configuration implements Serializable {
Iterator uniqueIter = table.getUniqueKeyIterator();
while ( uniqueIter.hasNext() ) {
final UniqueKey uniqueKey = (UniqueKey) uniqueIter.next();
- // Skip if index already exists
+ // Skip if index already exists. Most of the time, this
+ // won't work since most Dialects use Constraints. However,
+ // keep it for the few that do use Indexes.
if ( tableInfo != null && StringHelper.isNotEmpty( uniqueKey.getName() ) ) {
final IndexMetadata meta = tableInfo.getIndexMetadata( uniqueKey.getName() );
if ( meta != null ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java b/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java
index 0e63016139..9dad56567f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java
@@ -26,6 +26,8 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import org.jboss.logging.Logger;
+
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
@@ -33,12 +35,15 @@ import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
/**
* @author Emmanuel Bernard
*/
public class CopyIdentifierComponentSecondPass implements SecondPass {
+ private static final Logger log = Logger.getLogger( CopyIdentifierComponentSecondPass.class );
+
private final String referencedEntityName;
private final Component component;
private final Mappings mappings;
@@ -113,7 +118,7 @@ public class CopyIdentifierComponentSecondPass implements SecondPass {
final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue();
value.setTypeName( referencedValue.getTypeName() );
value.setTypeParameters( referencedValue.getTypeParameters() );
- final Iterator columns = referencedValue.getColumnIterator();
+ final Iterator columns = referencedValue.getColumnIterator();
if ( joinColumns[0].isNameDeferred() ) {
joinColumns[0].copyReferencedStructureAndCreateDefaultJoinColumns(
@@ -124,7 +129,12 @@ public class CopyIdentifierComponentSecondPass implements SecondPass {
else {
//FIXME take care of Formula
while ( columns.hasNext() ) {
- Column column = columns.next();
+ final Selectable selectable = columns.next();
+ if ( ! Column.class.isInstance( selectable ) ) {
+ log.debug( "Encountered formula definition; skipping" );
+ continue;
+ }
+ final Column column = (Column) selectable;
final Ejb3JoinColumn joinColumn;
String logicalColumnName = null;
if ( isExplicitReference ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java
index 270ed3192a..bcc79fd21f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java
@@ -556,7 +556,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
);
}
catch (MappingException e) {
- throw new RecoverableException(e);
+ throw new RecoverableException( e.getMessage(), e );
}
}
Table matchingTable = columnOwner instanceof PersistentClass ?
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
index 424a41eea3..a46b925059 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
@@ -2621,6 +2621,7 @@ public final class HbmBinder {
"not valid within collection using join fetching [" + collection.getRole() + "]"
);
}
+ final boolean debugEnabled = LOG.isDebugEnabled();
while ( filters.hasNext() ) {
final Element filterElement = ( Element ) filters.next();
final String name = filterElement.attributeValue( "name" );
@@ -2638,7 +2639,7 @@ public final class HbmBinder {
Element alias = (Element) aliasesIterator.next();
aliasTables.put(alias.attributeValue("alias"), alias.attributeValue("table"));
}
- if ( LOG.isDebugEnabled() ) {
+ if ( debugEnabled ) {
LOG.debugf( "Applying many-to-many filter [%s] as [%s] to role [%s]", name, condition, collection.getRole() );
}
String autoAliasInjectionText = filterElement.attributeValue("autoAliasInjection");
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java b/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java
index 36a4898346..893850342f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java
@@ -77,17 +77,27 @@ public class IndexColumn extends Ejb3Column {
this.base = base;
}
- //JPA 2 @OrderColumn processing
+ /**
+ * JPA 2 {@link OrderColumn @OrderColumn} processing.
+ *
+ * @param ann The OrderColumn annotation instance
+ * @param propertyHolder Information about the property
+ * @param inferredData Yeah, right. Uh...
+ * @param secondaryTables Any secondary tables available.
+ * @param mappings The mappings being built.
+ *
+ * @return The index column
+ */
public static IndexColumn buildColumnFromAnnotation(
OrderColumn ann,
PropertyHolder propertyHolder,
PropertyData inferredData,
Map secondaryTables,
Mappings mappings) {
- IndexColumn column;
+ final IndexColumn column;
if ( ann != null ) {
- String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition();
- String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() + "_ORDER" : ann.name();
+ final String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition();
+ final String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() + "_ORDER" : ann.name();
//TODO move it to a getter based system and remove the constructor
// The JPA OrderColumn annotation defines no table element...
// column = new IndexColumn(
@@ -110,16 +120,25 @@ public class IndexColumn extends Ejb3Column {
return column;
}
- //legacy @IndexColumn processing
+ /**
+ * Legacy {@link IndexColumn @IndexColumn} processing.
+ *
+ * @param ann The IndexColumn annotation instance
+ * @param propertyHolder Information about the property
+ * @param inferredData Yeah, right. Uh...
+ * @param mappings The mappings being built.
+ *
+ * @return The index column
+ */
public static IndexColumn buildColumnFromAnnotation(
org.hibernate.annotations.IndexColumn ann,
PropertyHolder propertyHolder,
PropertyData inferredData,
Mappings mappings) {
- IndexColumn column;
+ final IndexColumn column;
if ( ann != null ) {
- String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition();
- String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() : ann.name();
+ final String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition();
+ final String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() : ann.name();
//TODO move it to a getter based system and remove the constructor
column = new IndexColumn(
false, sqlType, 0, 0, 0, name, ann.nullable(),
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/RecoverableException.java b/hibernate-core/src/main/java/org/hibernate/cfg/RecoverableException.java
index 3b320f1041..daa351da5b 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/RecoverableException.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/RecoverableException.java
@@ -22,25 +22,35 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
+
import org.hibernate.AnnotationException;
/**
- * Should neven be exposed to the client
- * An exception that wrap an underlying exception whith the hope
- * subsequent processing will recover from it.
+ * An exception that indicates a condition where the hope is that subsequent processing will be able to
+ * recover from it.
+ *
+ * @deprecated Was only ever referenced in a single place, in an extremely dubious way.
*
* @author Emmanuel Bernard
*/
+@Deprecated
public class RecoverableException extends AnnotationException {
- public RecoverableException(String msg, Throwable root) {
- super( msg, root );
+ /**
+ * Constructs a RecoverableException using the given message and underlying cause.
+ *
+ * @param msg The message explaining the condition that caused the exception
+ * @param cause The underlying exception
+ */
+ public RecoverableException(String msg, Throwable cause) {
+ super( msg, cause );
}
- public RecoverableException(Throwable root) {
- super( root );
- }
-
- public RecoverableException(String s) {
- super( s );
+ /**
+ * Constructs a RecoverableException using the given message and underlying cause.
+ *
+ * @param msg
+ */
+ public RecoverableException(String msg) {
+ super( msg );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BagBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BagBinder.java
index c0490c57e2..a38756c9fe 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BagBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BagBinder.java
@@ -31,8 +31,8 @@ import org.hibernate.mapping.PersistentClass;
* @author Matthew Inger
*/
public class BagBinder extends CollectionBinder {
-
public BagBinder() {
+ super( false );
}
protected Collection createCollection(PersistentClass persistentClass) {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
index 3bc288cd2e..91122cc6e1 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
@@ -70,6 +70,8 @@ import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.Sort;
+import org.hibernate.annotations.SortComparator;
+import org.hibernate.annotations.SortNatural;
import org.hibernate.annotations.SortType;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.WhereJoinTable;
@@ -138,11 +140,6 @@ public abstract class CollectionBinder {
String cacheRegionName;
private boolean oneToMany;
protected IndexColumn indexColumn;
- private String orderBy;
- protected String hqlOrderBy;
- private boolean isSorted;
- private Class comparator;
- private boolean hasToBeSorted;
protected boolean cascadeDeleteEnabled;
protected String mapKeyPropertyName;
private boolean insertable = true;
@@ -163,6 +160,13 @@ public abstract class CollectionBinder {
private AccessType accessType;
private boolean hibernateExtensionMapping;
+ private boolean isSortedCollection;
+ private javax.persistence.OrderBy jpaOrderBy;
+ private OrderBy sqlOrderBy;
+ private Sort deprecatedSort;
+ private SortNatural naturalSort;
+ private SortComparator comparatorSort;
+
private String explicitType;
private Properties explicitTypeParameters = new Properties();
@@ -220,27 +224,24 @@ public abstract class CollectionBinder {
this.batchSize = batchSize == null ? -1 : batchSize.size();
}
- public void setEjb3OrderBy(javax.persistence.OrderBy orderByAnn) {
- if ( orderByAnn != null ) {
- hqlOrderBy = orderByAnn.value();
- }
+ public void setJpaOrderBy(javax.persistence.OrderBy jpaOrderBy) {
+ this.jpaOrderBy = jpaOrderBy;
}
- public void setSqlOrderBy(OrderBy orderByAnn) {
- if ( orderByAnn != null ) {
- if ( !BinderHelper.isEmptyAnnotationValue( orderByAnn.clause() ) ) {
- orderBy = orderByAnn.clause();
- }
- }
+ public void setSqlOrderBy(OrderBy sqlOrderBy) {
+ this.sqlOrderBy = sqlOrderBy;
}
- public void setSort(Sort sortAnn) {
- if ( sortAnn != null ) {
- isSorted = !SortType.UNSORTED.equals( sortAnn.type() );
- if ( isSorted && SortType.COMPARATOR.equals( sortAnn.type() ) ) {
- comparator = sortAnn.comparator();
- }
- }
+ public void setSort(Sort deprecatedSort) {
+ this.deprecatedSort = deprecatedSort;
+ }
+
+ public void setNaturalSort(SortNatural naturalSort) {
+ this.naturalSort = naturalSort;
+ }
+
+ public void setComparatorSort(SortComparator comparatorSort) {
+ this.comparatorSort = comparatorSort;
}
/**
@@ -252,7 +253,7 @@ public abstract class CollectionBinder {
boolean isIndexed,
boolean isHibernateExtensionMapping,
Mappings mappings) {
- CollectionBinder result;
+ final CollectionBinder result;
if ( property.isArray() ) {
if ( property.getElementClass().isPrimitive() ) {
result = new PrimitiveArrayBinder();
@@ -269,7 +270,7 @@ public abstract class CollectionBinder {
throw new AnnotationException( "Set do not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
- result = new SetBinder();
+ result = new SetBinder( false );
}
else if ( java.util.SortedSet.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
@@ -283,7 +284,7 @@ public abstract class CollectionBinder {
throw new AnnotationException( "Map do not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
- result = new MapBinder();
+ result = new MapBinder( false );
}
else if ( java.util.SortedMap.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
@@ -351,11 +352,8 @@ public abstract class CollectionBinder {
return result;
}
- protected CollectionBinder() {
- }
-
- protected CollectionBinder(boolean sorted) {
- this.hasToBeSorted = sorted;
+ protected CollectionBinder(boolean isSortedCollection) {
+ this.isSortedCollection = isSortedCollection;
}
public void setMappedBy(String mappedBy) {
@@ -427,11 +425,6 @@ public abstract class CollectionBinder {
//set laziness
defineFetchingStrategy();
collection.setBatchSize( batchSize );
- if ( orderBy != null && hqlOrderBy != null ) {
- throw new AnnotationException(
- "Cannot use sql order by clause in conjunction of EJB3 order by clause: " + safeCollectionRole()
- );
- }
collection.setMutable( !property.isAnnotationPresent( Immutable.class ) );
@@ -449,36 +442,7 @@ public abstract class CollectionBinder {
collection.setCollectionPersisterClass( persisterAnn.impl() );
}
- // set ordering
- if ( orderBy != null ) collection.setOrderBy( orderBy );
- if ( isSorted ) {
- collection.setSorted( true );
- if ( comparator != null ) {
- try {
- collection.setComparator( (Comparator) comparator.newInstance() );
- }
- catch (ClassCastException e) {
- throw new AnnotationException(
- "Comparator not implementing java.util.Comparator class: "
- + comparator.getName() + "(" + safeCollectionRole() + ")"
- );
- }
- catch (Exception e) {
- throw new AnnotationException(
- "Could not instantiate comparator class: "
- + comparator.getName() + "(" + safeCollectionRole() + ")"
- );
- }
- }
- }
- else {
- if ( hasToBeSorted ) {
- throw new AnnotationException(
- "A sorted collection has to define @Sort: "
- + safeCollectionRole()
- );
- }
- }
+ applySortingAndOrdering( collection );
//set cache
if ( StringHelper.isNotEmpty( cacheConcurrencyStrategy ) ) {
@@ -577,6 +541,99 @@ public abstract class CollectionBinder {
propertyHolder.addProperty( prop, declaringClass );
}
+ private void applySortingAndOrdering(Collection collection) {
+ boolean isSorted = isSortedCollection;
+
+ boolean hadOrderBy = false;
+ boolean hadExplicitSort = false;
+
+ Class extends Comparator> comparatorClass = null;
+
+ if ( jpaOrderBy == null && sqlOrderBy == null ) {
+ if ( deprecatedSort != null ) {
+ LOG.debug( "Encountered deprecated @Sort annotation; use @SortNatural or @SortComparator instead." );
+ if ( naturalSort != null || comparatorSort != null ) {
+ throw buildIllegalSortCombination();
+ }
+ hadExplicitSort = deprecatedSort.type() != SortType.UNSORTED;
+ if ( deprecatedSort.type() == SortType.NATURAL ) {
+ isSorted = true;
+ }
+ else if ( deprecatedSort.type() == SortType.COMPARATOR ) {
+ isSorted = true;
+ comparatorClass = deprecatedSort.comparator();
+ }
+ }
+ else if ( naturalSort != null ) {
+ if ( comparatorSort != null ) {
+ throw buildIllegalSortCombination();
+ }
+ hadExplicitSort = true;
+ }
+ else if ( comparatorSort != null ) {
+ hadExplicitSort = true;
+ comparatorClass = comparatorSort.value();
+ }
+ }
+ else {
+ if ( jpaOrderBy != null && sqlOrderBy != null ) {
+ throw new AnnotationException(
+ String.format(
+ "Illegal combination of @%s and @%s on %s",
+ javax.persistence.OrderBy.class.getName(),
+ OrderBy.class.getName(),
+ safeCollectionRole()
+ )
+ );
+ }
+
+ hadOrderBy = true;
+ hadExplicitSort = false;
+
+ // we can only apply the sql-based order by up front. The jpa order by has to wait for second pass
+ if ( sqlOrderBy != null ) {
+ collection.setOrderBy( sqlOrderBy.clause() );
+ }
+ }
+
+ if ( isSortedCollection ) {
+ if ( ! hadExplicitSort && !hadOrderBy ) {
+ throw new AnnotationException(
+ "A sorted collection must define and ordering or sorting : " + safeCollectionRole()
+ );
+ }
+ }
+
+ collection.setSorted( isSortedCollection || hadExplicitSort );
+
+ if ( comparatorClass != null ) {
+ try {
+ collection.setComparator( comparatorClass.newInstance() );
+ }
+ catch (Exception e) {
+ throw new AnnotationException(
+ String.format(
+ "Could not instantiate comparator class [%s] for %s",
+ comparatorClass.getName(),
+ safeCollectionRole()
+ )
+ );
+ }
+ }
+ }
+
+ private AnnotationException buildIllegalSortCombination() {
+ return new AnnotationException(
+ String.format(
+ "Illegal combination of annotations on %s. Only one of @%s, @%s and @%s can be used",
+ safeCollectionRole(),
+ Sort.class.getName(),
+ SortNatural.class.getName(),
+ SortComparator.class.getName()
+ )
+ );
+ }
+
private void defineFetchingStrategy() {
LazyCollection lazy = property.getAnnotation( LazyCollection.class );
Fetch fetch = property.getAnnotation( Fetch.class );
@@ -722,7 +779,7 @@ public abstract class CollectionBinder {
fkJoinColumns,
collType,
cascadeDeleteEnabled,
- ignoreNotFound, hqlOrderBy,
+ ignoreNotFound,
mappings,
inheritanceStatePerClass
);
@@ -739,7 +796,10 @@ public abstract class CollectionBinder {
isEmbedded, collType,
ignoreNotFound, unique,
cascadeDeleteEnabled,
- associationTableBinder, property, propertyHolder, hqlOrderBy, mappings
+ associationTableBinder,
+ property,
+ propertyHolder,
+ mappings
);
return false;
}
@@ -752,10 +812,11 @@ public abstract class CollectionBinder {
XClass collectionType,
boolean cascadeDeleteEnabled,
boolean ignoreNotFound,
- String hqlOrderBy,
Mappings mappings,
Map inheritanceStatePerClass) {
- if ( LOG.isDebugEnabled() ) {
+
+ final boolean debugEnabled = LOG.isDebugEnabled();
+ if ( debugEnabled ) {
LOG.debugf( "Binding a OneToMany: %s.%s through a foreign key", propertyHolder.getEntityName(), propertyName );
}
org.hibernate.mapping.OneToMany oneToMany = new org.hibernate.mapping.OneToMany( mappings, collection.getOwner() );
@@ -765,8 +826,20 @@ public abstract class CollectionBinder {
String assocClass = oneToMany.getReferencedEntityName();
PersistentClass associatedClass = (PersistentClass) persistentClasses.get( assocClass );
- String orderBy = buildOrderByClauseFromHql( hqlOrderBy, associatedClass, collection.getRole() );
- if ( orderBy != null ) collection.setOrderBy( orderBy );
+ if ( jpaOrderBy != null ) {
+ final String jpaOrderByFragment = jpaOrderBy.value();
+ if ( StringHelper.isNotEmpty( jpaOrderByFragment ) ) {
+ final String orderByFragment = buildOrderByClauseFromHql(
+ jpaOrderBy.value(),
+ associatedClass,
+ collection.getRole()
+ );
+ if ( StringHelper.isNotEmpty( orderByFragment ) ) {
+ collection.setOrderBy( orderByFragment );
+ }
+ }
+ }
+
if ( mappings == null ) {
throw new AssertionFailure(
"CollectionSecondPass for oneToMany should not be called with null mappings"
@@ -784,7 +857,7 @@ public abstract class CollectionBinder {
column.setJoins( joins );
collection.setCollectionTable( column.getTable() );
}
- if ( LOG.isDebugEnabled() ) {
+ if ( debugEnabled ) {
LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() );
}
bindFilters( false );
@@ -1065,10 +1138,10 @@ public abstract class CollectionBinder {
TableBinder associationTableBinder,
XProperty property,
PropertyHolder parentPropertyHolder,
- final String hqlOrderBy,
Mappings mappings) throws MappingException {
-
PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType.getName() );
+ final String hqlOrderBy = extractHqlOrderBy( jpaOrderBy );
+
boolean isCollectionOfEntities = collectionEntity != null;
ManyToAny anyAnn = property.getAnnotation( ManyToAny.class );
if (LOG.isDebugEnabled()) {
@@ -1190,7 +1263,7 @@ public abstract class CollectionBinder {
element.setFetchMode( FetchMode.JOIN );
element.setLazy( false );
element.setIgnoreNotFound( ignoreNotFound );
- // as per 11.1.38 of JPA-2 spec, default to primary key if no column is specified by @OrderBy.
+ // as per 11.1.38 of JPA 2.0 spec, default to primary key if no column is specified by @OrderBy.
if ( hqlOrderBy != null ) {
collValue.setManyToManyOrdering(
buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
@@ -1335,6 +1408,16 @@ public abstract class CollectionBinder {
}
+ private String extractHqlOrderBy(javax.persistence.OrderBy jpaOrderBy) {
+ if ( jpaOrderBy != null ) {
+ final String jpaOrderByFragment = jpaOrderBy.value();
+ return StringHelper.isNotEmpty( jpaOrderByFragment )
+ ? jpaOrderByFragment
+ : null;
+ }
+ return null;
+ }
+
private static void checkFilterConditions(Collection collValue) {
//for now it can't happen, but sometime soon...
if ( ( collValue.getFilters().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) &&
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java
index 4ee8d3d3a5..9ee882c558 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java
@@ -60,6 +60,7 @@ public class ListBinder extends CollectionBinder {
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, ListBinder.class.getName() );
public ListBinder() {
+ super( false );
}
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
index 4883499bf5..1e5e7d8150 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
@@ -77,10 +77,6 @@ public class MapBinder extends CollectionBinder {
super( sorted );
}
- public MapBinder() {
- super();
- }
-
public boolean isMap() {
return true;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SetBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SetBinder.java
index 4df97b1a01..4618f92671 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SetBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SetBinder.java
@@ -33,10 +33,6 @@ import org.hibernate.mapping.PersistentClass;
* @author Matthew Inger
*/
public class SetBinder extends CollectionBinder {
-
- public SetBinder() {
- }
-
public SetBinder(boolean sorted) {
super( sorted );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
index 7d5e6e5cf6..763e015c59 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
@@ -62,6 +62,7 @@ import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
@@ -167,6 +168,7 @@ class TypeSafeActivator {
}
applyRelationalConstraints( activationContext );
+//<<<<<<< HEAD
}
@SuppressWarnings( {"UnusedDeclaration"})
@@ -175,6 +177,22 @@ class TypeSafeActivator {
final Dialect dialect = activationContext.getServiceRegistry().getService( JdbcServices.class ).getDialect();
final ClassLoaderService classLoaderService = activationContext.getServiceRegistry().getService( ClassLoaderService.class );
ValidatorFactory factory = getValidatorFactory( properties );
+//=======
+// applyRelationalConstraints(
+// factory,
+// activationContext.getConfiguration().createMappings().getClasses().values(),
+// properties,
+// activationContext.getServiceRegistry().getService( JdbcServices.class ).getDialect()
+// );
+// }
+//
+// @SuppressWarnings( {"UnusedDeclaration"})
+// public static void applyRelationalConstraints(
+// ValidatorFactory factory,
+// Collection persistentClasses,
+// Properties properties,
+// Dialect dialect) {
+//>>>>>>> master
Class>[] groupsArray = new GroupsPerOperation( properties ).get( GroupsPerOperation.Operation.DDL );
Set> groups = new HashSet>( Arrays.asList( groupsArray ) );
@@ -482,14 +500,23 @@ class TypeSafeActivator {
private static boolean applyNotNull(Property property, ConstraintDescriptor> descriptor) {
boolean hasNotNull = false;
if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) {
+ // single table inheritance should not be forced to null due to shared state
if ( !( property.getPersistentClass() instanceof SingleTableSubclass ) ) {
- //single table should not be forced to null
- if ( !property.isComposite() ) { //composite should not add not-null on all columns
- @SuppressWarnings( "unchecked" )
- Iterator iter = property.getColumnIterator();
+ //composite should not add not-null on all columns
+ if ( !property.isComposite() ) {
+ final Iterator iter = property.getColumnIterator();
while ( iter.hasNext() ) {
- iter.next().setNullable( false );
- hasNotNull = true;
+ final Selectable selectable = iter.next();
+ if ( Column.class.isInstance( selectable ) ) {
+ Column.class.cast( selectable ).setNullable( false );
+ }
+ else {
+ LOG.debugf(
+ "@NotNull was applied to attribute [%s] which is defined (at least partially) " +
+ "by formula(s); formula portions will be skipped",
+ property.getName()
+ );
+ }
}
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java
index 47caa2e239..1981424553 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java
@@ -35,6 +35,7 @@ import org.hibernate.dialect.function.AvgWithArgumentCastFunction;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
@@ -314,6 +315,12 @@ public class H2Dialect extends Dialect {
exception = new PessimisticLockException(message, sqlException, sql);
}
+ if ( 90006 == errorCode ) {
+ // NULL not allowed for column [90006-145]
+ final String constraintName = getViolatedConstraintNameExtracter().extractConstraintName( sqlException );
+ exception = new ConstraintViolationException( message, sqlException, sql, constraintName );
+ }
+
return exception;
}
};
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
index 123e38e249..5a0d243feb 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
@@ -37,6 +37,7 @@ import org.hibernate.dialect.function.NvlFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.hibernate.exception.LockTimeoutException;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
@@ -462,6 +463,14 @@ public class Oracle8iDialect extends Dialect {
}
+ // data integrity violation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ if ( 1407 == errorCode ) {
+ // ORA-01407: cannot update column to NULL
+ final String constraintName = getViolatedConstraintNameExtracter().extractConstraintName( sqlException );
+ return new ConstraintViolationException( message, sqlException, sql, constraintName );
+ }
+
return null;
}
};
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE157Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE157Dialect.java
index 565b68377c..e3858c4cdb 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE157Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE157Dialect.java
@@ -29,6 +29,7 @@ import java.util.Map;
import org.hibernate.JDBCException;
import org.hibernate.LockOptions;
import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockTimeoutException;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.internal.util.JdbcExceptionHelper;
@@ -99,9 +100,15 @@ public class SybaseASE157Dialect extends SybaseASE15Dialect {
@Override
public JDBCException convert(SQLException sqlException, String message, String sql) {
final String sqlState = JdbcExceptionHelper.extractSqlState( sqlException );
+ final int errorCode = JdbcExceptionHelper.extractErrorCode( sqlException );
if("JZ0TO".equals( sqlState ) || "JZ006".equals( sqlState )){
throw new LockTimeoutException( message, sqlException, sql );
}
+ if ( 515 == errorCode && "ZZZZZ".equals( sqlState ) ) {
+ // Attempt to insert NULL value into column; column does not allow nulls.
+ final String constraintName = getViolatedConstraintNameExtracter().extractConstraintName( sqlException );
+ return new ConstraintViolationException( message, sqlException, sql, constraintName );
+ }
return null;
}
};
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/FetchStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/FetchStrategy.java
new file mode 100644
index 0000000000..8264eee79a
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/engine/FetchStrategy.java
@@ -0,0 +1,50 @@
+/*
+ * jDocBook, processing of DocBook sources
+ *
+ * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.engine;
+
+/**
+ * Describes the strategy for fetching an association
+ *
+ * todo not really a fan of the name. not sure of a better one though.
+ * I'd almost rather see this be called the style, but then what to call FetchStyle? HowToFetch?
+ *
+ * @author Steve Ebersole
+ */
+public class FetchStrategy {
+ private final FetchTiming timing;
+ private final FetchStyle style;
+
+ public FetchStrategy(FetchTiming timing, FetchStyle style) {
+ this.timing = timing;
+ this.style = style;
+ }
+
+ public FetchTiming getTiming() {
+ return timing;
+ }
+
+ public FetchStyle getStyle() {
+ return style;
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java
index 12400c4876..15f4eec794 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java
@@ -145,7 +145,8 @@ public final class Cascade {
throws HibernateException {
if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt
- if ( LOG.isTraceEnabled() ) {
+ final boolean traceEnabled = LOG.isTraceEnabled();
+ if ( traceEnabled ) {
LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() );
}
@@ -182,7 +183,7 @@ public final class Cascade {
}
}
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Done processing cascade {0} for: {1}", action, persister.getEntityName() );
}
}
@@ -248,7 +249,7 @@ public final class Cascade {
// orphaned value, something a delete with a subquery to
// match the owner.
// final EntityType entityType = (EntityType) type;
-// final String propertyPath = composePropertyPath( entityType.getPropertyName() );
+// final String getPropertyPath = composePropertyPath( entityType.getPropertyName() );
loadedValue = null;
}
if ( loadedValue != null ) {
@@ -406,7 +407,8 @@ public final class Cascade {
boolean reallyDoCascade = style.reallyDoCascade(action) && child!=CollectionType.UNFETCHED_COLLECTION;
if ( reallyDoCascade ) {
- if ( LOG.isTraceEnabled() ) {
+ final boolean traceEnabled = LOG.isTraceEnabled();
+ if ( traceEnabled ) {
LOG.tracev( "Cascade {0} for collection: {1}", action, collectionType.getRole() );
}
@@ -423,7 +425,7 @@ public final class Cascade {
);
}
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Done cascade {0} for collection: {1}", action, collectionType.getRole() );
}
}
@@ -434,7 +436,8 @@ public final class Cascade {
child instanceof PersistentCollection; //a newly instantiated collection can't have orphans
if ( deleteOrphans ) { // handle orphaned entities!!
- if ( LOG.isTraceEnabled() ) {
+ final boolean traceEnabled = LOG.isTraceEnabled();
+ if ( traceEnabled ) {
LOG.tracev( "Deleting orphans for collection: {0}", collectionType.getRole() );
}
// we can do the cast since orphan-delete does not apply to:
@@ -443,7 +446,7 @@ public final class Cascade {
final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() );
deleteOrphans( entityName, (PersistentCollection) child );
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Done deleting orphans for collection: {0}", collectionType.getRole() );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java
index 476e078953..8ea6a19bb9 100755
--- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java
@@ -73,7 +73,7 @@ public final class Collections {
CollectionEntry entry = persistenceContext.getCollectionEntry(coll);
final CollectionPersister loadedPersister = entry.getLoadedPersister();
- if ( LOG.isDebugEnabled() && loadedPersister != null ) {
+ if ( loadedPersister != null && LOG.isDebugEnabled() ) {
LOG.debugf(
"Collection dereferenced: %s",
MessageHelper.collectionInfoString( loadedPersister,
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/ParameterBinder.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/ParameterBinder.java
index e4cc3d5745..1926cf3d84 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/internal/ParameterBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/ParameterBinder.java
@@ -112,6 +112,7 @@ public class ParameterBinder {
final NamedParameterSource source,
final SessionImplementor session) throws SQLException, HibernateException {
if ( namedParams != null ) {
+ final boolean debugEnabled = LOG.isDebugEnabled();
// assumes that types are all of span 1
Iterator iter = namedParams.entrySet().iterator();
int result = 0;
@@ -121,7 +122,7 @@ public class ParameterBinder {
TypedValue typedval = (TypedValue) e.getValue();
int[] locations = source.getNamedParameterLocations( name );
for ( int i = 0; i < locations.length; i++ ) {
- if ( LOG.isDebugEnabled() ) {
+ if ( debugEnabled ) {
LOG.debugf("bindNamedParameters() %s -> %s [%s]", typedval.getValue(), name, locations[i] + start);
}
typedval.getType().nullSafeSet( ps, typedval.getValue(), locations[i] + start, session );
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java
index f3e890ff7b..3d6f83404d 100755
--- a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java
@@ -102,7 +102,7 @@ public final class TwoPhaseLoad {
lazyPropertiesAreUnfetched
);
- if ( LOG.isTraceEnabled() && version != null ) {
+ if ( version != null && LOG.isTraceEnabled() ) {
String versionStr = persister.isVersioned()
? persister.getVersionType().toLoggableString( version, session.getFactory() )
: "null";
@@ -154,7 +154,8 @@ public final class TwoPhaseLoad {
Serializable id = entityEntry.getId();
Object[] hydratedState = entityEntry.getLoadedState();
- if ( LOG.isDebugEnabled() ) {
+ final boolean debugEnabled = LOG.isDebugEnabled();
+ if ( debugEnabled ) {
LOG.debugf(
"Resolving associations for %s",
MessageHelper.infoString( persister, id, session.getFactory() )
@@ -188,7 +189,7 @@ public final class TwoPhaseLoad {
final SessionFactoryImplementor factory = session.getFactory();
if ( persister.hasCache() && session.getCacheMode().isPutEnabled() ) {
- if ( LOG.isDebugEnabled() ) {
+ if ( debugEnabled ) {
LOG.debugf(
"Adding entity to second-level cache: %s",
MessageHelper.infoString( persister, id, session.getFactory() )
@@ -273,7 +274,7 @@ public final class TwoPhaseLoad {
session
);
- if ( LOG.isDebugEnabled() ) {
+ if ( debugEnabled ) {
LOG.debugf(
"Done materializing entity %s",
MessageHelper.infoString( persister, id, session.getFactory() )
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java
index 0581f82b1d..f1d56fb263 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java
@@ -136,11 +136,14 @@ public class SqlExceptionHelper {
if (LOG.isEnabled(Level.ERROR)) {
if (LOG.isDebugEnabled()) {
message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG;
- LOG.debug( message, sqlException );
+ LOG.debug( message, sqlException );
}
+ final boolean warnEnabled = LOG.isEnabled( Level.WARN );
while (sqlException != null) {
- StringBuilder buf = new StringBuilder(30).append("SQL Error: ").append(sqlException.getErrorCode()).append(", SQLState: ").append(sqlException.getSQLState());
- LOG.warn(buf.toString());
+ if ( warnEnabled ) {
+ StringBuilder buf = new StringBuilder(30).append("SQL Error: ").append(sqlException.getErrorCode()).append(", SQLState: ").append(sqlException.getSQLState());
+ LOG.warn(buf.toString());
+ }
LOG.error(sqlException.getMessage());
sqlException = sqlException.getNextException();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java b/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java
index bbd337ca6d..a8cf961bbd 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java
@@ -221,20 +221,21 @@ public class CollectionLoadContext {
}
private void endLoadingCollections(CollectionPersister persister, List matchedCollectionEntries) {
+ final boolean debugEnabled = LOG.isDebugEnabled();
if ( matchedCollectionEntries == null ) {
- if ( LOG.isDebugEnabled()) LOG.debugf( "No collections were found in result set for role: %s", persister.getRole() );
+ if ( debugEnabled ) LOG.debugf( "No collections were found in result set for role: %s", persister.getRole() );
return;
}
final int count = matchedCollectionEntries.size();
- if ( LOG.isDebugEnabled()) LOG.debugf("%s collections were found in result set for role: %s", count, persister.getRole());
+ if ( debugEnabled ) LOG.debugf("%s collections were found in result set for role: %s", count, persister.getRole());
for ( int i = 0; i < count; i++ ) {
LoadingCollectionEntry lce = ( LoadingCollectionEntry ) matchedCollectionEntries.get( i );
endLoadingCollection( lce, persister );
}
- if ( LOG.isDebugEnabled() ) LOG.debugf( "%s collections initialized for role: %s", count, persister.getRole() );
+ if ( debugEnabled ) LOG.debugf( "%s collections initialized for role: %s", count, persister.getRole() );
}
private void endLoadingCollection(LoadingCollectionEntry lce, CollectionPersister persister) {
@@ -289,13 +290,16 @@ public class CollectionLoadContext {
final SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
final SessionFactoryImplementor factory = session.getFactory();
- if ( LOG.isDebugEnabled() ) {
+ final boolean debugEnabled = LOG.isDebugEnabled();
+ if ( debugEnabled ) {
LOG.debugf( "Caching collection: %s", MessageHelper.collectionInfoString( persister, lce.getCollection(), lce.getKey(), session ) );
}
if ( session.getLoadQueryInfluencers().hasEnabledFilters() && persister.isAffectedByEnabledFilters( session ) ) {
// some filters affecting the collection are enabled on the session, so do not do the put into the cache.
- LOG.debug( "Refusing to add to cache due to enabled filters" );
+ if ( debugEnabled ) {
+ LOG.debug( "Refusing to add to cache due to enabled filters" );
+ }
// todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered;
// but CacheKey is currently used for both collections and entities; would ideally need to define two seperate ones;
// currently this works in conjuction with the check on
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java
index f4c943c10c..a70c2bf3d5 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java
@@ -32,7 +32,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Queue;
import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedQueue;
import org.jboss.logging.Logger;
@@ -643,7 +645,9 @@ public class ActionQueue {
private static class BeforeTransactionCompletionProcessQueue {
private SessionImplementor session;
- private List processes = new ArrayList();
+ // Concurrency handling required when transaction completion process is dynamically registered
+ // inside event listener (HHH-7478).
+ private Queue processes = new ConcurrentLinkedQueue();
private BeforeTransactionCompletionProcessQueue(SessionImplementor session) {
this.session = session;
@@ -675,8 +679,9 @@ public class ActionQueue {
private static class AfterTransactionCompletionProcessQueue {
private SessionImplementor session;
private Set querySpacesToInvalidate = new HashSet();
- private List processes
- = new ArrayList( INIT_QUEUE_LIST_SIZE * 3 );
+ // Concurrency handling required when transaction completion process is dynamically registered
+ // inside event listener (HHH-7478).
+ private Queue processes = new ConcurrentLinkedQueue();
private AfterTransactionCompletionProcessQueue(SessionImplementor session) {
this.session = session;
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java
index 7c0e108160..4061393f7a 100644
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java
@@ -473,18 +473,19 @@ public abstract class AbstractSaveEventListener extends AbstractReassociateEvent
EntityEntry entry, //pass this as an argument only to avoid double looking
SessionImplementor source) {
+ final boolean traceEnabled = LOG.isTraceEnabled();
if ( entry != null ) { // the object is persistent
//the entity is associated with the session, so check its status
if ( entry.getStatus() != Status.DELETED ) {
// do nothing for persistent instances
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Persistent instance of: {0}", getLoggableName( entityName, entity ) );
}
return EntityState.PERSISTENT;
}
// ie. e.status==DELETED
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Deleted instance of: {0}", getLoggableName( entityName, entity ) );
}
return EntityState.DELETED;
@@ -495,12 +496,12 @@ public abstract class AbstractSaveEventListener extends AbstractReassociateEvent
// try interceptor and unsaved-value
if ( ForeignKeys.isTransient( entityName, entity, getAssumedUnsaved(), source )) {
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Transient instance of: {0}", getLoggableName( entityName, entity ) );
}
return EntityState.TRANSIENT;
}
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Detached instance of: {0}", getLoggableName( entityName, entity ) );
}
return EntityState.DETACHED;
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java
index c40942ea64..cf99ea572e 100755
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java
@@ -633,7 +633,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
}
private void logDirtyProperties(Serializable id, int[] dirtyProperties, EntityPersister persister) {
- if ( LOG.isTraceEnabled() && dirtyProperties != null && dirtyProperties.length > 0 ) {
+ if ( dirtyProperties != null && dirtyProperties.length > 0 && LOG.isTraceEnabled() ) {
final String[] allPropertyNames = persister.getPropertyNames();
final String[] dirtyPropertyNames = new String[ dirtyProperties.length ];
for ( int i = 0; i < dirtyProperties.length; i++ ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultInitializeCollectionEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultInitializeCollectionEventListener.java
index eca4b01581..e849d790de 100755
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultInitializeCollectionEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultInitializeCollectionEventListener.java
@@ -60,12 +60,13 @@ public class DefaultInitializeCollectionEventListener implements InitializeColle
CollectionEntry ce = source.getPersistenceContext().getCollectionEntry(collection);
if (ce==null) throw new HibernateException("collection was evicted");
if ( !collection.wasInitialized() ) {
- if ( LOG.isTraceEnabled() ) {
+ final boolean traceEnabled = LOG.isTraceEnabled();
+ if ( traceEnabled ) {
LOG.tracev( "Initializing collection {0}",
MessageHelper.collectionInfoString( ce.getLoadedPersister(), collection, ce.getLoadedKey(), source ) );
+ LOG.trace( "Checking second-level cache" );
}
- LOG.trace( "Checking second-level cache" );
final boolean foundInCache = initializeCollectionFromCache(
ce.getLoadedKey(),
ce.getLoadedPersister(),
@@ -73,13 +74,17 @@ public class DefaultInitializeCollectionEventListener implements InitializeColle
source
);
- if ( foundInCache ) {
+ if ( foundInCache && traceEnabled ) {
LOG.trace( "Collection initialized from cache" );
}
else {
- LOG.trace( "Collection not cached" );
+ if ( traceEnabled ) {
+ LOG.trace( "Collection not cached" );
+ }
ce.getLoadedPersister().initialize( ce.getLoadedKey(), source );
- LOG.trace( "Collection initialized" );
+ if ( traceEnabled ) {
+ LOG.trace( "Collection initialized" );
+ }
if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
source.getFactory().getStatisticsImplementor().fetchCollection(
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java
index 652df90bfb..2a46265d37 100755
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java
@@ -73,7 +73,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
* @throws HibernateException
*/
public void onMerge(MergeEvent event) throws HibernateException {
- EventCache copyCache = new EventCache();
+ EventCache copyCache = new EventCache( event.getSession() );
onMerge( event, copyCache );
copyCache.clear();
copyCache = null;
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java
index 7885ea6c4c..910faabf3c 100644
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java
@@ -101,8 +101,9 @@ public class DefaultReplicateEventListener extends AbstractSaveEventListener imp
oldVersion = persister.getCurrentVersion( id, source );
}
+ final boolean traceEnabled = LOG.isTraceEnabled();
if ( oldVersion != null ) {
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Found existing row for {0}", MessageHelper.infoString( persister, id, source.getFactory() ) );
}
@@ -120,14 +121,14 @@ public class DefaultReplicateEventListener extends AbstractSaveEventListener imp
// else do nothing (don't even reassociate object!)
if ( canReplicate )
performReplication( entity, id, realOldVersion, persister, replicationMode, source );
- else
+ else if ( traceEnabled )
LOG.trace( "No need to replicate" );
//TODO: would it be better to do a refresh from db?
}
else {
// no existing row - do an insert
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "No existing row, replicating new instance {0}",
MessageHelper.infoString( persister, id, source.getFactory() ) );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultSaveOrUpdateEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultSaveOrUpdateEventListener.java
index 8fe131bc3d..7948e31c4a 100755
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultSaveOrUpdateEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultSaveOrUpdateEventListener.java
@@ -117,8 +117,10 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
}
protected Serializable entityIsPersistent(SaveOrUpdateEvent event) throws HibernateException {
- LOG.trace( "Ignoring persistent instance" );
-
+ final boolean traceEnabled = LOG.isTraceEnabled();
+ if ( traceEnabled ) {
+ LOG.trace( "Ignoring persistent instance" );
+ }
EntityEntry entityEntry = event.getEntry();
if ( entityEntry == null ) {
throw new AssertionFailure( "entity was transient or detached" );
@@ -153,7 +155,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
}
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Object already associated with session: {0}", MessageHelper.infoString( entityEntry.getPersister(), savedId, factory ) );
}
@@ -279,11 +281,12 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
Object entity,
EntityPersister persister) throws HibernateException {
- if ( !persister.isMutable() ) {
+ final boolean traceEnabled = LOG.isTraceEnabled();
+ if ( traceEnabled && !persister.isMutable() ) {
LOG.trace( "Immutable instance passed to performUpdate()" );
}
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Updating {0}",
MessageHelper.infoString( persister, event.getRequestedId(), event.getSession().getFactory() ) );
}
@@ -329,7 +332,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
persister.afterReassociate(entity, source);
- if ( LOG.isTraceEnabled() ) {
+ if ( traceEnabled ) {
LOG.tracev( "Updating {0}", MessageHelper.infoString( persister, event.getRequestedId(), source.getFactory() ) );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/EventCache.java b/hibernate-core/src/main/java/org/hibernate/event/internal/EventCache.java
index 9bdf9f47f5..7c4bc9a26a 100644
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/EventCache.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/EventCache.java
@@ -30,6 +30,8 @@ import java.util.Map;
import java.util.Set;
import org.hibernate.AssertionFailure;
+import org.hibernate.event.spi.EventSource;
+import org.hibernate.pretty.MessageHelper;
/**
* EventCache is a Map implementation that can be used by an event
@@ -59,6 +61,8 @@ import org.hibernate.AssertionFailure;
* @author Gail Badner
*/
class EventCache implements Map {
+ private final EventSource session;
+
private Map