Final sync with upstream master

This commit is contained in:
JPAV 2011-03-08 16:19:57 -06:00
commit 346418c4ef
643 changed files with 13834 additions and 10212 deletions

View File

@ -69,9 +69,10 @@ libraries = [
jcl: 'commons-logging:commons-logging:99.0-does-not-exist', jcl: 'commons-logging:commons-logging:99.0-does-not-exist',
// testing // testing
atomikos: 'com.atomikos:transactions-jdbc:3.7.0',
junit: 'junit:junit:3.8.2', junit: 'junit:junit:3.8.2',
testng: 'org.testng:testng:5.8:jdk15', testng: 'org.testng:testng:5.8:jdk15',
jpa_modelgen: 'org.hibernate:hibernate-jpamodelgen:1.1.0.Final', jpa_modelgen: 'org.hibernate:hibernate-jpamodelgen:1.1.1.Final',
shrinkwrap_api: 'org.jboss.shrinkwrap:shrinkwrap-api:1.0.0-alpha-6', shrinkwrap_api: 'org.jboss.shrinkwrap:shrinkwrap-api:1.0.0-alpha-6',
shrinkwrap: 'org.jboss.shrinkwrap:shrinkwrap-impl-base:1.0.0-alpha-6' shrinkwrap: 'org.jboss.shrinkwrap:shrinkwrap-impl-base:1.0.0-alpha-6'
] ]
@ -110,6 +111,7 @@ subprojects { subProject ->
compile( libraries.logging_tools ) compile( libraries.logging_tools )
compile( libraries.slf4j_api ) compile( libraries.slf4j_api )
testCompile( libraries.junit ) testCompile( libraries.junit )
testCompile( libraries.atomikos )
testRuntime( libraries.slf4j_simple ) testRuntime( libraries.slf4j_simple )
testRuntime( libraries.jcl_slf4j ) testRuntime( libraries.jcl_slf4j )
testRuntime( libraries.jcl_api ) testRuntime( libraries.jcl_api )
@ -183,12 +185,8 @@ subprojects { subProject ->
sourceCompatibility = "1.6" sourceCompatibility = "1.6"
ideaModule { ideaModule {
// treat our "provided" configuration dependencies as "Compile" scope dependencies in IntelliJ // treat our "provided" configuration dependencies as "compile" scope dependencies in IntelliJ
scopes.COMPILE.plus.add( configurations.provided ) scopes.COMPILE.plus.add( configurations.provided )
// Use explicitly separate compilation output directories for Gradle and IntelliJ
File baseDirectory = new File( subProject.buildDir, "idea/classes" )
outputDir = new File( baseDirectory, "main" )
testOutputDir = new File( baseDirectory, "test" )
whenConfigured { module -> whenConfigured { module ->
module.dependencies*.exported = true module.dependencies*.exported = true
} }

View File

@ -53,7 +53,7 @@ public class AuthenticationHandler extends DefaultTask {
@TaskAction @TaskAction
public void configureUploadAuthentication() { public void configureUploadAuthentication() {
// todo : unfortunately I have no idea how to apply this to non MavenDeployer-type repos... // todo : unfortunately I have no idea how to apply this to non MavenDeployer-type repos...
uploadTask.getRepositories().withType( MavenDeployer.class ).allObjects( uploadTask.getRepositories().withType( MavenDeployer.class ).all(
new Action<MavenDeployer>() { new Action<MavenDeployer>() {
public void execute(MavenDeployer deployer) { public void execute(MavenDeployer deployer) {
final RemoteRepository repository = deployer.getRepository(); final RemoteRepository repository = deployer.getRepository();

View File

@ -43,7 +43,7 @@ public class UploadAuthenticationManager implements Plugin<Project> {
// code for just that. // code for just that.
final AuthenticationProviderRegistry registry = new AuthenticationProviderRegistry(); final AuthenticationProviderRegistry registry = new AuthenticationProviderRegistry();
project.getTasks().withType( Upload.class ).allTasks( project.getTasks().withType( Upload.class ).all(
new Action<Upload>() { new Action<Upload>() {
@Override @Override
public void execute(final Upload uploadTask) { public void execute(final Upload uploadTask) {

View File

@ -30,10 +30,10 @@ import java.util.Properties;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.UnknownUnwrapTypeException; import org.hibernate.service.spi.UnknownUnwrapTypeException;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import com.mchange.v2.c3p0.DataSources; import com.mchange.v2.c3p0.DataSources;

View File

@ -96,4 +96,9 @@ task installTesting(type:Upload, dependsOn: [testingJar,testingSourcesJar]) {
} }
install.dependsOn installTesting install.dependsOn installTesting
uploadTesting.dependsOn installTesting uploadTesting.dependsOn installTesting
// temporary
test {
ignoreFailures = true
}

View File

@ -1,10 +1,10 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as * Copyright (c) 2007-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution * indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are * 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, * 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 * copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,7 +20,6 @@
* Free Software Foundation, Inc. * Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*
*/ */
package org.hibernate; package org.hibernate;
@ -36,6 +35,9 @@ package org.hibernate;
* @author Gavin King * @author Gavin King
*/ */
public class HibernateException extends RuntimeException { public class HibernateException extends RuntimeException {
public HibernateException(String s) {
super(s);
}
public HibernateException(Throwable root) { public HibernateException(Throwable root) {
super(root); super(root);
@ -44,10 +46,6 @@ public class HibernateException extends RuntimeException {
public HibernateException(String string, Throwable root) { public HibernateException(String string, Throwable root) {
super(string, root); super(string, root);
} }
public HibernateException(String s) {
super(s);
}
} }

View File

@ -1802,4 +1802,16 @@ public interface HibernateLogger extends BasicLogger {
@LogMessage( level = INFO ) @LogMessage( level = INFO )
@Message( value = "Writing generated schema to file: %s", id = 417 ) @Message( value = "Writing generated schema to file: %s", id = 417 )
void writingGeneratedSchemaToFile( String outputFile ); void writingGeneratedSchemaToFile( String outputFile );
@LogMessage( level = INFO )
@Message( value = "Adding override for %s: %s", id = 418 )
void addingOverrideFor( String name,
String name2 );
@LogMessage( level = WARN )
@Message( value = "Resolved SqlTypeDescriptor is for a different SQL code. %s has sqlCode=%s; type override %s has sqlCode=%s", id = 419 )
void resolvedSqlTypeDescriptorForDifferentSqlCode( String name,
String valueOf,
String name2,
String valueOf2 );
} }

View File

@ -23,7 +23,8 @@
* *
*/ */
package org.hibernate; package org.hibernate;
import org.hibernate.util.StringHelper;
import org.hibernate.internal.util.StringHelper;
/** /**
* A problem occurred accessing a property of an instance of a * A problem occurred accessing a property of an instance of a
@ -58,7 +59,8 @@ public class PropertyAccessException extends HibernateException {
return propertyName; return propertyName;
} }
public String getMessage() { @Override
public String getMessage() {
return super.getMessage() + return super.getMessage() +
( wasSetter ? " setter of " : " getter of ") + ( wasSetter ? " setter of " : " getter of ") +
StringHelper.qualify( persistentClass.getName(), propertyName ); StringHelper.qualify( persistentClass.getName(), propertyName );

View File

@ -23,7 +23,8 @@
* *
*/ */
package org.hibernate; package org.hibernate;
import org.hibernate.util.StringHelper;
import org.hibernate.internal.util.StringHelper;
/** /**
* Thrown when the (illegal) value of a property can not be persisted. * Thrown when the (illegal) value of a property can not be persisted.
@ -53,7 +54,8 @@ public class PropertyValueException extends HibernateException {
return propertyName; return propertyName;
} }
public String getMessage() { @Override
public String getMessage() {
return super.getMessage() + ": " + return super.getMessage() + ": " +
StringHelper.qualify(entityName, propertyName); StringHelper.qualify(entityName, propertyName);
} }

View File

@ -1,10 +1,10 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution * indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are * 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, * 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 * copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,23 +20,20 @@
* Free Software Foundation, Inc. * Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*
*/ */
package org.hibernate.transaction; package org.hibernate;
/** /**
* {@link TransactionManagerLookup} strategy for JRun4 AS * Indicates an attempt was made to use a closed resource (Session, SessionFactory, etc).
* *
* @author Joseph Bissen * @author Steve Ebersole
*/ */
public class JRun4TransactionManagerLookup extends JNDITransactionManagerLookup { public class ResourceClosedException extends HibernateException {
public ResourceClosedException(String s) {
protected String getName() { super( s );
return "java:/TransactionManager";
} }
public String getUserTransactionName() { public ResourceClosedException(String string, Throwable root) {
return "java:comp/UserTransaction"; super( string, root );
} }
} }

View File

@ -918,39 +918,25 @@ public interface Session extends Serializable {
public void doWork(Work work) throws HibernateException; public void doWork(Work work) throws HibernateException;
/** /**
* Disconnect the <tt>Session</tt> from the current JDBC connection. If * Disconnect the session from its underlying JDBC connection. This is intended for use in cases where the
* the connection was obtained by Hibernate close it and return it to * application has supplied the JDBC connection to the session and which require long-sessions (aka, conversations).
* the connection pool; otherwise, return it to the application.
* <p/> * <p/>
* This is used by applications which supply JDBC connections to Hibernate * It is considered an error to call this method on a session which was not opened by supplying the JDBC connection
* and which require long-sessions (or long-conversations) * and an exception will be thrown.
* <p/> * <p/>
* Note that disconnect() called on a session where the connection was * For non-user-supplied scenarios, normal transaction management already handles disconnection and reconnection
* retrieved by Hibernate through its configured * automatically.
* {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} has no effect,
* provided {@link ConnectionReleaseMode#ON_CLOSE} is not in effect.
* *
* @return the application-supplied connection or <tt>null</tt> * @return the application-supplied connection or {@literal null}
*
* @see SessionFactory#openSession(java.sql.Connection)
* @see SessionFactory#openSession(java.sql.Connection, Interceptor)
* @see #reconnect(Connection) * @see #reconnect(Connection)
* @see #reconnect()
*/ */
Connection disconnect() throws HibernateException; Connection disconnect() throws HibernateException;
/** /**
* Obtain a new JDBC connection. This is used by applications which * Reconnect to the given JDBC connection.
* require long transactions and do not supply connections to the
* session.
*
* @see #disconnect()
* @deprecated Manual reconnection is only needed in the case of
* application-supplied connections, in which case the
* {@link #reconnect(java.sql.Connection)} for should be used.
*/
void reconnect() throws HibernateException;
/**
* Reconnect to the given JDBC connection. This is used by applications
* which require long transactions and use application-supplied connections.
* *
* @param connection a JDBC connection * @param connection a JDBC connection
* @see #disconnect() * @see #disconnect()

View File

@ -116,8 +116,7 @@ public interface SessionFactory extends Referenceable, Serializable {
* for use. * for use.
* <p/> * <p/>
* Note that for backwards compatibility, if a {@link org.hibernate.context.CurrentSessionContext} * Note that for backwards compatibility, if a {@link org.hibernate.context.CurrentSessionContext}
* is not configured but a JTA {@link org.hibernate.transaction.TransactionManagerLookup} * is not configured but JTA is configured this will default to the {@link org.hibernate.context.JTASessionContext}
* is configured this will default to the {@link org.hibernate.context.JTASessionContext}
* impl. * impl.
* *
* @return The current session. * @return The current session.

View File

@ -1,10 +1,10 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as * Copyright (c) 2007-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution * indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are * 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, * 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 * copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,108 +20,139 @@
* Free Software Foundation, Inc. * Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*
*/ */
package org.hibernate; package org.hibernate;
import javax.transaction.Synchronization; import javax.transaction.Synchronization;
import org.hibernate.engine.transaction.spi.LocalStatus;
/** /**
* Allows the application to define units of work, while * Defines the contract for abstracting applications from the configured underlying means of transaction management.
* maintaining abstraction from the underlying transaction * Allows the application to define units of work, while maintaining abstraction from the underlying transaction
* implementation (eg. JTA, JDBC).<br> * implementation (eg. JTA, JDBC).
* <br> * <p/>
* A transaction is associated with a <tt>Session</tt> and is * A transaction is associated with a {@link Session} and is usually initiated by a call to
* usually instantiated by a call to <tt>Session.beginTransaction()</tt>. * {@link org.hibernate.Session#beginTransaction()}. A single session might span multiple transactions since
* A single session might span multiple transactions since * the notion of a session (a conversation between the application and the datastore) is of coarser granularity than
* the notion of a session (a conversation between the application * the notion of a transaction. However, it is intended that there be at most one uncommitted transaction associated
* and the datastore) is of coarser granularity than the notion of * with a particular {@link Session} at any time.
* a transaction. However, it is intended that there be at most one * <p/>
* uncommitted <tt>Transaction</tt> associated with a particular * Implementers are not intended to be thread-safe.
* <tt>Session</tt> at any time.<br>
* <br>
* Implementors are not intended to be threadsafe.
* *
* @see Session#beginTransaction()
* @see org.hibernate.transaction.TransactionFactory
* @author Anton van Straaten * @author Anton van Straaten
* @author Steve Ebersole
*/ */
public interface Transaction { public interface Transaction {
/** /**
* Begin a new transaction. * Is this transaction the initiator of any underlying transaction?
*
* @return {@literal true} if this transaction initiated the underlying transaction; {@literal false} otherwise.
*/ */
public void begin() throws HibernateException; public boolean isInitiator();
/** /**
* Flush the associated <tt>Session</tt> and end the unit of work (unless * Begin this transaction. No-op if the transaction has already been begun. Note that this is not necessarily
* we are in {@link FlushMode#MANUAL}. * symmetrical since usually multiple calls to {@link #commit} or {@link #rollback} will error.
* </p>
* This method will commit the underlying transaction if and only
* if the underlying transaction was initiated by this object.
* *
* @throws HibernateException * @throws HibernateException Indicates a problem beginning the transaction.
*/ */
public void commit() throws HibernateException; public void begin();
/** /**
* Force the underlying transaction to roll back. * Commit this transaction. This might entail a number of things depending on the context:<ul>
* <li>
* If this transaction is the {@link #isInitiator initiator}, {@link Session#flush} the {@link Session}
* with which it is associated (unless {@link Session} is in {@link FlushMode#MANUAL}).
* </li>
* <li>
* If this transaction is the {@link #isInitiator initiator}, commit the underlying transaction.
* </li>
* <li>
* Coordinate various callbacks
* </li>
* </ul>
* *
* @throws HibernateException * @throws HibernateException Indicates a problem committing the transaction.
*/ */
public void rollback() throws HibernateException; public void commit();
/**
* Rollback this transaction. Either rolls back the underlying transaction or ensures it cannot later commit
* (depending on the actual underlying strategy).
*
* @throws HibernateException Indicates a problem rolling back the transaction.
*/
public void rollback();
/**
* Get the current local status of this transaction.
* <p/>
* This only accounts for the local view of the transaction status. In other words it does not check the status
* of the actual underlying transaction.
*
* @return The current local status.
*/
public LocalStatus getLocalStatus();
/**
* Is this transaction still active?
* <p/>
* Answers on a best effort basis. For example, in the case of JDBC based transactions we cannot know that a
* transaction is active when it is initiated directly through the JDBC {@link java.sql.Connection}, only when
* it is initiated from here.
*
* @return {@literal true} if the transaction is still active; {@literal false} otherwise.
*
* @throws HibernateException Indicates a problem checking the transaction status.
*/
public boolean isActive();
/**
* Was this transaction committed?
* <p/>
* Answers on a best effort basis. For example, in the case of JDBC based transactions we cannot know that a
* transaction was committed when the commit was performed directly through the JDBC {@link java.sql.Connection},
* only when the commit was done from this.
*
* @return {@literal true} if the transaction is rolled back; {@literal false} otherwise.
*
* @throws HibernateException Indicates a problem checking the transaction status.
*/
public boolean wasCommitted();
/** /**
* Was this transaction rolled back or set to rollback only? * Was this transaction rolled back or set to rollback only?
* <p/> * <p/>
* This only accounts for actions initiated from this local transaction. * Answers on a best effort basis. For example, in the case of JDBC based transactions we cannot know that a
* If, for example, the underlying transaction is forced to rollback via * transaction was rolled back when rollback was performed directly through the JDBC {@link java.sql.Connection},
* some other means, this method still reports false because the rollback * only when it was rolled back from here.
* was not initiated from here.
* *
* @return boolean True if the transaction was rolled back via this * @return {@literal true} if the transaction is rolled back; {@literal false} otherwise.
* local transaction; false otherwise.
* @throws HibernateException
*/
public boolean wasRolledBack() throws HibernateException;
/**
* Check if this transaction was successfully committed.
* <p/>
* This method could return <tt>false</tt> even after successful invocation
* of {@link #commit}. As an example, JTA based strategies no-op on
* {@link #commit} calls if they did not start the transaction; in that case,
* they also report {@link #wasCommitted} as false.
* *
* @return boolean True if the transaction was (unequivocally) committed * @throws HibernateException Indicates a problem checking the transaction status.
* via this local transaction; false otherwise.
* @throws HibernateException
*/ */
public boolean wasCommitted() throws HibernateException; public boolean wasRolledBack();
/**
* Is this transaction still active?
* <p/>
* Again, this only returns information in relation to the
* local transaction, not the actual underlying transaction.
*
* @return boolean Treu if this local transaction is still active.
*/
public boolean isActive() throws HibernateException;
/** /**
* Register a user synchronization callback for this transaction. * Register a user synchronization callback for this transaction.
* *
* @param synchronization The Synchronization callback to register. * @param synchronization The Synchronization callback to register.
* @throws HibernateException *
* @throws HibernateException Indicates a problem registering the synchronization.
*/ */
public void registerSynchronization(Synchronization synchronization) public void registerSynchronization(Synchronization synchronization) throws HibernateException;
throws HibernateException;
/** /**
* Set the transaction timeout for any transaction started by * Set the transaction timeout for any transaction started by a subsequent call to {@link #begin} on this instance.
* a subsequent call to <tt>begin()</tt> on this instance.
* *
* @param seconds The number of seconds before a timeout. * @param seconds The number of seconds before a timeout.
*/ */
public void setTimeout(int seconds); public void setTimeout(int seconds);
/**
* Retrieve the transaction timeout set for this transaction. A negative indicates no timeout has been set.
*
* @return The timeout, in seconds.
*/
public int getTimeout();
} }

View File

@ -33,7 +33,7 @@ import org.hibernate.collection.PersistentCollection;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* Any action relating to insert/update/delete of a collection * Any action relating to insert/update/delete of a collection
@ -42,11 +42,12 @@ import org.hibernate.util.StringHelper;
*/ */
public abstract class CollectionAction implements Executable, Serializable, Comparable { public abstract class CollectionAction implements Executable, Serializable, Comparable {
private transient CollectionPersister persister; private transient CollectionPersister persister;
private final Serializable key; private transient SessionImplementor session;
private final SessionImplementor session;
private final String collectionRole;
private final PersistentCollection collection; private final PersistentCollection collection;
private final Serializable key;
private final String collectionRole;
public CollectionAction( public CollectionAction(
final CollectionPersister persister, final CollectionPersister persister,
final PersistentCollection collection, final PersistentCollection collection,
@ -63,9 +64,19 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
return collection; return collection;
} }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { /**
ois.defaultReadObject(); * Reconnect to session after deserialization...
persister = session.getFactory().getCollectionPersister( collectionRole ); */
public void afterDeserialize(SessionImplementor session) {
if ( this.session != null || this.persister != null ) {
throw new IllegalStateException( "already attached to a session." );
}
// IMPL NOTE: non-flushed changes code calls this method with session == null...
// guard against NullPointerException
if ( session != null ) {
this.session = session;
this.persister = session.getFactory().getCollectionPersister( collectionRole );
}
} }
public final void beforeExecutions() throws CacheException { public final void beforeExecutions() throws CacheException {
@ -130,8 +141,8 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
key, key,
persister.getKeyType(), persister.getKeyType(),
persister.getRole(), persister.getRole(),
session.getEntityMode(), session.getEntityMode(),
session.getFactory() session.getFactory()
); );
persister.getCacheAccessStrategy().remove( ck ); persister.getCacheAccessStrategy().remove( ck );
} }

View File

@ -27,10 +27,12 @@ import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.engine.EntityEntry;
import org.hibernate.engine.EntityKey;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.util.StringHelper;
/** /**
* Base class for actions relating to insert/update/delete of an entity * Base class for actions relating to insert/update/delete of an entity
@ -43,9 +45,9 @@ public abstract class EntityAction
private final String entityName; private final String entityName;
private final Serializable id; private final Serializable id;
private final Object instance;
private final SessionImplementor session;
private transient Object instance;
private transient SessionImplementor session;
private transient EntityPersister persister; private transient EntityPersister persister;
/** /**
@ -96,11 +98,18 @@ public abstract class EntityAction
*/ */
public final Serializable getId() { public final Serializable getId() {
if ( id instanceof DelayedPostInsertIdentifier ) { if ( id instanceof DelayedPostInsertIdentifier ) {
return session.getPersistenceContext().getEntry( instance ).getId(); Serializable eeId = session.getPersistenceContext().getEntry( instance ).getId();
return eeId instanceof DelayedPostInsertIdentifier ? null : eeId;
} }
return id; return id;
} }
public final DelayedPostInsertIdentifier getDelayedId() {
return DelayedPostInsertIdentifier.class.isInstance( id ) ?
DelayedPostInsertIdentifier.class.cast( id ) :
null;
}
/** /**
* entity instance accessor * entity instance accessor
* *
@ -154,15 +163,19 @@ public abstract class EntityAction
} }
/** /**
* Serialization... * Reconnect to session after deserialization...
*
* @param ois Thed object stream
* @throws IOException Problem performing the default stream reading
* @throws ClassNotFoundException Problem performing the default stream reading
*/ */
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { public void afterDeserialize(SessionImplementor session) {
ois.defaultReadObject(); if ( this.session != null || this.persister != null ) {
persister = session.getFactory().getEntityPersister( entityName ); throw new IllegalStateException( "already attached to a session." );
}
// IMPL NOTE: non-flushed changes code calls this method with session == null...
// guard against NullPointerException
if ( session != null ) {
this.session = session;
this.persister = session.getFactory().getEntityPersister( entityName );
this.instance = session.getPersistenceContext().getEntity( new EntityKey( id, persister, session.getEntityMode() ) );
}
} }
} }

View File

@ -23,9 +23,11 @@
* *
*/ */
package org.hibernate.action; package org.hibernate.action;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.EntityEntry;
import org.hibernate.engine.EntityKey; import org.hibernate.engine.EntityKey;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventSource; import org.hibernate.event.EventSource;
@ -37,7 +39,7 @@ import org.hibernate.persister.entity.EntityPersister;
public final class EntityIdentityInsertAction extends EntityAction { public final class EntityIdentityInsertAction extends EntityAction {
private final Object[] state; private transient Object[] state;
private final boolean isDelayed; private final boolean isDelayed;
private final EntityKey delayedEntityKey; private final EntityKey delayedEntityKey;
//private CacheEntry cacheEntry; //private CacheEntry cacheEntry;
@ -49,7 +51,12 @@ public final class EntityIdentityInsertAction extends EntityAction {
EntityPersister persister, EntityPersister persister,
SessionImplementor session, SessionImplementor session,
boolean isDelayed) throws HibernateException { boolean isDelayed) throws HibernateException {
super( session, null, instance, persister ); super(
session,
( isDelayed ? generateDelayedPostInsertIdentifier() : null ),
instance,
persister
);
this.state = state; this.state = state;
this.isDelayed = isDelayed; this.isDelayed = isDelayed;
this.delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null; this.delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
@ -59,7 +66,7 @@ public final class EntityIdentityInsertAction extends EntityAction {
final EntityPersister persister = getPersister(); final EntityPersister persister = getPersister();
final SessionImplementor session = getSession(); final SessionImplementor session = getSession();
final Object instance = getInstance(); final Object instance = getInstance();
boolean veto = preInsert(); boolean veto = preInsert();
// Don't need to lock the cache here, since if someone // Don't need to lock the cache here, since if someone
@ -84,7 +91,7 @@ public final class EntityIdentityInsertAction extends EntityAction {
cacheEntry = new CacheEntry(object, persister, session); cacheEntry = new CacheEntry(object, persister, session);
persister.getCache().insert(generatedId, cacheEntry); persister.getCache().insert(generatedId, cacheEntry);
}*/ }*/
postInsert(); postInsert();
if ( session.getFactory().getStatistics().isStatisticsEnabled() && !veto ) { if ( session.getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
@ -93,12 +100,14 @@ public final class EntityIdentityInsertAction extends EntityAction {
} }
public boolean needsAfterTransactionCompletion() { @Override
public boolean needsAfterTransactionCompletion() {
//TODO: simply remove this override if we fix the above todos //TODO: simply remove this override if we fix the above todos
return hasPostCommitEventListeners(); return hasPostCommitEventListeners();
} }
protected boolean hasPostCommitEventListeners() { @Override
protected boolean hasPostCommitEventListeners() {
return getSession().getListeners().getPostCommitInsertEventListeners().length>0; return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
} }
@ -140,7 +149,7 @@ public final class EntityIdentityInsertAction extends EntityAction {
generatedId, generatedId,
state, state,
getPersister(), getPersister(),
(EventSource) getSession() (EventSource) getSession()
); );
for ( int i = 0; i < postListeners.length; i++ ) { for ( int i = 0; i < postListeners.length; i++ ) {
postListeners[i].onPostInsert(postEvent); postListeners[i].onPostInsert(postEvent);
@ -169,10 +178,25 @@ public final class EntityIdentityInsertAction extends EntityAction {
return delayedEntityKey; return delayedEntityKey;
} }
private synchronized EntityKey generateDelayedEntityKey() { private synchronized static DelayedPostInsertIdentifier generateDelayedPostInsertIdentifier() {
return new DelayedPostInsertIdentifier();
}
private EntityKey generateDelayedEntityKey() {
if ( !isDelayed ) { if ( !isDelayed ) {
throw new AssertionFailure( "cannot request delayed entity-key for non-delayed post-insert-id generation" ); throw new AssertionFailure( "cannot request delayed entity-key for non-delayed post-insert-id generation" );
} }
return new EntityKey( new DelayedPostInsertIdentifier(), getPersister(), getSession().getEntityMode() ); return new EntityKey( getDelayedId(), getPersister(), getSession().getEntityMode() );
}
@Override
public void afterDeserialize(SessionImplementor session) {
super.afterDeserialize( session );
// IMPL NOTE: non-flushed changes code calls this method with session == null...
// guard against NullPointerException
if ( session != null ) {
EntityEntry entityEntry = session.getPersistenceContext().getEntry( getInstance() );
this.state = entityEntry.getLoadedState();
}
} }
} }

View File

@ -23,6 +23,7 @@
* *
*/ */
package org.hibernate.bytecode.cglib; package org.hibernate.bytecode.cglib;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import net.sf.cglib.beans.BulkBean; import net.sf.cglib.beans.BulkBean;
import net.sf.cglib.beans.BulkBeanException; import net.sf.cglib.beans.BulkBeanException;
@ -32,7 +33,7 @@ import org.hibernate.bytecode.BytecodeProvider;
import org.hibernate.bytecode.ProxyFactoryFactory; import org.hibernate.bytecode.ProxyFactoryFactory;
import org.hibernate.bytecode.ReflectionOptimizer; import org.hibernate.bytecode.ReflectionOptimizer;
import org.hibernate.bytecode.util.FieldFilter; import org.hibernate.bytecode.util.FieldFilter;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -23,6 +23,7 @@
* *
*/ */
package org.hibernate.bytecode.javassist; package org.hibernate.bytecode.javassist;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.bytecode.BytecodeProvider; import org.hibernate.bytecode.BytecodeProvider;
@ -31,7 +32,7 @@ import org.hibernate.bytecode.ProxyFactoryFactory;
import org.hibernate.bytecode.ReflectionOptimizer; import org.hibernate.bytecode.ReflectionOptimizer;
import org.hibernate.bytecode.util.ClassFilter; import org.hibernate.bytecode.util.ClassFilter;
import org.hibernate.bytecode.util.FieldFilter; import org.hibernate.bytecode.util.FieldFilter;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -23,14 +23,15 @@
* *
*/ */
package org.hibernate.cache; package org.hibernate.cache;
import java.util.Properties; import java.util.Properties;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.naming.NamingException; import javax.naming.NamingException;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.jndi.JndiHelper; import org.hibernate.internal.util.jndi.JndiHelper;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cache; package org.hibernate.cache;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.Iterator; import java.util.Iterator;
@ -32,10 +33,10 @@ import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.RowSelection; import org.hibernate.engine.RowSelection;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.transform.CacheableResultTransformer; import org.hibernate.transform.CacheableResultTransformer;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.EqualsHelper;
/** /**
* A key that identifies a particular query with bound parameter values. This is the object Hibernate uses * A key that identifies a particular query with bound parameter values. This is the object Hibernate uses
@ -53,7 +54,7 @@ public class QueryKey implements Serializable {
private final Integer maxRows; private final Integer maxRows;
private final EntityMode entityMode; private final EntityMode entityMode;
private final Set filterKeys; private final Set filterKeys;
// the user provided resulttransformer, not the one used with "select new". Here to avoid mangling // the user provided resulttransformer, not the one used with "select new". Here to avoid mangling
// transformed/non-transformed results. // transformed/non-transformed results.
private final CacheableResultTransformer customTransformer; private final CacheableResultTransformer customTransformer;
@ -158,7 +159,7 @@ public class QueryKey implements Serializable {
Object[] positionalParameterValues, Object[] positionalParameterValues,
Map namedParameters, Map namedParameters,
Integer firstRow, Integer firstRow,
Integer maxRows, Integer maxRows,
Set filterKeys, Set filterKeys,
EntityMode entityMode, EntityMode entityMode,
CacheableResultTransformer customTransformer) { CacheableResultTransformer customTransformer) {
@ -208,7 +209,8 @@ public class QueryKey implements Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public boolean equals(Object other) { @Override
public boolean equals(Object other) {
if ( !( other instanceof QueryKey ) ) { if ( !( other instanceof QueryKey ) ) {
return false; return false;
} }
@ -251,14 +253,16 @@ public class QueryKey implements Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public int hashCode() { @Override
public int hashCode() {
return hashCode; return hashCode;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public String toString() { @Override
public String toString() {
StringBuffer buf = new StringBuffer() StringBuffer buf = new StringBuffer()
.append( "sql: " ) .append( "sql: " )
.append( sqlQueryString ); .append( sqlQueryString );
@ -285,5 +289,5 @@ public class QueryKey implements Serializable {
} }
return buf.toString(); return buf.toString();
} }
} }

View File

@ -32,7 +32,7 @@ import org.hibernate.event.PreLoadEvent;
import org.hibernate.event.PreLoadEventListener; import org.hibernate.event.PreLoadEventListener;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.TypeHelper; import org.hibernate.type.TypeHelper;
import org.hibernate.util.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
/** /**
* A cached instance of a persistent class * A cached instance of a persistent class

View File

@ -25,8 +25,8 @@
package org.hibernate.cache.entry; package org.hibernate.cache.entry;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.collection.PersistentCollection; import org.hibernate.collection.PersistentCollection;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.util.ArrayHelper;
/** /**
* @author Gavin King * @author Gavin King

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cache.impl.bridge; package org.hibernate.cache.impl.bridge;
import java.util.Properties; import java.util.Properties;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.cache.CacheDataDescription; import org.hibernate.cache.CacheDataDescription;
@ -36,8 +37,8 @@ import org.hibernate.cache.TimestampsRegion;
import org.hibernate.cache.access.AccessType; import org.hibernate.cache.access.AccessType;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Settings; import org.hibernate.cfg.Settings;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -38,7 +38,7 @@ import org.hibernate.AssertionFailure;
import org.hibernate.annotations.common.reflection.XAnnotatedElement; import org.hibernate.annotations.common.reflection.XAnnotatedElement;
import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard

View File

@ -31,7 +31,6 @@ import org.dom4j.Document;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Interceptor; import org.hibernate.Interceptor;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.persister.PersisterClassProvider;
/** /**
* Similar to the {@link Configuration} object but handles EJB3 and Hibernate * Similar to the {@link Configuration} object but handles EJB3 and Hibernate
@ -238,12 +237,6 @@ public class AnnotationConfiguration extends Configuration {
return this; return this;
} }
@Override
public AnnotationConfiguration setPersisterClassProvider(PersisterClassProvider persisterClassProvider) {
super.setPersisterClassProvider( persisterClassProvider );
return this;
}
@Deprecated @Deprecated
protected class ExtendedMappingsImpl extends MappingsImpl { protected class ExtendedMappingsImpl extends MappingsImpl {
} }

View File

@ -47,6 +47,7 @@ import org.hibernate.cfg.annotations.Nullability;
import org.hibernate.cfg.annotations.TableBinder; import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.id.MultipleHiLoPerTableGenerator; import org.hibernate.id.MultipleHiLoPerTableGenerator;
import org.hibernate.id.PersistentIdentifierGenerator; import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Any; import org.hibernate.mapping.Any;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
@ -61,7 +62,6 @@ import org.hibernate.mapping.SyntheticProperty;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -40,7 +40,7 @@ import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.annotations.EntityBinder; import org.hibernate.cfg.annotations.EntityBinder;
import org.hibernate.cfg.annotations.Nullability; import org.hibernate.cfg.annotations.Nullability;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* Do the initial discovery of columns metadata and apply defaults. * Do the initial discovery of columns metadata and apply defaults.

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -88,7 +89,6 @@ import org.hibernate.engine.Mapping;
import org.hibernate.engine.NamedQueryDefinition; import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition; import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.ResultSetMappingDefinition; import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.event.AutoFlushEventListener; import org.hibernate.event.AutoFlushEventListener;
import org.hibernate.event.DeleteEventListener; import org.hibernate.event.DeleteEventListener;
import org.hibernate.event.DirtyCheckEventListener; import org.hibernate.event.DirtyCheckEventListener;
@ -124,7 +124,20 @@ import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.id.factory.DefaultIdentifierGeneratorFactory; import org.hibernate.id.factory.DefaultIdentifierGeneratorFactory;
import org.hibernate.id.factory.IdentifierGeneratorFactory; import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.impl.SessionFactoryImpl; import org.hibernate.impl.SessionFactoryImpl;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.SerializationHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.internal.util.xml.MappingReader;
import org.hibernate.internal.util.xml.Origin;
import org.hibernate.internal.util.xml.OriginImpl;
import org.hibernate.internal.util.xml.XMLHelper;
import org.hibernate.internal.util.xml.XmlDocument;
import org.hibernate.internal.util.xml.XmlDocumentImpl;
import org.hibernate.mapping.AuxiliaryDatabaseObject; import org.hibernate.mapping.AuxiliaryDatabaseObject;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
@ -144,9 +157,9 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.TypeDef; import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UniqueKey; import org.hibernate.mapping.UniqueKey;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.JACCConfiguration; import org.hibernate.secure.JACCConfiguration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.spi.ServiceRegistry; import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata; import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.IndexMetadata; import org.hibernate.tool.hbm2ddl.IndexMetadata;
@ -158,19 +171,6 @@ import org.hibernate.type.Type;
import org.hibernate.type.TypeResolver; import org.hibernate.type.TypeResolver;
import org.hibernate.usertype.CompositeUserType; import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.hibernate.util.ArrayHelper;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.ConfigHelper;
import org.hibernate.util.JoinedIterator;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.SerializationHelper;
import org.hibernate.util.StringHelper;
import org.hibernate.util.XMLHelper;
import org.hibernate.util.xml.MappingReader;
import org.hibernate.util.xml.Origin;
import org.hibernate.util.xml.OriginImpl;
import org.hibernate.util.xml.XmlDocument;
import org.hibernate.util.xml.XmlDocumentImpl;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -259,7 +259,6 @@ public class Configuration implements Serializable {
protected transient XMLHelper xmlHelper; protected transient XMLHelper xmlHelper;
protected NamingStrategy namingStrategy; protected NamingStrategy namingStrategy;
private PersisterClassProvider persisterClassProvider;
private SessionFactoryObserver sessionFactoryObserver; private SessionFactoryObserver sessionFactoryObserver;
private EventListeners eventListeners; private EventListeners eventListeners;
@ -357,7 +356,6 @@ public class Configuration implements Serializable {
propertyRefResolver = new HashMap<String, String>(); propertyRefResolver = new HashMap<String, String>();
caches = new ArrayList<CacheHolder>(); caches = new ArrayList<CacheHolder>();
namingStrategy = EJB3NamingStrategy.INSTANCE; namingStrategy = EJB3NamingStrategy.INSTANCE;
persisterClassProvider = null;
setEntityResolver( new EJB3DTDEntityResolver() ); setEntityResolver( new EJB3DTDEntityResolver() );
anyMetaDefs = new HashMap<String, AnyMetaDef>(); anyMetaDefs = new HashMap<String, AnyMetaDef>();
propertiesAnnotatedWithMapsId = new HashMap<XClass, Map<String, PropertyData>>(); propertiesAnnotatedWithMapsId = new HashMap<XClass, Map<String, PropertyData>>();
@ -437,7 +435,7 @@ public class Configuration implements Serializable {
/** /**
* Set a custom entity resolver. This entity resolver must be * Set a custom entity resolver. This entity resolver must be
* set before addXXX(misc) call. * set before addXXX(misc) call.
* Default value is {@link org.hibernate.util.DTDEntityResolver} * Default value is {@link org.hibernate.internal.util.xml.DTDEntityResolver}
* *
* @param entityResolver entity resolver to use * @param entityResolver entity resolver to use
*/ */
@ -1824,7 +1822,7 @@ public class Configuration implements Serializable {
Properties copy = new Properties(); Properties copy = new Properties();
copy.putAll( properties ); copy.putAll( properties );
ConfigurationHelper.resolvePlaceHolders( copy ); ConfigurationHelper.resolvePlaceHolders( copy );
Settings settings = buildSettings( copy, serviceRegistry.getService( JdbcServices.class ) ); Settings settings = buildSettings( copy, serviceRegistry );
return new SessionFactoryImpl( return new SessionFactoryImpl(
this, this,
@ -1836,6 +1834,36 @@ public class Configuration implements Serializable {
); );
} }
/**
* Create a {@link SessionFactory} using the properties and mappings in this configuration. The
* {@link SessionFactory} will be immutable, so changes made to {@code this} {@link Configuration} after
* building the {@link SessionFactory} will not affect it.
*
* @return The build {@link SessionFactory}
*
* @throws HibernateException usually indicates an invalid configuration or invalid mapping information
*
* @deprecated Use {@link #buildSessionFactory(ServiceRegistry)} instead
*/
public SessionFactory buildSessionFactory() throws HibernateException {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
final ServiceRegistry serviceRegistry = new ServiceRegistryImpl( properties );
setSessionFactoryObserver(
new SessionFactoryObserver() {
@Override
public void sessionFactoryCreated(SessionFactory factory) {
}
@Override
public void sessionFactoryClosed(SessionFactory factory) {
( (ServiceRegistryImpl ) serviceRegistry ).destroy();
}
}
);
return buildSessionFactory( serviceRegistry );
}
private static final String LEGACY_VALIDATOR_EVENT_LISTENER = "org.hibernate.validator.event.ValidateEventListener"; private static final String LEGACY_VALIDATOR_EVENT_LISTENER = "org.hibernate.validator.event.ValidateEventListener";
private void enableLegacyHibernateValidator() { private void enableLegacyHibernateValidator() {
@ -1981,7 +2009,7 @@ public class Configuration implements Serializable {
/** /**
* Set the current {@link Interceptor} * Set the current {@link Interceptor}
* *
* @param interceptor The {@link Interceptor} to use for the {@link #buildSessionFactory() built} * @param interceptor The {@link Interceptor} to use for the {@link #buildSessionFactory) built}
* {@link SessionFactory}. * {@link SessionFactory}.
* *
* @return this for method chaining * @return this for method chaining
@ -2806,18 +2834,18 @@ public class Configuration implements Serializable {
* *
* @return The build settings * @return The build settings
*/ */
public Settings buildSettings(JdbcServices jdbcServices) { public Settings buildSettings(ServiceRegistry serviceRegistry) {
Properties clone = ( Properties ) properties.clone(); Properties clone = ( Properties ) properties.clone();
ConfigurationHelper.resolvePlaceHolders( clone ); ConfigurationHelper.resolvePlaceHolders( clone );
return buildSettingsInternal( clone, jdbcServices ); return buildSettingsInternal( clone, serviceRegistry );
} }
public Settings buildSettings(Properties props, JdbcServices jdbcServices) throws HibernateException { public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) throws HibernateException {
return buildSettingsInternal( props, jdbcServices ); return buildSettingsInternal( props, serviceRegistry );
} }
private Settings buildSettingsInternal(Properties props, JdbcServices jdbcServices) { private Settings buildSettingsInternal(Properties props, ServiceRegistry serviceRegistry) {
final Settings settings = settingsFactory.buildSettings( props, jdbcServices ); final Settings settings = settingsFactory.buildSettings( props, serviceRegistry );
settings.setEntityTuplizerFactory( this.getEntityTuplizerFactory() ); settings.setEntityTuplizerFactory( this.getEntityTuplizerFactory() );
// settings.setComponentTuplizerFactory( this.getComponentTuplizerFactory() ); // settings.setComponentTuplizerFactory( this.getComponentTuplizerFactory() );
return settings; return settings;
@ -2847,26 +2875,6 @@ public class Configuration implements Serializable {
return this; return this;
} }
public PersisterClassProvider getPersisterClassProvider() {
return persisterClassProvider;
}
/**
* Defines a custom persister class provider.
*
* The persister class is chosen according to the following rules in decreasing priority:
* - the persister class defined explicitly via annotation or XML
* - the persister class returned by the PersisterClassProvider implementation (if not null)
* - the default provider as chosen by Hibernate Core (best choice most of the time)
*
*
* @param persisterClassProvider implementation
*/
public Configuration setPersisterClassProvider(PersisterClassProvider persisterClassProvider) {
this.persisterClassProvider = persisterClassProvider;
return this;
}
/** /**
* Retrieve the IdentifierGeneratorFactory in effect for this configuration. * Retrieve the IdentifierGeneratorFactory in effect for this configuration.
* *
@ -3099,14 +3107,6 @@ public class Configuration implements Serializable {
Configuration.this.namingStrategy = namingStrategy; Configuration.this.namingStrategy = namingStrategy;
} }
public PersisterClassProvider getPersisterClassProvider() {
return persisterClassProvider;
}
public void setPersisterClassProvider(PersisterClassProvider persisterClassProvider) {
Configuration.this.persisterClassProvider = persisterClassProvider;
}
public TypeResolver getTypeResolver() { public TypeResolver getTypeResolver() {
return typeResolver; return typeResolver;
} }

View File

@ -23,7 +23,7 @@
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard

View File

@ -22,9 +22,10 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* The default <tt>NamingStrategy</tt> * The default <tt>NamingStrategy</tt>

View File

@ -22,9 +22,10 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.InputStream; import java.io.InputStream;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.util.DTDEntityResolver; import org.hibernate.internal.util.xml.DTDEntityResolver;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;

View File

@ -24,7 +24,7 @@
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* Naming strategy implementing the EJB3 standards * Naming strategy implementing the EJB3 standards

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.Map; import java.util.Map;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
@ -31,12 +32,12 @@ import org.hibernate.annotations.ColumnTransformers;
import org.hibernate.annotations.Index; import org.hibernate.annotations.Index;
import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.annotations.Nullability; import org.hibernate.cfg.annotations.Nullability;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.Formula; import org.hibernate.mapping.Formula;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -35,13 +36,13 @@ import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas; import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula; import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.util.StringHelper;
/** /**
* Wrap state of an EJB3 @JoinColumn annotation * Wrap state of an EJB3 @JoinColumn annotation
@ -144,7 +145,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
JoinColumnOrFormula [] ann = anns.value(); JoinColumnOrFormula [] ann = anns.value();
Ejb3JoinColumn [] joinColumns = new Ejb3JoinColumn[ann.length]; Ejb3JoinColumn [] joinColumns = new Ejb3JoinColumn[ann.length];
for (int i = 0; i < ann.length; i++) { for (int i = 0; i < ann.length; i++) {
JoinColumnOrFormula join = (JoinColumnOrFormula) ann[i]; JoinColumnOrFormula join = ann[i];
JoinFormula formula = join.formula(); JoinFormula formula = join.formula();
if (formula.value() != null && !formula.value().equals("")) { if (formula.value() != null && !formula.value().equals("")) {
joinColumns[i] = buildJoinFormula( joinColumns[i] = buildJoinFormula(
@ -157,10 +158,10 @@ public class Ejb3JoinColumn extends Ejb3Column {
)[0]; )[0];
} }
} }
return joinColumns; return joinColumns;
} }
/** /**
* build join formula * build join formula
*/ */
@ -255,7 +256,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
} }
Ejb3JoinColumn joinColumn = new Ejb3JoinColumn(); Ejb3JoinColumn joinColumn = new Ejb3JoinColumn();
joinColumn.setJoinAnnotation( ann, null ); joinColumn.setJoinAnnotation( ann, null );
if ( StringHelper.isEmpty( joinColumn.getLogicalColumnName() ) if ( StringHelper.isEmpty( joinColumn.getLogicalColumnName() )
&& ! StringHelper.isEmpty( suffixForDefaultColumnName ) ) { && ! StringHelper.isEmpty( suffixForDefaultColumnName ) ) {
joinColumn.setLogicalColumnName( propertyName + suffixForDefaultColumnName ); joinColumn.setLogicalColumnName( propertyName + suffixForDefaultColumnName );
} }
@ -431,7 +432,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
getMappingColumn().setName( columnName ); getMappingColumn().setName( columnName );
setLogicalColumnName( columnName ); setLogicalColumnName( columnName );
} }
private String buildDefaultColumnName(PersistentClass referencedEntity, String logicalReferencedColumn) { private String buildDefaultColumnName(PersistentClass referencedEntity, String logicalReferencedColumn) {
String columnName; String columnName;
boolean mappedBySide = mappedByTableName != null || mappedByPropertyName != null; boolean mappedBySide = mappedByTableName != null || mappedByPropertyName != null;
@ -505,7 +506,8 @@ public class Ejb3JoinColumn extends Ejb3Column {
linkWithValue( value ); linkWithValue( value );
} }
protected void addColumnBinding(SimpleValue value) { @Override
protected void addColumnBinding(SimpleValue value) {
if ( StringHelper.isEmpty( mappedBy ) ) { if ( StringHelper.isEmpty( mappedBy ) ) {
String unquotedLogColName = StringHelper.unquote( getLogicalColumnName() ); String unquotedLogColName = StringHelper.unquote( getLogicalColumnName() );
String unquotedRefColumn = StringHelper.unquote( getReferencedColumn() ); String unquotedRefColumn = StringHelper.unquote( getReferencedColumn() );
@ -600,7 +602,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
/** /**
* Called to apply column definitions from the referenced FK column to this column. * Called to apply column definitions from the referenced FK column to this column.
* *
* @param column the referenced column. * @param column the referenced column.
*/ */
public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) { public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) {

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
@ -35,8 +36,8 @@ import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.Version; import org.hibernate.Version;
import org.hibernate.bytecode.BytecodeProvider; import org.hibernate.bytecode.BytecodeProvider;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.util.ConfigHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -161,7 +162,7 @@ import org.jboss.logging.Logger;
* <tr> * <tr>
* <td><tt>hibernate.transaction.factory_class</tt></td> * <td><tt>hibernate.transaction.factory_class</tt></td>
* <td>the factory to use for instantiating <tt>Transaction</tt>s. * <td>the factory to use for instantiating <tt>Transaction</tt>s.
* (Defaults to <tt>JDBCTransactionFactory</tt>.)</td> * (Defaults to <tt>JdbcTransactionFactory</tt>.)</td>
* </tr> * </tr>
* <tr> * <tr>
* <td><tt>hibernate.query.substitutions</tt></td><td>query language token substitutions</td> * <td><tt>hibernate.query.substitutions</tt></td><td>query language token substitutions</td>
@ -373,7 +374,8 @@ public final class Environment {
*/ */
public static final String CURRENT_SESSION_CONTEXT_CLASS = "hibernate.current_session_context_class"; public static final String CURRENT_SESSION_CONTEXT_CLASS = "hibernate.current_session_context_class";
/** /**
* <tt>TransactionFactory</tt> implementor to use for creating <tt>Transaction</tt>s * Names the implementation of {@link org.hibernate.engine.transaction.spi.TransactionContext} to use for
* creating {@link org.hibernate.Transaction} instances
*/ */
public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class"; public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class";
/** /**
@ -535,12 +537,12 @@ public final class Environment {
public static final String PREFER_POOLED_VALUES_LO = "hibernate.id.optimizer.pooled.prefer_lo"; public static final String PREFER_POOLED_VALUES_LO = "hibernate.id.optimizer.pooled.prefer_lo";
/** /**
* The maximum number of strong references maintained by {@link org.hibernate.util.SoftLimitMRUCache}. Default is 128. * The maximum number of strong references maintained by {@link org.hibernate.internal.util.collections.SoftLimitMRUCache}. Default is 128.
*/ */
public static final String QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES = "hibernate.query.plan_cache_max_strong_references"; public static final String QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES = "hibernate.query.plan_cache_max_strong_references";
/** /**
* The maximum number of soft references maintained by {@link org.hibernate.util.SoftLimitMRUCache}. Default is 2048. * The maximum number of soft references maintained by {@link org.hibernate.internal.util.collections.SoftLimitMRUCache}. Default is 2048.
*/ */
public static final String QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES = "hibernate.query.plan_cache_max_soft_references"; public static final String QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES = "hibernate.query.plan_cache_max_soft_references";
@ -605,7 +607,7 @@ public final class Environment {
GLOBAL_PROPERTIES.setProperty( USE_REFLECTION_OPTIMIZER, Boolean.FALSE.toString() ); GLOBAL_PROPERTIES.setProperty( USE_REFLECTION_OPTIMIZER, Boolean.FALSE.toString() );
try { try {
InputStream stream = ConfigHelper.getResourceAsStream("/hibernate.properties"); InputStream stream = ConfigHelper.getResourceAsStream( "/hibernate.properties" );
try { try {
GLOBAL_PROPERTIES.load(stream); GLOBAL_PROPERTIES.load(stream);
LOG.propertiesLoaded(ConfigurationHelper.maskOut(GLOBAL_PROPERTIES, PASS)); LOG.propertiesLoaded(ConfigurationHelper.maskOut(GLOBAL_PROPERTIES, PASS));

View File

@ -22,8 +22,9 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.Set; import java.util.Set;
import org.hibernate.util.xml.XmlDocument; import org.hibernate.internal.util.xml.XmlDocument;
/** /**
* Represents a mapping queued for delayed processing to await * Represents a mapping queued for delayed processing to await

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
* *
*/ */
package org.hibernate.util; package org.hibernate.cfg;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -30,8 +30,7 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.hibernate.cfg.Configuration; import org.hibernate.internal.util.StringHelper;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
/** /**
@ -267,7 +266,7 @@ public abstract class ExternalSessionFactoryConfig {
// type=listenerClass // type=listenerClass
// ({sep}type=listenerClass)* // ({sep}type=listenerClass)*
// where {sep} is any whitespace or comma // where {sep} is any whitespace or comma
if ( StringHelper.isNotEmpty( customListenersString) ) { if ( StringHelper.isNotEmpty( customListenersString ) ) {
String[] listenerEntries = ConfigurationHelper.toStringArray( customListenersString, " ,\n\t\r\f" ); String[] listenerEntries = ConfigurationHelper.toStringArray( customListenersString, " ,\n\t\r\f" );
for ( int i = 0; i < listenerEntries.length; i++ ) { for ( int i = 0; i < listenerEntries.length; i++ ) {
final int keyValueSepPosition = listenerEntries[i].indexOf( '=' ); final int keyValueSepPosition = listenerEntries[i].indexOf( '=' );

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -42,6 +43,10 @@ import org.hibernate.engine.FilterDefinition;
import org.hibernate.engine.NamedQueryDefinition; import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.Versioning; import org.hibernate.engine.Versioning;
import org.hibernate.id.PersistentIdentifierGenerator; import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.internal.util.xml.XmlDocument;
import org.hibernate.mapping.Any; import org.hibernate.mapping.Any;
import org.hibernate.mapping.Array; import org.hibernate.mapping.Array;
import org.hibernate.mapping.AuxiliaryDatabaseObject; import org.hibernate.mapping.AuxiliaryDatabaseObject;
@ -86,19 +91,12 @@ import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UnionSubclass; import org.hibernate.mapping.UnionSubclass;
import org.hibernate.mapping.UniqueKey; import org.hibernate.mapping.UniqueKey;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.JoinedSubclassEntityPersister; import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
import org.hibernate.persister.entity.SingleTableEntityPersister; import org.hibernate.persister.entity.SingleTableEntityPersister;
import org.hibernate.persister.entity.UnionSubclassEntityPersister; import org.hibernate.persister.entity.UnionSubclassEntityPersister;
import org.hibernate.type.DiscriminatorType; import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.ForeignKeyDirection; import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.JoinedIterator;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
import org.hibernate.util.xml.XmlDocument;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -684,31 +682,19 @@ public final class HbmBinder {
entity.setMetaAttributes( getMetas( node, inheritedMetas ) ); entity.setMetaAttributes( getMetas( node, inheritedMetas ) );
// PERSISTER // PERSISTER
//persister node in XML has priority over
//persisterClassProvider
//if all fail, the default Hibernate persisters kick in
Attribute persisterNode = node.attribute( "persister" ); Attribute persisterNode = node.attribute( "persister" );
if ( persisterNode != null ) { if ( persisterNode != null ) {
try { try {
entity.setEntityPersisterClass( ReflectHelper.classForName( persisterNode entity.setEntityPersisterClass( ReflectHelper.classForName(
.getValue() ) ); persisterNode
.getValue()
) );
} }
catch (ClassNotFoundException cnfe) { catch (ClassNotFoundException cnfe) {
throw new MappingException( "Could not find persister class: " throw new MappingException( "Could not find persister class: "
+ persisterNode.getValue() ); + persisterNode.getValue() );
} }
} }
else {
final PersisterClassProvider persisterClassProvider = mappings.getPersisterClassProvider();
if ( persisterClassProvider != null ) {
final Class<? extends EntityPersister> persister = persisterClassProvider.getEntityPersisterClass(
entity.getEntityName()
);
if ( persister != null ) {
entity.setEntityPersisterClass( persister );
}
}
}
// CUSTOM SQL // CUSTOM SQL
handleCustomSQL( node, entity ); handleCustomSQL( node, entity );
@ -1397,9 +1383,6 @@ public final class HbmBinder {
// PERSISTER // PERSISTER
//persister node in XML has priority over
//persisterClassProvider
//if all fail, the default Hibernate persisters kick in
Attribute persisterNode = node.attribute( "persister" ); Attribute persisterNode = node.attribute( "persister" );
if ( persisterNode != null ) { if ( persisterNode != null ) {
try { try {
@ -1411,16 +1394,6 @@ public final class HbmBinder {
+ persisterNode.getValue() ); + persisterNode.getValue() );
} }
} }
else {
final PersisterClassProvider persisterClassProvider = mappings.getPersisterClassProvider();
if ( persisterClassProvider != null ) {
final Class<? extends CollectionPersister> persister =
persisterClassProvider.getCollectionPersisterClass( collection.getRole() );
if ( persister != null ) {
collection.setCollectionPersisterClass( persister );
}
}
}
Attribute typeNode = node.attribute( "collection-type" ); Attribute typeNode = node.attribute( "collection-type" );
if ( typeNode != null ) { if ( typeNode != null ) {

View File

@ -22,9 +22,10 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* An improved naming strategy that prefers embedded * An improved naming strategy that prefers embedded

View File

@ -50,7 +50,6 @@ import org.hibernate.mapping.MetadataSource;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.TypeDef; import org.hibernate.mapping.TypeDef;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.type.TypeResolver; import org.hibernate.type.TypeResolver;
/** /**
@ -89,16 +88,6 @@ public interface Mappings {
*/ */
public void setNamingStrategy(NamingStrategy namingStrategy); public void setNamingStrategy(NamingStrategy namingStrategy);
/**
* Get the current persister class provider implementation
*/
public PersisterClassProvider getPersisterClassProvider();
/**
* Set the current persister class provider implementation
*/
public void setPersisterClassProvider(PersisterClassProvider persisterClassProvider);
/** /**
* Returns the currently bound default schema name. * Returns the currently bound default schema name.
* *

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -31,7 +32,7 @@ import org.hibernate.HibernateLogger;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.engine.NamedSQLQueryDefinition; import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.ResultSetMappingDefinition; import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,7 +22,8 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import org.hibernate.util.StringHelper;
import org.hibernate.internal.util.StringHelper;
/** /**
* Provides centralized normalization of how database object names are handled. * Provides centralized normalization of how database object names are handled.

View File

@ -29,6 +29,7 @@ import org.hibernate.MappingException;
import org.hibernate.annotations.ForeignKey; import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.cfg.annotations.PropertyBinder; import org.hibernate.cfg.annotations.PropertyBinder;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.DependantValue; import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
@ -38,7 +39,6 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.type.ForeignKeyDirection; import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.util.StringHelper;
/** /**
* We have to handle OneToOne in a second pass because: * We have to handle OneToOne in a second pass because:

View File

@ -25,6 +25,7 @@
// $Id$ // $Id$
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -44,7 +45,7 @@ import org.hibernate.annotations.Target;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -37,15 +38,15 @@ import org.hibernate.engine.query.sql.NativeSQLQueryCollectionReturn;
import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn; import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn; import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn; import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.ArrayHelper;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.StringHelper;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -99,7 +100,7 @@ public abstract class ResultSetMappingBinder {
private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) { private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
String alias = returnElem.attributeValue( "alias" ); String alias = returnElem.attributeValue( "alias" );
if( StringHelper.isEmpty(alias)) { if( StringHelper.isEmpty( alias )) {
alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key. alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
} }
@ -181,7 +182,7 @@ public abstract class ResultSetMappingBinder {
Element discriminatorResult = returnElement.element("return-discriminator"); Element discriminatorResult = returnElement.element("return-discriminator");
if(discriminatorResult!=null) { if(discriminatorResult!=null) {
ArrayList resultColumns = getResultColumns(discriminatorResult); ArrayList resultColumns = getResultColumns(discriminatorResult);
propertyresults.put("class", ArrayHelper.toStringArray(resultColumns) ); propertyresults.put("class", ArrayHelper.toStringArray( resultColumns ) );
} }
Iterator iterator = returnElement.elementIterator("return-property"); Iterator iterator = returnElement.elementIterator("return-property");
List properties = new ArrayList(); List properties = new ArrayList();
@ -307,7 +308,7 @@ public abstract class ResultSetMappingBinder {
// } // }
// } // }
// but I am not clear enough on the intended purpose of this code block, especially // but I am not clear enough on the intended purpose of this code block, especially
// in relation to the "Reorder properties" code block above... // in relation to the "Reorder properties" code block above...
// String key = StringHelper.root( name ); // String key = StringHelper.root( name );
String key = name; String key = name;
ArrayList intermediateResults = (ArrayList) propertyresults.get( key ); ArrayList intermediateResults = (ArrayList) propertyresults.get( key );

View File

@ -22,17 +22,15 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.Map; import java.util.Map;
import org.hibernate.ConnectionReleaseMode; import org.hibernate.ConnectionReleaseMode;
import org.hibernate.EntityMode; import org.hibernate.EntityMode;
import org.hibernate.cache.QueryCacheFactory; import org.hibernate.cache.QueryCacheFactory;
import org.hibernate.cache.RegionFactory; import org.hibernate.cache.RegionFactory;
import org.hibernate.engine.jdbc.JdbcSupport; import org.hibernate.engine.jdbc.JdbcSupport;
import org.hibernate.engine.jdbc.batch.internal.BatchBuilder;
import org.hibernate.hql.QueryTranslatorFactory; import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.jdbc.util.SQLStatementLogger; import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.transaction.TransactionFactory;
import org.hibernate.transaction.TransactionManagerLookup;
import org.hibernate.tuple.entity.EntityTuplizerFactory; import org.hibernate.tuple.entity.EntityTuplizerFactory;
/** /**
@ -42,9 +40,6 @@ import org.hibernate.tuple.entity.EntityTuplizerFactory;
*/ */
public final class Settings { public final class Settings {
// private boolean showSql;
// private boolean formatSql;
private SQLStatementLogger sqlStatementLogger;
private Integer maximumFetchDepth; private Integer maximumFetchDepth;
private Map querySubstitutions; private Map querySubstitutions;
private int jdbcBatchSize; private int jdbcBatchSize;
@ -73,9 +68,6 @@ public final class Settings {
private ConnectionReleaseMode connectionReleaseMode; private ConnectionReleaseMode connectionReleaseMode;
private RegionFactory regionFactory; private RegionFactory regionFactory;
private QueryCacheFactory queryCacheFactory; private QueryCacheFactory queryCacheFactory;
private TransactionFactory transactionFactory;
private TransactionManagerLookup transactionManagerLookup;
private BatchBuilder batchBuilder;
private QueryTranslatorFactory queryTranslatorFactory; private QueryTranslatorFactory queryTranslatorFactory;
private boolean wrapResultSetsEnabled; private boolean wrapResultSetsEnabled;
private boolean orderUpdatesEnabled; private boolean orderUpdatesEnabled;
@ -92,6 +84,8 @@ public final class Settings {
private JdbcSupport jdbcSupport; private JdbcSupport jdbcSupport;
private String importFiles; private String importFiles;
private JtaPlatform jtaPlatform;
/** /**
* Package protected constructor * Package protected constructor
*/ */
@ -100,14 +94,6 @@ public final class Settings {
// public getters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // public getters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// public boolean isShowSqlEnabled() {
// return showSql;
// }
//
// public boolean isFormatSqlEnabled() {
// return formatSql;
// }
public String getImportFiles() { public String getImportFiles() {
return importFiles; return importFiles;
} }
@ -116,10 +102,6 @@ public final class Settings {
this.importFiles = importFiles; this.importFiles = importFiles;
} }
public SQLStatementLogger getSqlStatementLogger() {
return sqlStatementLogger;
}
public String getDefaultSchemaName() { public String getDefaultSchemaName() {
return defaultSchemaName; return defaultSchemaName;
} }
@ -160,10 +142,6 @@ public final class Settings {
return jdbcFetchSize; return jdbcFetchSize;
} }
public TransactionFactory getTransactionFactory() {
return transactionFactory;
}
public String getSessionFactoryName() { public String getSessionFactoryName() {
return sessionFactoryName; return sessionFactoryName;
} }
@ -188,10 +166,6 @@ public final class Settings {
return regionFactory; return regionFactory;
} }
public TransactionManagerLookup getTransactionManagerLookup() {
return transactionManagerLookup;
}
public boolean isQueryCacheEnabled() { public boolean isQueryCacheEnabled() {
return queryCacheEnabled; return queryCacheEnabled;
} }
@ -224,10 +198,6 @@ public final class Settings {
return flushBeforeCompletionEnabled; return flushBeforeCompletionEnabled;
} }
public BatchBuilder getBatchBuilder() {
return batchBuilder;
}
public boolean isAutoCloseSessionEnabled() { public boolean isAutoCloseSessionEnabled() {
return autoCloseSessionEnabled; return autoCloseSessionEnabled;
} }
@ -295,18 +265,6 @@ public final class Settings {
// package protected setters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // package protected setters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// void setShowSqlEnabled(boolean b) {
// showSql = b;
// }
//
// void setFormatSqlEnabled(boolean b) {
// formatSql = b;
// }
void setSqlStatementLogger(SQLStatementLogger sqlStatementLogger) {
this.sqlStatementLogger = sqlStatementLogger;
}
void setDefaultSchemaName(String string) { void setDefaultSchemaName(String string) {
defaultSchemaName = string; defaultSchemaName = string;
} }
@ -347,10 +305,6 @@ public final class Settings {
jdbcFetchSize = integer; jdbcFetchSize = integer;
} }
void setTransactionFactory(TransactionFactory factory) {
transactionFactory = factory;
}
void setSessionFactoryName(String string) { void setSessionFactoryName(String string) {
sessionFactoryName = string; sessionFactoryName = string;
} }
@ -375,10 +329,6 @@ public final class Settings {
this.regionFactory = regionFactory; this.regionFactory = regionFactory;
} }
void setTransactionManagerLookup(TransactionManagerLookup lookup) {
transactionManagerLookup = lookup;
}
void setQueryCacheEnabled(boolean b) { void setQueryCacheEnabled(boolean b) {
queryCacheEnabled = b; queryCacheEnabled = b;
} }
@ -411,10 +361,6 @@ public final class Settings {
this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled; this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
} }
void setBatcherBuilder(BatchBuilder batchBuilder) {
this.batchBuilder = batchBuilder;
}
void setAutoCloseSessionEnabled(boolean autoCloseSessionEnabled) { void setAutoCloseSessionEnabled(boolean autoCloseSessionEnabled) {
this.autoCloseSessionEnabled = autoCloseSessionEnabled; this.autoCloseSessionEnabled = autoCloseSessionEnabled;
} }
@ -494,4 +440,13 @@ public final class Settings {
// void setBytecodeProvider(BytecodeProvider bytecodeProvider) { // void setBytecodeProvider(BytecodeProvider bytecodeProvider) {
// this.bytecodeProvider = bytecodeProvider; // this.bytecodeProvider = bytecodeProvider;
// } // }
public JtaPlatform getJtaPlatform() {
return jtaPlatform;
}
void setJtaPlatform(JtaPlatform jtaPlatform) {
this.jtaPlatform = jtaPlatform;
}
} }

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -35,18 +36,15 @@ import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.impl.NoCachingRegionFactory; import org.hibernate.cache.impl.NoCachingRegionFactory;
import org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge; import org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge;
import org.hibernate.engine.jdbc.JdbcSupport; import org.hibernate.engine.jdbc.JdbcSupport;
import org.hibernate.engine.jdbc.batch.internal.BatchBuilder;
import org.hibernate.engine.jdbc.spi.ExtractedDatabaseMetaData; import org.hibernate.engine.jdbc.spi.ExtractedDatabaseMetaData;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.hql.QueryTranslatorFactory; import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.util.SQLStatementLogger; import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.transaction.TransactionFactory; import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.transaction.TransactionFactoryFactory;
import org.hibernate.transaction.TransactionManagerLookup;
import org.hibernate.transaction.TransactionManagerLookupFactory;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -65,7 +63,8 @@ public class SettingsFactory implements Serializable {
protected SettingsFactory() { protected SettingsFactory() {
} }
public Settings buildSettings(Properties props, JdbcServices jdbcServices) { public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) {
final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
Settings settings = new Settings(); Settings settings = new Settings();
//SessionFactory name: //SessionFactory name:
@ -89,10 +88,7 @@ public class SettingsFactory implements Serializable {
settings.setJdbcSupport( new JdbcSupport( ! ConfigurationHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, properties ) ) ); settings.setJdbcSupport( new JdbcSupport( ! ConfigurationHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, properties ) ) );
// Transaction settings: // Transaction settings:
settings.setJtaPlatform( serviceRegistry.getService( JtaPlatform.class ) );
TransactionFactory transactionFactory = createTransactionFactory(properties);
settings.setTransactionFactory(transactionFactory);
settings.setTransactionManagerLookup( createTransactionManagerLookup(properties) );
boolean flushBeforeCompletion = ConfigurationHelper.getBoolean(Environment.FLUSH_BEFORE_COMPLETION, properties); boolean flushBeforeCompletion = ConfigurationHelper.getBoolean(Environment.FLUSH_BEFORE_COMPLETION, properties);
LOG.autoFlush(enabledDisabled(flushBeforeCompletion)); LOG.autoFlush(enabledDisabled(flushBeforeCompletion));
@ -111,7 +107,6 @@ public class SettingsFactory implements Serializable {
boolean jdbcBatchVersionedData = ConfigurationHelper.getBoolean(Environment.BATCH_VERSIONED_DATA, properties, false); boolean jdbcBatchVersionedData = ConfigurationHelper.getBoolean(Environment.BATCH_VERSIONED_DATA, properties, false);
if (batchSize > 0) LOG.jdbcBatchUpdates(enabledDisabled(jdbcBatchVersionedData)); if (batchSize > 0) LOG.jdbcBatchUpdates(enabledDisabled(jdbcBatchVersionedData));
settings.setJdbcBatchVersionedData(jdbcBatchVersionedData); settings.setJdbcBatchVersionedData(jdbcBatchVersionedData);
settings.setBatcherBuilder( createBatchBuilder(properties, batchSize) );
boolean useScrollableResultSets = ConfigurationHelper.getBoolean(Environment.USE_SCROLLABLE_RESULTSET, properties, meta.supportsScrollableResults()); boolean useScrollableResultSets = ConfigurationHelper.getBoolean(Environment.USE_SCROLLABLE_RESULTSET, properties, meta.supportsScrollableResults());
LOG.scrollabelResultSets(enabledDisabled(useScrollableResultSets)); LOG.scrollabelResultSets(enabledDisabled(useScrollableResultSets));
@ -133,7 +128,7 @@ public class SettingsFactory implements Serializable {
LOG.connectionReleaseMode(releaseModeName); LOG.connectionReleaseMode(releaseModeName);
ConnectionReleaseMode releaseMode; ConnectionReleaseMode releaseMode;
if ( "auto".equals(releaseModeName) ) { if ( "auto".equals(releaseModeName) ) {
releaseMode = transactionFactory.getDefaultReleaseMode(); releaseMode = serviceRegistry.getService( TransactionFactory.class ).getDefaultReleaseMode();
} }
else { else {
releaseMode = ConnectionReleaseMode.parse( releaseModeName ); releaseMode = ConnectionReleaseMode.parse( releaseModeName );
@ -218,15 +213,6 @@ public class SettingsFactory implements Serializable {
//Statistics and logging: //Statistics and logging:
boolean showSql = ConfigurationHelper.getBoolean(Environment.SHOW_SQL, properties);
if (showSql) LOG.echoingSql();
// settings.setShowSqlEnabled(showSql);
boolean formatSql = ConfigurationHelper.getBoolean(Environment.FORMAT_SQL, properties);
// settings.setFormatSqlEnabled(formatSql);
settings.setSqlStatementLogger( new SQLStatementLogger( showSql, formatSql ) );
boolean useStatistics = ConfigurationHelper.getBoolean(Environment.GENERATE_STATISTICS, properties); boolean useStatistics = ConfigurationHelper.getBoolean(Environment.GENERATE_STATISTICS, properties);
LOG.statistics( enabledDisabled(useStatistics) ); LOG.statistics( enabledDisabled(useStatistics) );
settings.setStatisticsEnabled(useStatistics); settings.setStatisticsEnabled(useStatistics);
@ -300,7 +286,9 @@ public class SettingsFactory implements Serializable {
} }
public static RegionFactory createRegionFactory(Properties properties, boolean cachingEnabled) { public static RegionFactory createRegionFactory(Properties properties, boolean cachingEnabled) {
String regionFactoryClassName = ConfigurationHelper.getString( Environment.CACHE_REGION_FACTORY, properties, null ); String regionFactoryClassName = ConfigurationHelper.getString(
Environment.CACHE_REGION_FACTORY, properties, null
);
if ( regionFactoryClassName == null && cachingEnabled ) { if ( regionFactoryClassName == null && cachingEnabled ) {
String providerClassName = ConfigurationHelper.getString( Environment.CACHE_PROVIDER, properties, null ); String providerClassName = ConfigurationHelper.getString( Environment.CACHE_PROVIDER, properties, null );
if ( providerClassName != null ) { if ( providerClassName != null ) {
@ -341,33 +329,4 @@ public class SettingsFactory implements Serializable {
throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, cnfe); throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, cnfe);
} }
} }
protected BatchBuilder createBatchBuilder(Properties properties, int batchSize) {
String batchBuilderClass = properties.getProperty(Environment.BATCH_STRATEGY);
BatchBuilder batchBuilder;
if (batchBuilderClass==null) {
batchBuilder = batchSize > 0
? new BatchBuilder( batchSize )
: new BatchBuilder();
}
else {
LOG.batcherFactory(batchBuilderClass);
try {
batchBuilder = (BatchBuilder) ReflectHelper.classForName(batchBuilderClass).newInstance();
}
catch (Exception cnfe) {
throw new HibernateException("could not instantiate BatchBuilder: " + batchBuilderClass, cnfe);
}
}
batchBuilder.setJdbcBatchSize( batchSize );
return batchBuilder;
}
protected TransactionFactory createTransactionFactory(Properties properties) {
return TransactionFactoryFactory.buildTransactionFactory(properties);
}
protected TransactionManagerLookup createTransactionManagerLookup(Properties properties) {
return TransactionManagerLookupFactory.getTransactionManagerLookup(properties);
}
} }

View File

@ -22,11 +22,13 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.Iterator; import java.util.Iterator;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.cfg.annotations.TableBinder; import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.ManyToOne; import org.hibernate.mapping.ManyToOne;
@ -34,7 +36,6 @@ import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.util.StringHelper;
/** /**
* Enable a proper set of the FK columns in respect with the id column order * Enable a proper set of the FK columns in respect with the id column order
@ -63,11 +64,13 @@ public class ToOneFkSecondPass extends FkSecondPass {
this.path = entityClassName != null ? path.substring( entityClassName.length() + 1 ) : path; this.path = entityClassName != null ? path.substring( entityClassName.length() + 1 ) : path;
} }
public String getReferencedEntityName() { @Override
public String getReferencedEntityName() {
return ( (ToOne) value ).getReferencedEntityName(); return ( (ToOne) value ).getReferencedEntityName();
} }
public boolean isInPrimaryKey() { @Override
public boolean isInPrimaryKey() {
if ( entityClassName == null ) return false; if ( entityClassName == null ) return false;
final PersistentClass persistentClass = mappings.getClass( entityClassName ); final PersistentClass persistentClass = mappings.getClass( entityClassName );
Property property = persistentClass.getIdentifierProperty(); Property property = persistentClass.getIdentifierProperty();

View File

@ -25,7 +25,7 @@ package org.hibernate.cfg;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.annotations; package org.hibernate.cfg.annotations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
@ -91,6 +92,7 @@ import org.hibernate.cfg.PropertyInferredData;
import org.hibernate.cfg.PropertyPreloadedData; import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.cfg.SecondPass; import org.hibernate.cfg.SecondPass;
import org.hibernate.engine.ExecuteUpdateResultCheckStyle; import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Any; import org.hibernate.mapping.Any;
import org.hibernate.mapping.Backref; import org.hibernate.mapping.Backref;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
@ -107,9 +109,6 @@ import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SingleTableSubclass; import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -400,22 +399,10 @@ public abstract class CollectionBinder {
OptimisticLock lockAnn = property.getAnnotation( OptimisticLock.class ); OptimisticLock lockAnn = property.getAnnotation( OptimisticLock.class );
if ( lockAnn != null ) collection.setOptimisticLocked( !lockAnn.excluded() ); if ( lockAnn != null ) collection.setOptimisticLocked( !lockAnn.excluded() );
//@Persister has priority over PersisterClassProvider
//if all fail, left null and Hibernate defaults kick in
Persister persisterAnn = property.getAnnotation( Persister.class ); Persister persisterAnn = property.getAnnotation( Persister.class );
if ( persisterAnn != null ) { if ( persisterAnn != null ) {
collection.setCollectionPersisterClass( persisterAnn.impl() ); collection.setCollectionPersisterClass( persisterAnn.impl() );
} }
else {
final PersisterClassProvider persisterClassProvider = mappings.getPersisterClassProvider();
if (persisterClassProvider != null) {
final Class<? extends CollectionPersister> persister =
persisterClassProvider.getCollectionPersisterClass( collection.getRole() );
if (persister != null) {
collection.setCollectionPersisterClass( persister );
}
}
}
// set ordering // set ordering
if ( orderBy != null ) collection.setOrderBy( orderBy ); if ( orderBy != null ) collection.setOrderBy( orderBy );

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.annotations; package org.hibernate.cfg.annotations;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -74,6 +75,8 @@ import org.hibernate.cfg.UniqueConstraintHolder;
import org.hibernate.engine.ExecuteUpdateResultCheckStyle; import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.engine.FilterDefinition; import org.hibernate.engine.FilterDefinition;
import org.hibernate.engine.Versioning; import org.hibernate.engine.Versioning;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.DependantValue; import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
@ -82,9 +85,6 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.TableOwner; import org.hibernate.mapping.TableOwner;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -243,9 +243,6 @@ public class EntityBinder {
persistentClass.setSelectBeforeUpdate( selectBeforeUpdate ); persistentClass.setSelectBeforeUpdate( selectBeforeUpdate );
//set persister if needed //set persister if needed
//@Persister has precedence over @Entity.persister
//in both fail we look for the PersisterClassProvider
//if all fail, the persister is left null and the Hibernate defaults kick in
Persister persisterAnn = annotatedClass.getAnnotation( Persister.class ); Persister persisterAnn = annotatedClass.getAnnotation( Persister.class );
Class persister = null; Class persister = null;
if ( persisterAnn != null ) { if ( persisterAnn != null ) {
@ -261,12 +258,6 @@ public class EntityBinder {
throw new AnnotationException( "Could not find persister class: " + persister ); throw new AnnotationException( "Could not find persister class: " + persister );
} }
} }
else {
final PersisterClassProvider persisterClassProvider = mappings.getPersisterClassProvider();
if ( persisterClassProvider != null ) {
persister = persisterClassProvider.getEntityPersisterClass( persistentClass.getEntityName() );
}
}
} }
if ( persister != null ) { if ( persister != null ) {
persistentClass.setEntityPersisterClass( persister ); persistentClass.setEntityPersisterClass( persister );

View File

@ -41,7 +41,7 @@ import org.hibernate.mapping.IdentifierCollection;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.annotations; package org.hibernate.cfg.annotations;
import java.util.Map; import java.util.Map;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
@ -37,13 +38,13 @@ import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder; import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder; import org.hibernate.cfg.PropertyHolderBuilder;
import org.hibernate.cfg.SecondPass; import org.hibernate.cfg.SecondPass;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.IndexBackref; import org.hibernate.mapping.IndexBackref;
import org.hibernate.mapping.List; import org.hibernate.mapping.List;
import org.hibernate.mapping.OneToMany; import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -52,6 +52,7 @@ import org.hibernate.cfg.PropertyHolderBuilder;
import org.hibernate.cfg.PropertyPreloadedData; import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.cfg.SecondPass; import org.hibernate.cfg.SecondPass;
import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.HSQLDialect;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
@ -66,7 +67,6 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.sql.Template; import org.hibernate.sql.Template;
import org.hibernate.util.StringHelper;
/** /**
* Implementation to bind a Map * Implementation to bind a Map

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.annotations; package org.hibernate.cfg.annotations;
import java.util.Map; import java.util.Map;
import javax.persistence.EmbeddedId; import javax.persistence.EmbeddedId;
import javax.persistence.Id; import javax.persistence.Id;
@ -43,6 +44,7 @@ import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.Mappings; import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder; import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyPreloadedData; import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
@ -50,7 +52,6 @@ import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.mapping.RootClass; import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.annotations; package org.hibernate.cfg.annotations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -42,12 +43,12 @@ import org.hibernate.cfg.QuerySecondPass;
import org.hibernate.engine.ResultSetMappingDefinition; import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn; import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn; import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.annotations; package org.hibernate.cfg.annotations;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Types; import java.sql.Types;
import java.util.Calendar; import java.util.Calendar;
@ -48,6 +49,7 @@ import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.NotYetImplementedException; import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass; import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
import org.hibernate.cfg.SetSimpleValueTypeSecondPass; import org.hibernate.cfg.SetSimpleValueTypeSecondPass;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.type.CharacterArrayClobType; import org.hibernate.type.CharacterArrayClobType;
@ -55,7 +57,6 @@ import org.hibernate.type.EnumType;
import org.hibernate.type.PrimitiveCharacterArrayClobType; import org.hibernate.type.PrimitiveCharacterArrayClobType;
import org.hibernate.type.SerializableToBlobType; import org.hibernate.type.SerializableToBlobType;
import org.hibernate.type.WrappedMaterializedBlobType; import org.hibernate.type.WrappedMaterializedBlobType;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.annotations; package org.hibernate.cfg.annotations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -38,6 +39,8 @@ import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.ObjectNameNormalizer; import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.cfg.ObjectNameSource; import org.hibernate.cfg.ObjectNameSource;
import org.hibernate.cfg.UniqueConstraintHolder; import org.hibernate.cfg.UniqueConstraintHolder;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.DependantValue; import org.hibernate.mapping.DependantValue;
@ -48,8 +51,6 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -40,7 +40,7 @@ import org.dom4j.Element;
import org.hibernate.annotations.common.reflection.AnnotationReader; import org.hibernate.annotations.common.reflection.AnnotationReader;
import org.hibernate.annotations.common.reflection.MetadataProvider; import org.hibernate.annotations.common.reflection.MetadataProvider;
import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider; import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider;
import org.hibernate.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
/** /**
* MetadataProvider aware of the JPA Deployment descriptor * MetadataProvider aware of the JPA Deployment descriptor

View File

@ -23,6 +23,7 @@
*/ */
package org.hibernate.cfg.annotations.reflection; package org.hibernate.cfg.annotations.reflection;
import java.beans.Introspector; import java.beans.Introspector;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject; import java.lang.reflect.AccessibleObject;
@ -126,8 +127,8 @@ import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
import org.hibernate.annotations.common.reflection.AnnotationReader; import org.hibernate.annotations.common.reflection.AnnotationReader;
import org.hibernate.annotations.common.reflection.Filter; import org.hibernate.annotations.common.reflection.Filter;
import org.hibernate.annotations.common.reflection.ReflectionUtil; import org.hibernate.annotations.common.reflection.ReflectionUtil;
import org.hibernate.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -140,6 +141,7 @@ import org.jboss.logging.Logger;
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class JPAOverridenAnnotationReader implements AnnotationReader { public class JPAOverridenAnnotationReader implements AnnotationReader {
private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class,
JPAOverridenAnnotationReader.class.getName()); JPAOverridenAnnotationReader.class.getName());
private static final Map<Class, String> annotationToXml; private static final Map<Class, String> annotationToXml;

View File

@ -25,6 +25,7 @@
// $Id$ // $Id$
package org.hibernate.cfg.annotations.reflection; package org.hibernate.cfg.annotations.reflection;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -35,7 +36,7 @@ import org.dom4j.Document;
import org.dom4j.Element; import org.dom4j.Element;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -31,8 +31,8 @@ import java.util.Set;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.event.EventListeners; import org.hibernate.event.EventListeners;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.util.ReflectHelper;
/** /**
* This class has no hard dependency on Bean Validation APIs * This class has no hard dependency on Bean Validation APIs

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.beanvalidation; package org.hibernate.cfg.beanvalidation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -29,7 +30,7 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import javax.validation.groups.Default; import javax.validation.groups.Default;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.beanvalidation; package org.hibernate.cfg.beanvalidation;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -49,13 +50,13 @@ import org.hibernate.event.EventListeners;
import org.hibernate.event.PreDeleteEventListener; import org.hibernate.event.PreDeleteEventListener;
import org.hibernate.event.PreInsertEventListener; import org.hibernate.event.PreInsertEventListener;
import org.hibernate.event.PreUpdateEventListener; import org.hibernate.event.PreUpdateEventListener;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.SingleTableSubclass; import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg.search; package org.hibernate.cfg.search;
import java.util.Properties; import java.util.Properties;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
@ -32,7 +33,7 @@ import org.hibernate.event.PostCollectionUpdateEventListener;
import org.hibernate.event.PostDeleteEventListener; import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PostInsertEventListener; import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEventListener; import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -39,13 +39,13 @@ import org.hibernate.engine.ForeignKeys;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.Status; import org.hibernate.engine.Status;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.collections.EmptyIterator;
import org.hibernate.internal.util.collections.IdentitySet;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.CollectionHelper; import org.hibernate.internal.util.MarkerObject;
import org.hibernate.util.EmptyIterator;
import org.hibernate.util.IdentitySet;
import org.hibernate.util.MarkerObject;
/** /**
* Base class implementing {@link PersistentCollection} * Base class implementing {@link PersistentCollection}

View File

@ -23,6 +23,7 @@
* *
*/ */
package org.hibernate.collection; package org.hibernate.collection;
import java.io.Serializable; import java.io.Serializable;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -34,10 +35,10 @@ import org.dom4j.Element;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.loader.CollectionAliases; import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.CollectionHelper;
/** /**
* A persistent wrapper for an XML element * A persistent wrapper for an XML element
@ -46,17 +47,17 @@ import org.hibernate.util.CollectionHelper;
*/ */
public class PersistentElementHolder extends AbstractPersistentCollection { public class PersistentElementHolder extends AbstractPersistentCollection {
protected Element element; protected Element element;
public PersistentElementHolder(SessionImplementor session, Element element) { public PersistentElementHolder(SessionImplementor session, Element element) {
super(session); super(session);
this.element = element; this.element = element;
setInitialized(); setInitialized();
} }
public Serializable getSnapshot(CollectionPersister persister) public Serializable getSnapshot(CollectionPersister persister)
throws HibernateException { throws HibernateException {
final Type elementType = persister.getElementType(); final Type elementType = persister.getElementType();
List elements = element.elements( persister.getElementNodeName() ); List elements = element.elements( persister.getElementNodeName() );
ArrayList snapshot = new ArrayList( elements.size() ); ArrayList snapshot = new ArrayList( elements.size() );
for ( int i=0; i<elements.size(); i++ ) { for ( int i=0; i<elements.size(); i++ ) {
@ -66,16 +67,17 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
snapshot.add(copy); snapshot.add(copy);
} }
return snapshot; return snapshot;
} }
public Collection getOrphans(Serializable snapshot, String entityName) @Override
public Collection getOrphans(Serializable snapshot, String entityName)
throws HibernateException { throws HibernateException {
//orphan delete not supported for EntityMode.DOM4J //orphan delete not supported for EntityMode.DOM4J
return CollectionHelper.EMPTY_COLLECTION; return CollectionHelper.EMPTY_COLLECTION;
} }
public PersistentElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key) public PersistentElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key)
throws HibernateException { throws HibernateException {
super(session); super(session);
Element owner = (Element) session.getPersistenceContext().getCollectionOwner(key, persister); Element owner = (Element) session.getPersistenceContext().getCollectionOwner(key, persister);
@ -97,7 +99,7 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
Type elementType = persister.getElementType(); Type elementType = persister.getElementType();
ArrayList snapshot = (ArrayList) getSnapshot(); ArrayList snapshot = (ArrayList) getSnapshot();
List elements = element.elements( persister.getElementNodeName() ); List elements = element.elements( persister.getElementNodeName() );
if ( snapshot.size()!= elements.size() ) return false; if ( snapshot.size()!= elements.size() ) return false;
@ -113,8 +115,9 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
public boolean isSnapshotEmpty(Serializable snapshot) { public boolean isSnapshotEmpty(Serializable snapshot) {
return ( (Collection) snapshot ).isEmpty(); return ( (Collection) snapshot ).isEmpty();
} }
public boolean empty() { @Override
public boolean empty() {
return !element.elementIterator().hasNext(); return !element.elementIterator().hasNext();
} }
@ -123,12 +126,12 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ); Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
final Type elementType = persister.getElementType(); final Type elementType = persister.getElementType();
Element subelement = element.addElement( persister.getElementNodeName() ); Element subelement = element.addElement( persister.getElementNodeName() );
elementType.setToXMLNode( subelement, object, persister.getFactory() ); elementType.setToXMLNode( subelement, object, persister.getFactory() );
return object; return object;
} }
public Iterator entries(CollectionPersister persister) { public Iterator entries(CollectionPersister persister) {
final Type elementType = persister.getElementType(); final Type elementType = persister.getElementType();
List elements = element.elements( persister.getElementNodeName() ); List elements = element.elements( persister.getElementNodeName() );
int length = elements.size(); int length = elements.size();
@ -143,13 +146,14 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {} public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {}
public boolean isDirectlyAccessible() { @Override
public boolean isDirectlyAccessible() {
return true; return true;
} }
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
throws HibernateException { throws HibernateException {
Type elementType = persister.getElementType(); Type elementType = persister.getElementType();
Serializable[] cached = (Serializable[]) disassembled; Serializable[] cached = (Serializable[]) disassembled;
for ( int i=0; i<cached.length; i++ ) { for ( int i=0; i<cached.length; i++ ) {
@ -157,11 +161,11 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
Element subelement = element.addElement( persister.getElementNodeName() ); Element subelement = element.addElement( persister.getElementNodeName() );
elementType.setToXMLNode( subelement, object, persister.getFactory() ); elementType.setToXMLNode( subelement, object, persister.getFactory() );
} }
} }
public Serializable disassemble(CollectionPersister persister) throws HibernateException { public Serializable disassemble(CollectionPersister persister) throws HibernateException {
Type elementType = persister.getElementType(); Type elementType = persister.getElementType();
List elements = element.elements( persister.getElementNodeName() ); List elements = element.elements( persister.getElementNodeName() );
int length = elements.size(); int length = elements.size();
@ -174,13 +178,14 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
return result; return result;
} }
public Object getValue() { @Override
public Object getValue() {
return element; return element;
} }
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
throws HibernateException { throws HibernateException {
Type elementType = persister.getElementType(); Type elementType = persister.getElementType();
ArrayList snapshot = (ArrayList) getSnapshot(); ArrayList snapshot = (ArrayList) getSnapshot();
List elements = element.elements( persister.getElementNodeName() ); List elements = element.elements( persister.getElementNodeName() );
@ -197,16 +202,16 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
} }
} }
return result.iterator(); return result.iterator();
} }
public boolean needsInserting(Object entry, int i, Type elementType) public boolean needsInserting(Object entry, int i, Type elementType)
throws HibernateException { throws HibernateException {
ArrayList snapshot = (ArrayList) getSnapshot(); ArrayList snapshot = (ArrayList) getSnapshot();
return i>=snapshot.size() || elementType.isDirty( snapshot.get(i), entry, getSession() ); return i>=snapshot.size() || elementType.isDirty( snapshot.get(i), entry, getSession() );
} }
public boolean needsUpdating(Object entry, int i, Type elementType) public boolean needsUpdating(Object entry, int i, Type elementType)
throws HibernateException { throws HibernateException {
return false; return false;
} }

View File

@ -41,7 +41,7 @@ import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.type.XmlRepresentableType; import org.hibernate.type.XmlRepresentableType;
import org.hibernate.util.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
/** /**
* A persistent wrapper for an XML element * A persistent wrapper for an XML element

View File

@ -23,6 +23,7 @@
* *
*/ */
package org.hibernate.context; package org.hibernate.context;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Map; import java.util.Map;
import javax.transaction.Synchronization; import javax.transaction.Synchronization;
@ -33,7 +34,8 @@ import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.classic.Session; import org.hibernate.classic.Session;
import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.util.JTAHelper; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -74,7 +76,8 @@ public class JTASessionContext implements CurrentSessionContext {
* {@inheritDoc} * {@inheritDoc}
*/ */
public Session currentSession() throws HibernateException { public Session currentSession() throws HibernateException {
TransactionManager transactionManager = factory.getTransactionManager(); final JtaPlatform jtaPlatform = factory.getServiceRegistry().getService( JtaPlatform.class );
final TransactionManager transactionManager = jtaPlatform.retrieveTransactionManager();
if ( transactionManager == null ) { if ( transactionManager == null ) {
throw new HibernateException( "No TransactionManagerLookup specified" ); throw new HibernateException( "No TransactionManagerLookup specified" );
} }
@ -85,9 +88,9 @@ public class JTASessionContext implements CurrentSessionContext {
if ( txn == null ) { if ( txn == null ) {
throw new HibernateException( "Unable to locate current JTA transaction" ); throw new HibernateException( "Unable to locate current JTA transaction" );
} }
if ( !JTAHelper.isInProgress( txn.getStatus() ) ) { if ( !JtaStatusHelper.isActive( txn.getStatus() ) ) {
// We could register the session against the transaction even though it is // We could register the session against the transaction even though it is
// not started, but we'd have no guarentee of ever getting the map // not started, but we'd have no guarantee of ever getting the map
// entries cleaned up (aside from spawning threads). // entries cleaned up (aside from spawning threads).
throw new HibernateException( "Current transaction is not in progress" ); throw new HibernateException( "Current transaction is not in progress" );
} }
@ -99,9 +102,7 @@ public class JTASessionContext implements CurrentSessionContext {
throw new HibernateException( "Problem locating/validating JTA transaction", t ); throw new HibernateException( "Problem locating/validating JTA transaction", t );
} }
final Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null final Object txnIdentifier = jtaPlatform.getTransactionIdentifier( txn );
? txn
: factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );
Session currentSession = ( Session ) currentSessionMap.get( txnIdentifier ); Session currentSession = ( Session ) currentSessionMap.get( txnIdentifier );

View File

@ -23,6 +23,7 @@
* *
*/ */
package org.hibernate.context; package org.hibernate.context;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
@ -40,6 +41,10 @@ import org.hibernate.HibernateLogger;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.classic.Session; import org.hibernate.classic.Session;
import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.event.EventSource;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -73,11 +78,11 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class,
ThreadLocalSessionContext.class.getName()); ThreadLocalSessionContext.class.getName());
private static final Class[] SESSION_PROXY_INTERFACES = new Class[] { private static final Class[] SESSION_PROXY_INTERFACES = new Class[] {
org.hibernate.classic.Session.class, Session.class,
org.hibernate.engine.SessionImplementor.class, SessionImplementor.class,
org.hibernate.engine.jdbc.spi.JDBCContext.Context.class, EventSource.class,
org.hibernate.event.EventSource.class, TransactionContext.class,
org.hibernate.engine.jdbc.LobCreationContext.class LobCreationContext.class
}; };
/** /**

View File

@ -26,7 +26,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* Constrains a property to between two values * Constrains a property to between two values

View File

@ -31,10 +31,10 @@ import org.hibernate.Criteria;
import org.hibernate.EntityMode; import org.hibernate.EntityMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.CompositeType; import org.hibernate.type.CompositeType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/** /**
* Support for query by example. * Support for query by example.

View File

@ -23,14 +23,16 @@
* *
*/ */
package org.hibernate.criterion; package org.hibernate.criterion;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.ArrayHelper;
/** /**
* @deprecated Use <tt>Restrictions</tt>. * @deprecated Use <tt>Restrictions</tt>.
* @see Restrictions * @see Restrictions
* @author Gavin King * @author Gavin King
*/ */
@Deprecated
public final class Expression extends Restrictions { public final class Expression extends Restrictions {
private Expression() { private Expression() {
@ -48,7 +50,8 @@ public final class Expression extends Restrictions {
* @param types * @param types
* @return Criterion * @return Criterion
*/ */
public static Criterion sql(String sql, Object[] values, Type[] types) { @Deprecated
public static Criterion sql(String sql, Object[] values, Type[] types) {
return new SQLCriterion(sql, values, types); return new SQLCriterion(sql, values, types);
} }
/** /**
@ -62,7 +65,8 @@ public final class Expression extends Restrictions {
* @param type * @param type
* @return Criterion * @return Criterion
*/ */
public static Criterion sql(String sql, Object value, Type type) { @Deprecated
public static Criterion sql(String sql, Object value, Type type) {
return new SQLCriterion(sql, new Object[] { value }, new Type[] { type } ); return new SQLCriterion(sql, new Object[] { value }, new Type[] { type } );
} }
/** /**
@ -73,7 +77,8 @@ public final class Expression extends Restrictions {
* @param sql * @param sql
* @return Criterion * @return Criterion
*/ */
public static Criterion sql(String sql) { @Deprecated
public static Criterion sql(String sql) {
return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY, ArrayHelper.EMPTY_TYPE_ARRAY); return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY, ArrayHelper.EMPTY_TYPE_ARRAY);
} }

View File

@ -26,7 +26,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* An identifier constraint * An identifier constraint
@ -46,8 +46,8 @@ public class IdentifierEqExpression implements Criterion {
String[] columns = criteriaQuery.getIdentifierColumns(criteria); String[] columns = criteriaQuery.getIdentifierColumns(criteria);
String result = StringHelper.join( String result = StringHelper.join(
" and ", " and ",
StringHelper.suffix( columns, " = ?" ) StringHelper.suffix( columns, " = ?" )
); );
if (columns.length>1) result = '(' + result + ')'; if (columns.length>1) result = '(' + result + ')';
return result; return result;

View File

@ -26,7 +26,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* A property value, or grouped property value * A property value, or grouped property value

View File

@ -27,9 +27,9 @@ import org.hibernate.Criteria;
import org.hibernate.EntityMode; import org.hibernate.EntityMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.CompositeType; import org.hibernate.type.CompositeType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/** /**
* Constrains the property to a specified list of values * Constrains the property to a specified list of values

View File

@ -29,7 +29,7 @@ import java.util.List;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* A sequence of a logical expressions combined by some * A sequence of a logical expressions combined by some

View File

@ -26,7 +26,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* Constrains a property to be non-null * Constrains a property to be non-null
@ -46,8 +46,8 @@ public class NotNullExpression implements Criterion {
throws HibernateException { throws HibernateException {
String[] columns = criteriaQuery.findColumns(propertyName, criteria); String[] columns = criteriaQuery.findColumns(propertyName, criteria);
String result = StringHelper.join( String result = StringHelper.join(
" or ", " or ",
StringHelper.suffix( columns, " is not null" ) StringHelper.suffix( columns, " is not null" )
); );
if (columns.length>1) result = '(' + result + ')'; if (columns.length>1) result = '(' + result + ')';
return result; return result;

View File

@ -26,7 +26,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* Constrains a property to be null * Constrains a property to be null
@ -46,8 +46,8 @@ public class NullExpression implements Criterion {
throws HibernateException { throws HibernateException {
String[] columns = criteriaQuery.findColumns(propertyName, criteria); String[] columns = criteriaQuery.findColumns(propertyName, criteria);
String result = StringHelper.join( String result = StringHelper.join(
" and ", " and ",
StringHelper.suffix( columns, " is null" ) StringHelper.suffix( columns, " is null" )
); );
if (columns.length>1) result = '(' + result + ')'; if (columns.length>1) result = '(' + result + ')';
return result; return result;

View File

@ -27,8 +27,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.ArrayHelper;
/** /**
* @author Gavin King * @author Gavin King
@ -150,7 +150,7 @@ public class ProjectionList implements EnhancedProjection {
List result = new ArrayList( getLength() ); List result = new ArrayList( getLength() );
for ( int i=0; i<getLength(); i++ ) { for ( int i=0; i<getLength(); i++ ) {
String[] aliases = getProjection(i).getAliases(); String[] aliases = getProjection(i).getAliases();
ArrayHelper.addAll(result, aliases); ArrayHelper.addAll( result, aliases );
} }
return ArrayHelper.toStringArray(result); return ArrayHelper.toStringArray(result);

View File

@ -26,7 +26,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* superclass for comparisons between two properties (with SQL binary operators) * superclass for comparisons between two properties (with SQL binary operators)
@ -52,7 +52,7 @@ public class PropertyExpression implements Criterion {
String[] ycols = criteriaQuery.findColumns(otherPropertyName, criteria); String[] ycols = criteriaQuery.findColumns(otherPropertyName, criteria);
String result = StringHelper.join( String result = StringHelper.join(
" and ", " and ",
StringHelper.add(xcols, getOp(), ycols) StringHelper.add( xcols, getOp(), ycols )
); );
if (xcols.length>1) result = '(' + result + ')'; if (xcols.length>1) result = '(' + result + ')';
return result; return result;

View File

@ -25,8 +25,8 @@
package org.hibernate.criterion; package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/** /**
* A property value, or grouped property value * A property value, or grouped property value

View File

@ -23,11 +23,12 @@
* *
*/ */
package org.hibernate.criterion; package org.hibernate.criterion;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.ArrayHelper;
/** /**
* The <tt>criterion</tt> package may be used by applications as a framework for building * The <tt>criterion</tt> package may be used by applications as a framework for building
@ -325,7 +326,7 @@ public class Restrictions {
} }
return conj; return conj;
} }
/** /**
* Constrain a collection valued property to be empty * Constrain a collection valued property to be empty
*/ */
@ -339,51 +340,51 @@ public class Restrictions {
public static Criterion isNotEmpty(String propertyName) { public static Criterion isNotEmpty(String propertyName) {
return new NotEmptyExpression(propertyName); return new NotEmptyExpression(propertyName);
} }
/** /**
* Constrain a collection valued property by size * Constrain a collection valued property by size
*/ */
public static Criterion sizeEq(String propertyName, int size) { public static Criterion sizeEq(String propertyName, int size) {
return new SizeExpression(propertyName, size, "="); return new SizeExpression(propertyName, size, "=");
} }
/** /**
* Constrain a collection valued property by size * Constrain a collection valued property by size
*/ */
public static Criterion sizeNe(String propertyName, int size) { public static Criterion sizeNe(String propertyName, int size) {
return new SizeExpression(propertyName, size, "<>"); return new SizeExpression(propertyName, size, "<>");
} }
/** /**
* Constrain a collection valued property by size * Constrain a collection valued property by size
*/ */
public static Criterion sizeGt(String propertyName, int size) { public static Criterion sizeGt(String propertyName, int size) {
return new SizeExpression(propertyName, size, "<"); return new SizeExpression(propertyName, size, "<");
} }
/** /**
* Constrain a collection valued property by size * Constrain a collection valued property by size
*/ */
public static Criterion sizeLt(String propertyName, int size) { public static Criterion sizeLt(String propertyName, int size) {
return new SizeExpression(propertyName, size, ">"); return new SizeExpression(propertyName, size, ">");
} }
/** /**
* Constrain a collection valued property by size * Constrain a collection valued property by size
*/ */
public static Criterion sizeGe(String propertyName, int size) { public static Criterion sizeGe(String propertyName, int size) {
return new SizeExpression(propertyName, size, "<="); return new SizeExpression(propertyName, size, "<=");
} }
/** /**
* Constrain a collection valued property by size * Constrain a collection valued property by size
*/ */
public static Criterion sizeLe(String propertyName, int size) { public static Criterion sizeLe(String propertyName, int size) {
return new SizeExpression(propertyName, size, ">="); return new SizeExpression(propertyName, size, ">=");
} }
public static NaturalIdentifier naturalId() { public static NaturalIdentifier naturalId() {
return new NaturalIdentifier(); return new NaturalIdentifier();
} }
} }

View File

@ -27,8 +27,8 @@ import org.hibernate.Criteria;
import org.hibernate.EntityMode; import org.hibernate.EntityMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.TypedValue;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/** /**
* A SQL fragment. The string {alias} will be replaced by the * A SQL fragment. The string {alias} will be replaced by the
@ -43,7 +43,7 @@ public class SQLCriterion implements Criterion {
Criteria criteria, Criteria criteria,
CriteriaQuery criteriaQuery) CriteriaQuery criteriaQuery)
throws HibernateException { throws HibernateException {
return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) ); return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias( criteria ) );
} }
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)

View File

@ -25,8 +25,8 @@
package org.hibernate.criterion; package org.hibernate.criterion;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/** /**
* A SQL fragment. The string {alias} will be replaced by the * A SQL fragment. The string {alias} will be replaced by the
@ -51,7 +51,7 @@ public class SQLProjection implements Projection {
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery) public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException { throws HibernateException {
return StringHelper.replace( groupBy, "{alias}", criteriaQuery.getSQLAlias(criteria) ); return StringHelper.replace( groupBy, "{alias}", criteriaQuery.getSQLAlias( criteria ) );
} }
public Type[] getTypes(Criteria crit, CriteriaQuery criteriaQuery) public Type[] getTypes(Criteria crit, CriteriaQuery criteriaQuery)

View File

@ -50,11 +50,11 @@ import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.id.IdentityGenerator; import org.hibernate.id.IdentityGenerator;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.Lockable;
import org.hibernate.sql.CacheJoinFragment; import org.hibernate.sql.CacheJoinFragment;
import org.hibernate.sql.JoinFragment; import org.hibernate.sql.JoinFragment;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.StringHelper;
/** /**
* Cach&eacute; 2007.1 dialect. This class is required in order to use Hibernate with Intersystems Cach<EFBFBD> SQL.<br> * Cach&eacute; 2007.1 dialect. This class is required in order to use Hibernate with Intersystems Cach<EFBFBD> SQL.<br>

View File

@ -22,14 +22,15 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.dialect.function.AnsiTrimFunction; import org.hibernate.dialect.function.AnsiTrimFunction;
import org.hibernate.dialect.function.DerbyConcatFunction; import org.hibernate.dialect.function.DerbyConcatFunction;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.sql.CaseFragment; import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.DerbyCaseFragment; import org.hibernate.sql.DerbyCaseFragment;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -233,7 +234,7 @@ public String getForUpdateString() {
public boolean supportsLobValueChangePropogation() { public boolean supportsLobValueChangePropogation() {
return false; return false;
} }
@Override @Override
public boolean supportsUnboundedLobLocatorMaterialization() { public boolean supportsUnboundedLobLocatorMaterialization() {
return false; return false;

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -55,6 +56,8 @@ import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.id.IdentityGenerator; import org.hibernate.id.IdentityGenerator;
import org.hibernate.id.SequenceGenerator; import org.hibernate.id.SequenceGenerator;
import org.hibernate.id.TableHiLoGenerator; import org.hibernate.id.TableHiLoGenerator;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.Lockable;
import org.hibernate.sql.ANSICaseFragment; import org.hibernate.sql.ANSICaseFragment;
@ -63,8 +66,9 @@ import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.ForUpdateFragment; import org.hibernate.sql.ForUpdateFragment;
import org.hibernate.sql.JoinFragment; import org.hibernate.sql.JoinFragment;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper; import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
import org.hibernate.util.StringHelper; import org.hibernate.type.descriptor.sql.ClobTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -291,6 +295,67 @@ public abstract class Dialect {
typeNames.put( code, name ); typeNames.put( code, name );
} }
/**
* Allows the dialect to override a {@link SqlTypeDescriptor}.
* <p/>
* If <code>sqlTypeDescriptor</code> is a "standard basic" SQL type
* descriptor, then this method uses {@link #getSqlTypeDescriptorOverride}
* to get an optional override based on the SQL code returned by
* {@link SqlTypeDescriptor#getSqlType()}.
* <p/>
* If this dialect does not provide an override, then this method
* simply returns <code>sqlTypeDescriptor</code>
*
* @param sqlTypeDescriptor The {@link SqlTypeDescriptor} to override
* @return The {@link SqlTypeDescriptor} that should be used for this dialect;
* if there is no override, then <code>sqlTypeDescriptor</code> is returned.
* @throws IllegalArgumentException if <code>sqlTypeDescriptor</code> is null.
*
* @see {@link SqlTypeDescriptor}
* @see {@link #getSqlTypeDescriptorOverride}
* @see {@link StandardBasicTypes#isStandardBasicSqlTypeDescriptor(org.hibernate.type.descriptor.sql.SqlTypeDescriptor)}
*/
public SqlTypeDescriptor resolveSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
if ( sqlTypeDescriptor == null ) {
throw new IllegalArgumentException( "sqlTypeDescriptor is null" );
}
SqlTypeDescriptor overrideBySqlCode = null;
if ( StandardBasicTypes.isStandardBasicSqlTypeDescriptor( sqlTypeDescriptor ) ) {
overrideBySqlCode = getSqlTypeDescriptorOverride( sqlTypeDescriptor.getSqlType() );
}
return overrideBySqlCode == null ? sqlTypeDescriptor : overrideBySqlCode;
}
/**
* Returns the {@link SqlTypeDescriptor} that should override the
* "standard basic" SQL type descriptor for values of the specified
* column type, or null, if there is no override.
*
* @param sqlCode A {@link Types} constant indicating the SQL column type
* @return The {@link SqlTypeDescriptor} that should override the
* "standard basic" SQL type descriptor, or null, if there is no override.
*
* @see {@link SqlTypeDescriptor}
* @see {@link StandardBasicTypes#isStandardBasicSqlTypeDescriptor(org.hibernate.type.descriptor.sql.SqlTypeDescriptor)}
*/
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
SqlTypeDescriptor descriptor;
switch ( sqlCode ) {
case Types.BLOB: {
descriptor = useInputStreamToInsertBlob() ? BlobTypeDescriptor.STREAM_BINDING : null;
break;
}
case Types.CLOB: {
descriptor = useInputStreamToInsertBlob() ? ClobTypeDescriptor.STREAM_BINDING : null;
break;
}
default: {
descriptor = null;
break;
}
}
return descriptor;
}
// hibernate type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // hibernate type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.HibernateLogger; import org.hibernate.HibernateLogger;
@ -32,8 +33,8 @@ import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.io.Serializable; import java.io.Serializable;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
@ -43,12 +44,12 @@ import org.hibernate.dialect.lock.PessimisticReadSelectLockingStrategy;
import org.hibernate.dialect.lock.PessimisticWriteSelectLockingStrategy; import org.hibernate.dialect.lock.PessimisticWriteSelectLockingStrategy;
import org.hibernate.dialect.lock.SelectLockingStrategy; import org.hibernate.dialect.lock.SelectLockingStrategy;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.Lockable;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -309,7 +310,7 @@ public class HSQLDialect extends Dialect {
public String extractConstraintName(SQLException sqle) { public String extractConstraintName(SQLException sqle) {
String constraintName = null; String constraintName = null;
int errorCode = JDBCExceptionHelper.extractErrorCode( sqle ); int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == -8 ) { if ( errorCode == -8 ) {
constraintName = extractUsingTemplate( constraintName = extractUsingTemplate(
@ -346,7 +347,7 @@ public class HSQLDialect extends Dialect {
public String extractConstraintName(SQLException sqle) { public String extractConstraintName(SQLException sqle) {
String constraintName = null; String constraintName = null;
int errorCode = JDBCExceptionHelper.extractErrorCode( sqle ); int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == -8 ) { if ( errorCode == -8 ) {
constraintName = extractUsingTemplate( constraintName = extractUsingTemplate(

View File

@ -26,11 +26,11 @@ import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.StringHelper;
/** /**
* Informix dialect.<br> * Informix dialect.<br>
@ -204,7 +204,7 @@ public class InformixDialect extends Dialect {
public String extractConstraintName(SQLException sqle) { public String extractConstraintName(SQLException sqle) {
String constraintName = null; String constraintName = null;
int errorCode = JDBCExceptionHelper.extractErrorCode(sqle); int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == -268 ) { if ( errorCode == -268 ) {
constraintName = extractUsingTemplate( "Unique constraint (", ") violated.", sqle.getMessage() ); constraintName = extractUsingTemplate( "Unique constraint (", ") violated.", sqle.getMessage() );
} }

View File

@ -30,7 +30,7 @@ import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* An SQL dialect for MySQL (prior to 5.x). * An SQL dialect for MySQL (prior to 5.x).

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -33,15 +34,15 @@ import org.hibernate.dialect.function.NvlFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.sql.CaseFragment; import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.DecodeCaseFragment; import org.hibernate.sql.DecodeCaseFragment;
import org.hibernate.sql.JoinFragment; import org.hibernate.sql.JoinFragment;
import org.hibernate.sql.OracleJoinFragment; import org.hibernate.sql.OracleJoinFragment;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;
/** /**
* A dialect for Oracle 8i. * A dialect for Oracle 8i.
@ -97,7 +98,7 @@ public class Oracle8iDialect extends Dialect {
registerColumnType( Types.CLOB, "clob" ); registerColumnType( Types.CLOB, "clob" );
registerColumnType( Types.LONGVARCHAR, "long" ); registerColumnType( Types.LONGVARCHAR, "long" );
registerColumnType( Types.LONGVARBINARY, "long raw" ); registerColumnType( Types.LONGVARBINARY, "long raw" );
} }
protected void registerReverseHibernateTypeMappings() { protected void registerReverseHibernateTypeMappings() {
@ -379,7 +380,7 @@ public class Oracle8iDialect extends Dialect {
* @return The extracted constraint name. * @return The extracted constraint name.
*/ */
public String extractConstraintName(SQLException sqle) { public String extractConstraintName(SQLException sqle) {
int errorCode = JDBCExceptionHelper.extractErrorCode(sqle); int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) { if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() ); return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
} }

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -34,11 +35,11 @@ import org.hibernate.dialect.function.NvlFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -279,7 +280,7 @@ public class Oracle9Dialect extends Dialect {
* @return The extracted constraint name. * @return The extracted constraint name.
*/ */
public String extractConstraintName(SQLException sqle) { public String extractConstraintName(SQLException sqle) {
int errorCode = JDBCExceptionHelper.extractErrorCode(sqle); int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) { if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() ); return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
} }

View File

@ -34,10 +34,13 @@ import org.hibernate.dialect.function.PositionSubstringFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.id.SequenceGenerator; import org.hibernate.id.SequenceGenerator;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
import org.hibernate.type.descriptor.sql.ClobTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
/** /**
* An SQL dialect for Postgres * An SQL dialect for Postgres
@ -142,6 +145,30 @@ public class PostgreSQLDialect extends Dialect {
registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as varchar)") ); registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as varchar)") );
getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE); getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" );
}
/**
* {@inheritDoc}
*/
@Override
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
SqlTypeDescriptor descriptor;
switch ( sqlCode ) {
case Types.BLOB: {
descriptor = BlobTypeDescriptor.BLOB_BINDING;
break;
}
case Types.CLOB: {
descriptor = ClobTypeDescriptor.CLOB_BINDING;
break;
}
default: {
descriptor = super.getSqlTypeDescriptorOverride( sqlCode );
break;
}
}
return descriptor;
} }
public String getAddColumnString() { public String getAddColumnString() {
@ -307,7 +334,7 @@ public class PostgreSQLDialect extends Dialect {
private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() { private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
public String extractConstraintName(SQLException sqle) { public String extractConstraintName(SQLException sqle) {
try { try {
int sqlState = Integer.valueOf( JDBCExceptionHelper.extractSqlState(sqle)).intValue(); int sqlState = Integer.valueOf( JdbcExceptionHelper.extractSqlState( sqle )).intValue();
switch (sqlState) { switch (sqlState) {
// CHECK VIOLATION // CHECK VIOLATION
case 23514: return extractUsingTemplate("violates check constraint \"","\"", sqle.getMessage()); case 23514: return extractUsingTemplate("violates check constraint \"","\"", sqle.getMessage());
@ -362,8 +389,18 @@ public class PostgreSQLDialect extends Dialect {
return false; return false;
} }
@Override
public boolean supportsExpectedLobUsagePattern() { public boolean supportsExpectedLobUsagePattern() {
// seems to have spotty LOB suppport return true;
}
@Override
public boolean supportsLobValueChangePropogation() {
return false;
}
@Override
public boolean supportsUnboundedLobLocatorMaterialization() {
return false; return false;
} }

View File

@ -22,16 +22,17 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.Types; import java.sql.Types;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.sql.CaseFragment; import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.DecodeCaseFragment; import org.hibernate.sql.DecodeCaseFragment;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.StringHelper;
/** /**
* An SQL dialect compatible with SAP DB. * An SQL dialect compatible with SAP DB.
@ -57,7 +58,7 @@ public class SAPDBDialect extends Dialect {
registerColumnType( Types.NUMERIC, "fixed($p,$s)" ); registerColumnType( Types.NUMERIC, "fixed($p,$s)" );
registerColumnType( Types.CLOB, "long varchar" ); registerColumnType( Types.CLOB, "long varchar" );
registerColumnType( Types.BLOB, "long byte" ); registerColumnType( Types.BLOB, "long byte" );
registerFunction( "abs", new StandardSQLFunction("abs") ); registerFunction( "abs", new StandardSQLFunction("abs") );
registerFunction( "sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER) ); registerFunction( "sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER) );
@ -125,7 +126,7 @@ public class SAPDBDialect extends Dialect {
registerFunction( "index", new StandardSQLFunction("index", StandardBasicTypes.INTEGER) ); registerFunction( "index", new StandardSQLFunction("index", StandardBasicTypes.INTEGER) );
registerFunction( "value", new StandardSQLFunction( "value" ) ); registerFunction( "value", new StandardSQLFunction( "value" ) );
registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) ); registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) ); registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
registerFunction( "locate", new StandardSQLFunction("index", StandardBasicTypes.INTEGER) ); registerFunction( "locate", new StandardSQLFunction("index", StandardBasicTypes.INTEGER) );
@ -144,25 +145,25 @@ public class SAPDBDialect extends Dialect {
} }
public String getAddForeignKeyConstraintString( public String getAddForeignKeyConstraintString(
String constraintName, String constraintName,
String[] foreignKey, String[] foreignKey,
String referencedTable, String referencedTable,
String[] primaryKey, boolean referencesPrimaryKey String[] primaryKey, boolean referencesPrimaryKey
) { ) {
StringBuffer res = new StringBuffer(30) StringBuffer res = new StringBuffer(30)
.append(" foreign key ") .append(" foreign key ")
.append(constraintName) .append(constraintName)
.append(" (") .append(" (")
.append( StringHelper.join(", ", foreignKey) ) .append( StringHelper.join( ", ", foreignKey ) )
.append(") references ") .append(") references ")
.append(referencedTable); .append(referencedTable);
if(!referencesPrimaryKey) { if(!referencesPrimaryKey) {
res.append(" (") res.append(" (")
.append( StringHelper.join(", ", primaryKey) ) .append( StringHelper.join(", ", primaryKey) )
.append(')'); .append(')');
} }
return res.toString(); return res.toString();
} }

View File

@ -26,7 +26,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.util.StringHelper; import org.hibernate.internal.util.StringHelper;
/** /**
* This class maps a type to names. Associations * This class maps a type to names. Associations

View File

@ -76,7 +76,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS
final String sql = determineSql( timeout ); final String sql = determineSql( timeout );
SessionFactoryImplementor factory = session.getFactory(); SessionFactoryImplementor factory = session.getFactory();
try { try {
PreparedStatement st = session.getJDBCContext().getConnectionManager().prepareSelectStatement( sql ); PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql );
try { try {
getLockable().getIdentifierType().nullSafeSet( st, id, 1, session ); getLockable().getIdentifierType().nullSafeSet( st, id, 1, session );
if ( getLockable().isVersioned() ) { if ( getLockable().isVersioned() ) {

View File

@ -94,7 +94,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
} }
SessionFactoryImplementor factory = session.getFactory(); SessionFactoryImplementor factory = session.getFactory();
try { try {
PreparedStatement st = session.getJDBCContext().getConnectionManager().prepareSelectStatement( sql ); PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql );
try { try {
lockable.getVersionType().nullSafeSet( st, version, 1, session ); lockable.getVersionType().nullSafeSet( st, version, 1, session );
int offset = 2; int offset = 2;

View File

@ -76,7 +76,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking
final String sql = determineSql( timeout ); final String sql = determineSql( timeout );
SessionFactoryImplementor factory = session.getFactory(); SessionFactoryImplementor factory = session.getFactory();
try { try {
PreparedStatement st = session.getJDBCContext().getConnectionManager().prepareSelectStatement( sql ); PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql );
try { try {
getLockable().getIdentifierType().nullSafeSet( st, id, 1, session ); getLockable().getIdentifierType().nullSafeSet( st, id, 1, session );
if ( getLockable().isVersioned() ) { if ( getLockable().isVersioned() ) {

Some files were not shown because too many files have changed in this diff Show More