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',
// testing
atomikos: 'com.atomikos:transactions-jdbc:3.7.0',
junit: 'junit:junit:3.8.2',
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: 'org.jboss.shrinkwrap:shrinkwrap-impl-base:1.0.0-alpha-6'
]
@ -110,6 +111,7 @@ subprojects { subProject ->
compile( libraries.logging_tools )
compile( libraries.slf4j_api )
testCompile( libraries.junit )
testCompile( libraries.atomikos )
testRuntime( libraries.slf4j_simple )
testRuntime( libraries.jcl_slf4j )
testRuntime( libraries.jcl_api )
@ -183,12 +185,8 @@ subprojects { subProject ->
sourceCompatibility = "1.6"
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 )
// 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 ->
module.dependencies*.exported = true
}

View File

@ -53,7 +53,7 @@ public class AuthenticationHandler extends DefaultTask {
@TaskAction
public void configureUploadAuthentication() {
// 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>() {
public void execute(MavenDeployer deployer) {
final RemoteRepository repository = deployer.getRepository();

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
/*
* 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
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate;
@ -36,6 +35,9 @@ package org.hibernate;
* @author Gavin King
*/
public class HibernateException extends RuntimeException {
public HibernateException(String s) {
super(s);
}
public HibernateException(Throwable root) {
super(root);
@ -44,10 +46,6 @@ public class HibernateException extends RuntimeException {
public HibernateException(String string, Throwable root) {
super(string, root);
}
public HibernateException(String s) {
super(s);
}
}

View File

@ -1802,4 +1802,16 @@ public interface HibernateLogger extends BasicLogger {
@LogMessage( level = INFO )
@Message( value = "Writing generated schema to file: %s", id = 417 )
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;
import org.hibernate.util.StringHelper;
import org.hibernate.internal.util.StringHelper;
/**
* A problem occurred accessing a property of an instance of a
@ -58,6 +59,7 @@ public class PropertyAccessException extends HibernateException {
return propertyName;
}
@Override
public String getMessage() {
return super.getMessage() +
( wasSetter ? " setter of " : " getter of ") +

View File

@ -23,7 +23,8 @@
*
*/
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.
@ -53,6 +54,7 @@ public class PropertyValueException extends HibernateException {
return propertyName;
}
@Override
public String getMessage() {
return super.getMessage() + ": " +
StringHelper.qualify(entityName, propertyName);

View File

@ -1,10 +1,10 @@
/*
* 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
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,23 +20,20 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* 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 {
protected String getName() {
return "java:/TransactionManager";
public class ResourceClosedException extends HibernateException {
public ResourceClosedException(String s) {
super( s );
}
public String getUserTransactionName() {
return "java:comp/UserTransaction";
public ResourceClosedException(String string, Throwable root) {
super( string, root );
}
}

View File

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

View File

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

View File

@ -1,10 +1,10 @@
/*
* 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
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,108 +20,139 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate;
import javax.transaction.Synchronization;
import org.hibernate.engine.transaction.spi.LocalStatus;
/**
* Allows the application to define units of work, while
* maintaining abstraction from the underlying transaction
* implementation (eg. JTA, JDBC).<br>
* <br>
* A transaction is associated with a <tt>Session</tt> and is
* usually instantiated by a call to <tt>Session.beginTransaction()</tt>.
* 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 transaction. However, it is intended that there be at most one
* uncommitted <tt>Transaction</tt> associated with a particular
* <tt>Session</tt> at any time.<br>
* <br>
* Implementors are not intended to be threadsafe.
* Defines the contract for abstracting applications from the configured underlying means of transaction management.
* Allows the application to define units of work, while maintaining abstraction from the underlying transaction
* implementation (eg. JTA, JDBC).
* <p/>
* A transaction is associated with a {@link Session} and is usually initiated by a call to
* {@link org.hibernate.Session#beginTransaction()}. 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 transaction. However, it is intended that there be at most one uncommitted transaction associated
* with a particular {@link Session} at any time.
* <p/>
* Implementers are not intended to be thread-safe.
*
* @see Session#beginTransaction()
* @see org.hibernate.transaction.TransactionFactory
* @author Anton van Straaten
* @author Steve Ebersole
*/
public interface Transaction {
/**
* Begin a new transaction.
*/
public void begin() throws HibernateException;
/**
* Flush the associated <tt>Session</tt> and end the unit of work (unless
* we are in {@link FlushMode#MANUAL}.
* </p>
* This method will commit the underlying transaction if and only
* if the underlying transaction was initiated by this object.
* Is this transaction the initiator of any underlying transaction?
*
* @throws HibernateException
* @return {@literal true} if this transaction initiated the underlying transaction; {@literal false} otherwise.
*/
public void commit() throws HibernateException;
public boolean isInitiator();
/**
* Force the underlying transaction to roll back.
* Begin this transaction. No-op if the transaction has already been begun. Note that this is not necessarily
* symmetrical since usually multiple calls to {@link #commit} or {@link #rollback} will error.
*
* @throws HibernateException
* @throws HibernateException Indicates a problem beginning the transaction.
*/
public void rollback() throws HibernateException;
public void begin();
/**
* Was this transaction rolled back or set to rollback only?
* 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 Indicates a problem committing the transaction.
*/
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 actions initiated from this local transaction.
* If, for example, the underlying transaction is forced to rollback via
* some other means, this method still reports false because the rollback
* was not initiated from here.
* 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 boolean True if the transaction was rolled back via this
* local transaction; false otherwise.
* @throws HibernateException
* @return The current local status.
*/
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
* via this local transaction; false otherwise.
* @throws HibernateException
*/
public boolean wasCommitted() throws HibernateException;
public LocalStatus getLocalStatus();
/**
* Is this transaction still active?
* <p/>
* Again, this only returns information in relation to the
* local transaction, not the actual underlying transaction.
* 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 boolean Treu if this local transaction is still active.
* @return {@literal true} if the transaction is still active; {@literal false} otherwise.
*
* @throws HibernateException Indicates a problem checking the transaction status.
*/
public boolean isActive() throws HibernateException;
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?
* <p/>
* Answers on a best effort basis. For example, in the case of JDBC based transactions we cannot know that a
* transaction was rolled back when rollback was performed directly through the JDBC {@link java.sql.Connection},
* only when it was rolled back from here.
*
* @return {@literal true} if the transaction is rolled back; {@literal false} otherwise.
*
* @throws HibernateException Indicates a problem checking the transaction status.
*/
public boolean wasRolledBack();
/**
* Register a user synchronization callback for this transaction.
*
* @param synchronization The Synchronization callback to register.
* @throws HibernateException
*
* @throws HibernateException Indicates a problem registering the synchronization.
*/
public void registerSynchronization(Synchronization synchronization)
throws HibernateException;
public void registerSynchronization(Synchronization synchronization) throws HibernateException;
/**
* Set the transaction timeout for any transaction started by
* a subsequent call to <tt>begin()</tt> on this instance.
* Set the transaction timeout for any transaction started by a subsequent call to {@link #begin} on this instance.
*
* @param seconds The number of seconds before a timeout.
*/
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.persister.collection.CollectionPersister;
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
@ -42,11 +42,12 @@ import org.hibernate.util.StringHelper;
*/
public abstract class CollectionAction implements Executable, Serializable, Comparable {
private transient CollectionPersister persister;
private final Serializable key;
private final SessionImplementor session;
private final String collectionRole;
private transient SessionImplementor session;
private final PersistentCollection collection;
private final Serializable key;
private final String collectionRole;
public CollectionAction(
final CollectionPersister persister,
final PersistentCollection collection,
@ -63,9 +64,19 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
return collection;
}
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
ois.defaultReadObject();
persister = session.getFactory().getCollectionPersister( collectionRole );
/**
* Reconnect to session after deserialization...
*/
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 {

View File

@ -27,10 +27,12 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.engine.EntityEntry;
import org.hibernate.engine.EntityKey;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.util.StringHelper;
/**
* 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 Serializable id;
private final Object instance;
private final SessionImplementor session;
private transient Object instance;
private transient SessionImplementor session;
private transient EntityPersister persister;
/**
@ -96,11 +98,18 @@ public abstract class EntityAction
*/
public final Serializable getId() {
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;
}
public final DelayedPostInsertIdentifier getDelayedId() {
return DelayedPostInsertIdentifier.class.isInstance( id ) ?
DelayedPostInsertIdentifier.class.cast( id ) :
null;
}
/**
* entity instance accessor
*
@ -154,15 +163,19 @@ public abstract class EntityAction
}
/**
* Serialization...
*
* @param ois Thed object stream
* @throws IOException Problem performing the default stream reading
* @throws ClassNotFoundException Problem performing the default stream reading
* Reconnect to session after deserialization...
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
ois.defaultReadObject();
persister = session.getFactory().getEntityPersister( entityName );
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().getEntityPersister( entityName );
this.instance = session.getPersistenceContext().getEntity( new EntityKey( id, persister, session.getEntityMode() ) );
}
}
}

View File

@ -23,9 +23,11 @@
*
*/
package org.hibernate.action;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.engine.EntityEntry;
import org.hibernate.engine.EntityKey;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventSource;
@ -37,7 +39,7 @@ import org.hibernate.persister.entity.EntityPersister;
public final class EntityIdentityInsertAction extends EntityAction {
private final Object[] state;
private transient Object[] state;
private final boolean isDelayed;
private final EntityKey delayedEntityKey;
//private CacheEntry cacheEntry;
@ -49,7 +51,12 @@ public final class EntityIdentityInsertAction extends EntityAction {
EntityPersister persister,
SessionImplementor session,
boolean isDelayed) throws HibernateException {
super( session, null, instance, persister );
super(
session,
( isDelayed ? generateDelayedPostInsertIdentifier() : null ),
instance,
persister
);
this.state = state;
this.isDelayed = isDelayed;
this.delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
@ -93,11 +100,13 @@ public final class EntityIdentityInsertAction extends EntityAction {
}
@Override
public boolean needsAfterTransactionCompletion() {
//TODO: simply remove this override if we fix the above todos
return hasPostCommitEventListeners();
}
@Override
protected boolean hasPostCommitEventListeners() {
return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
}
@ -169,10 +178,25 @@ public final class EntityIdentityInsertAction extends EntityAction {
return delayedEntityKey;
}
private synchronized EntityKey generateDelayedEntityKey() {
private synchronized static DelayedPostInsertIdentifier generateDelayedPostInsertIdentifier() {
return new DelayedPostInsertIdentifier();
}
private EntityKey generateDelayedEntityKey() {
if ( !isDelayed ) {
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;
import java.lang.reflect.Modifier;
import net.sf.cglib.beans.BulkBean;
import net.sf.cglib.beans.BulkBeanException;
@ -32,7 +33,7 @@ import org.hibernate.bytecode.BytecodeProvider;
import org.hibernate.bytecode.ProxyFactoryFactory;
import org.hibernate.bytecode.ReflectionOptimizer;
import org.hibernate.bytecode.util.FieldFilter;
import org.hibernate.util.StringHelper;
import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger;
/**

View File

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

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cache;
import java.io.IOException;
import java.io.Serializable;
import java.util.Iterator;
@ -32,10 +33,10 @@ import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.RowSelection;
import org.hibernate.engine.SessionImplementor;
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.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
@ -208,6 +209,7 @@ public class QueryKey implements Serializable {
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object other) {
if ( !( other instanceof QueryKey ) ) {
return false;
@ -251,6 +253,7 @@ public class QueryKey implements Serializable {
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return hashCode;
}
@ -258,6 +261,7 @@ public class QueryKey implements Serializable {
/**
* {@inheritDoc}
*/
@Override
public String toString() {
StringBuffer buf = new StringBuffer()
.append( "sql: " )

View File

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

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cache.impl.bridge;
import java.util.Properties;
import org.hibernate.HibernateLogger;
import org.hibernate.cache.CacheDataDescription;
@ -36,8 +37,8 @@ import org.hibernate.cache.TimestampsRegion;
import org.hibernate.cache.access.AccessType;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Settings;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.util.ReflectHelper;
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.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.util.StringHelper;
import org.hibernate.internal.util.StringHelper;
/**
* @author Emmanuel Bernard

View File

@ -31,7 +31,6 @@ import org.dom4j.Document;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.MappingException;
import org.hibernate.persister.PersisterClassProvider;
/**
* Similar to the {@link Configuration} object but handles EJB3 and Hibernate
@ -238,12 +237,6 @@ public class AnnotationConfiguration extends Configuration {
return this;
}
@Override
public AnnotationConfiguration setPersisterClassProvider(PersisterClassProvider persisterClassProvider) {
super.setPersisterClassProvider( persisterClassProvider );
return this;
}
@Deprecated
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.id.MultipleHiLoPerTableGenerator;
import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
@ -61,7 +62,6 @@ import org.hibernate.mapping.SyntheticProperty;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.util.StringHelper;
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.cfg.annotations.EntityBinder;
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.

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -88,7 +89,6 @@ import org.hibernate.engine.Mapping;
import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.event.AutoFlushEventListener;
import org.hibernate.event.DeleteEventListener;
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.IdentifierGeneratorFactory;
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.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.Collection;
import org.hibernate.mapping.Column;
@ -144,9 +157,9 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UniqueKey;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.JACCConfiguration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.IndexMetadata;
@ -158,19 +171,6 @@ import org.hibernate.type.Type;
import org.hibernate.type.TypeResolver;
import org.hibernate.usertype.CompositeUserType;
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.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
@ -259,7 +259,6 @@ public class Configuration implements Serializable {
protected transient XMLHelper xmlHelper;
protected NamingStrategy namingStrategy;
private PersisterClassProvider persisterClassProvider;
private SessionFactoryObserver sessionFactoryObserver;
private EventListeners eventListeners;
@ -357,7 +356,6 @@ public class Configuration implements Serializable {
propertyRefResolver = new HashMap<String, String>();
caches = new ArrayList<CacheHolder>();
namingStrategy = EJB3NamingStrategy.INSTANCE;
persisterClassProvider = null;
setEntityResolver( new EJB3DTDEntityResolver() );
anyMetaDefs = new HashMap<String, AnyMetaDef>();
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 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
*/
@ -1824,7 +1822,7 @@ public class Configuration implements Serializable {
Properties copy = new Properties();
copy.putAll( properties );
ConfigurationHelper.resolvePlaceHolders( copy );
Settings settings = buildSettings( copy, serviceRegistry.getService( JdbcServices.class ) );
Settings settings = buildSettings( copy, serviceRegistry );
return new SessionFactoryImpl(
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 void enableLegacyHibernateValidator() {
@ -1981,7 +2009,7 @@ public class Configuration implements Serializable {
/**
* 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}.
*
* @return this for method chaining
@ -2806,18 +2834,18 @@ public class Configuration implements Serializable {
*
* @return The build settings
*/
public Settings buildSettings(JdbcServices jdbcServices) {
public Settings buildSettings(ServiceRegistry serviceRegistry) {
Properties clone = ( Properties ) properties.clone();
ConfigurationHelper.resolvePlaceHolders( clone );
return buildSettingsInternal( clone, jdbcServices );
return buildSettingsInternal( clone, serviceRegistry );
}
public Settings buildSettings(Properties props, JdbcServices jdbcServices) throws HibernateException {
return buildSettingsInternal( props, jdbcServices );
public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) throws HibernateException {
return buildSettingsInternal( props, serviceRegistry );
}
private Settings buildSettingsInternal(Properties props, JdbcServices jdbcServices) {
final Settings settings = settingsFactory.buildSettings( props, jdbcServices );
private Settings buildSettingsInternal(Properties props, ServiceRegistry serviceRegistry) {
final Settings settings = settingsFactory.buildSettings( props, serviceRegistry );
settings.setEntityTuplizerFactory( this.getEntityTuplizerFactory() );
// settings.setComponentTuplizerFactory( this.getComponentTuplizerFactory() );
return settings;
@ -2847,26 +2875,6 @@ public class Configuration implements Serializable {
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.
*
@ -3099,14 +3107,6 @@ public class Configuration implements Serializable {
Configuration.this.namingStrategy = namingStrategy;
}
public PersisterClassProvider getPersisterClassProvider() {
return persisterClassProvider;
}
public void setPersisterClassProvider(PersisterClassProvider persisterClassProvider) {
Configuration.this.persisterClassProvider = persisterClassProvider;
}
public TypeResolver getTypeResolver() {
return typeResolver;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@ -35,13 +36,13 @@ import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
import org.hibernate.util.StringHelper;
/**
* Wrap state of an EJB3 @JoinColumn annotation
@ -144,7 +145,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
JoinColumnOrFormula [] ann = anns.value();
Ejb3JoinColumn [] joinColumns = new Ejb3JoinColumn[ann.length];
for (int i = 0; i < ann.length; i++) {
JoinColumnOrFormula join = (JoinColumnOrFormula) ann[i];
JoinColumnOrFormula join = ann[i];
JoinFormula formula = join.formula();
if (formula.value() != null && !formula.value().equals("")) {
joinColumns[i] = buildJoinFormula(
@ -505,6 +506,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
linkWithValue( value );
}
@Override
protected void addColumnBinding(SimpleValue value) {
if ( StringHelper.isEmpty( mappedBy ) ) {
String unquotedLogColName = StringHelper.unquote( getLogicalColumnName() );

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
@ -35,8 +36,8 @@ import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger;
import org.hibernate.Version;
import org.hibernate.bytecode.BytecodeProvider;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.util.ConfigHelper;
import org.jboss.logging.Logger;
@ -161,7 +162,7 @@ import org.jboss.logging.Logger;
* <tr>
* <td><tt>hibernate.transaction.factory_class</tt></td>
* <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>
* <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";
/**
* <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";
/**
@ -535,12 +537,12 @@ public final class Environment {
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";
/**
* 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";
@ -605,7 +607,7 @@ public final class Environment {
GLOBAL_PROPERTIES.setProperty( USE_REFLECTION_OPTIMIZER, Boolean.FALSE.toString() );
try {
InputStream stream = ConfigHelper.getResourceAsStream("/hibernate.properties");
InputStream stream = ConfigHelper.getResourceAsStream( "/hibernate.properties" );
try {
GLOBAL_PROPERTIES.load(stream);
LOG.propertiesLoaded(ConfigurationHelper.maskOut(GLOBAL_PROPERTIES, PASS));

View File

@ -22,8 +22,9 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
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

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -42,6 +43,10 @@ import org.hibernate.engine.FilterDefinition;
import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.Versioning;
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.Array;
import org.hibernate.mapping.AuxiliaryDatabaseObject;
@ -86,19 +91,12 @@ import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UnionSubclass;
import org.hibernate.mapping.UniqueKey;
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.SingleTableEntityPersister;
import org.hibernate.persister.entity.UnionSubclassEntityPersister;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.ForeignKeyDirection;
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;
/**
@ -684,31 +682,19 @@ public final class HbmBinder {
entity.setMetaAttributes( getMetas( node, inheritedMetas ) );
// PERSISTER
//persister node in XML has priority over
//persisterClassProvider
//if all fail, the default Hibernate persisters kick in
Attribute persisterNode = node.attribute( "persister" );
if ( persisterNode != null ) {
try {
entity.setEntityPersisterClass( ReflectHelper.classForName( persisterNode
.getValue() ) );
entity.setEntityPersisterClass( ReflectHelper.classForName(
persisterNode
.getValue()
) );
}
catch (ClassNotFoundException cnfe) {
throw new MappingException( "Could not find persister class: "
+ 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
handleCustomSQL( node, entity );
@ -1397,9 +1383,6 @@ public final class HbmBinder {
// PERSISTER
//persister node in XML has priority over
//persisterClassProvider
//if all fail, the default Hibernate persisters kick in
Attribute persisterNode = node.attribute( "persister" );
if ( persisterNode != null ) {
try {
@ -1411,16 +1394,6 @@ public final class HbmBinder {
+ 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" );
if ( typeNode != null ) {

View File

@ -22,9 +22,10 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.util.StringHelper;
import org.hibernate.internal.util.StringHelper;
/**
* 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.Table;
import org.hibernate.mapping.TypeDef;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.type.TypeResolver;
/**
@ -89,16 +88,6 @@ public interface Mappings {
*/
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.
*

View File

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

View File

@ -22,7 +22,8 @@
* Boston, MA 02110-1301 USA
*/
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.

View File

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

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
import java.util.ArrayList;
import java.util.HashMap;
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.NativeSQLQueryRootReturn;
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.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.type.Type;
import org.hibernate.util.ArrayHelper;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.StringHelper;
/**
* @author Emmanuel Bernard
@ -99,7 +100,7 @@ public abstract class ResultSetMappingBinder {
private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
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.
}
@ -181,7 +182,7 @@ public abstract class ResultSetMappingBinder {
Element discriminatorResult = returnElement.element("return-discriminator");
if(discriminatorResult!=null) {
ArrayList resultColumns = getResultColumns(discriminatorResult);
propertyresults.put("class", ArrayHelper.toStringArray(resultColumns) );
propertyresults.put("class", ArrayHelper.toStringArray( resultColumns ) );
}
Iterator iterator = returnElement.elementIterator("return-property");
List properties = new ArrayList();

View File

@ -22,17 +22,15 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg;
import java.util.Map;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.EntityMode;
import org.hibernate.cache.QueryCacheFactory;
import org.hibernate.cache.RegionFactory;
import org.hibernate.engine.jdbc.JdbcSupport;
import org.hibernate.engine.jdbc.batch.internal.BatchBuilder;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.jdbc.util.SQLStatementLogger;
import org.hibernate.transaction.TransactionFactory;
import org.hibernate.transaction.TransactionManagerLookup;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
/**
@ -42,9 +40,6 @@ import org.hibernate.tuple.entity.EntityTuplizerFactory;
*/
public final class Settings {
// private boolean showSql;
// private boolean formatSql;
private SQLStatementLogger sqlStatementLogger;
private Integer maximumFetchDepth;
private Map querySubstitutions;
private int jdbcBatchSize;
@ -73,9 +68,6 @@ public final class Settings {
private ConnectionReleaseMode connectionReleaseMode;
private RegionFactory regionFactory;
private QueryCacheFactory queryCacheFactory;
private TransactionFactory transactionFactory;
private TransactionManagerLookup transactionManagerLookup;
private BatchBuilder batchBuilder;
private QueryTranslatorFactory queryTranslatorFactory;
private boolean wrapResultSetsEnabled;
private boolean orderUpdatesEnabled;
@ -92,6 +84,8 @@ public final class Settings {
private JdbcSupport jdbcSupport;
private String importFiles;
private JtaPlatform jtaPlatform;
/**
* Package protected constructor
*/
@ -100,14 +94,6 @@ public final class Settings {
// public getters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// public boolean isShowSqlEnabled() {
// return showSql;
// }
//
// public boolean isFormatSqlEnabled() {
// return formatSql;
// }
public String getImportFiles() {
return importFiles;
}
@ -116,10 +102,6 @@ public final class Settings {
this.importFiles = importFiles;
}
public SQLStatementLogger getSqlStatementLogger() {
return sqlStatementLogger;
}
public String getDefaultSchemaName() {
return defaultSchemaName;
}
@ -160,10 +142,6 @@ public final class Settings {
return jdbcFetchSize;
}
public TransactionFactory getTransactionFactory() {
return transactionFactory;
}
public String getSessionFactoryName() {
return sessionFactoryName;
}
@ -188,10 +166,6 @@ public final class Settings {
return regionFactory;
}
public TransactionManagerLookup getTransactionManagerLookup() {
return transactionManagerLookup;
}
public boolean isQueryCacheEnabled() {
return queryCacheEnabled;
}
@ -224,10 +198,6 @@ public final class Settings {
return flushBeforeCompletionEnabled;
}
public BatchBuilder getBatchBuilder() {
return batchBuilder;
}
public boolean isAutoCloseSessionEnabled() {
return autoCloseSessionEnabled;
}
@ -295,18 +265,6 @@ public final class Settings {
// 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) {
defaultSchemaName = string;
}
@ -347,10 +305,6 @@ public final class Settings {
jdbcFetchSize = integer;
}
void setTransactionFactory(TransactionFactory factory) {
transactionFactory = factory;
}
void setSessionFactoryName(String string) {
sessionFactoryName = string;
}
@ -375,10 +329,6 @@ public final class Settings {
this.regionFactory = regionFactory;
}
void setTransactionManagerLookup(TransactionManagerLookup lookup) {
transactionManagerLookup = lookup;
}
void setQueryCacheEnabled(boolean b) {
queryCacheEnabled = b;
}
@ -411,10 +361,6 @@ public final class Settings {
this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
}
void setBatcherBuilder(BatchBuilder batchBuilder) {
this.batchBuilder = batchBuilder;
}
void setAutoCloseSessionEnabled(boolean autoCloseSessionEnabled) {
this.autoCloseSessionEnabled = autoCloseSessionEnabled;
}
@ -494,4 +440,13 @@ public final class Settings {
// void setBytecodeProvider(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
*/
package org.hibernate.cfg;
import java.io.Serializable;
import java.util.Map;
import java.util.Properties;
@ -35,18 +36,15 @@ import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.impl.NoCachingRegionFactory;
import org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge;
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.JdbcServices;
import org.hibernate.engine.transaction.spi.TransactionFactory;
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.jdbc.util.SQLStatementLogger;
import org.hibernate.transaction.TransactionFactory;
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.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.ServiceRegistry;
import org.jboss.logging.Logger;
/**
@ -65,7 +63,8 @@ public class SettingsFactory implements Serializable {
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();
//SessionFactory name:
@ -89,10 +88,7 @@ public class SettingsFactory implements Serializable {
settings.setJdbcSupport( new JdbcSupport( ! ConfigurationHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, properties ) ) );
// Transaction settings:
TransactionFactory transactionFactory = createTransactionFactory(properties);
settings.setTransactionFactory(transactionFactory);
settings.setTransactionManagerLookup( createTransactionManagerLookup(properties) );
settings.setJtaPlatform( serviceRegistry.getService( JtaPlatform.class ) );
boolean flushBeforeCompletion = ConfigurationHelper.getBoolean(Environment.FLUSH_BEFORE_COMPLETION, properties);
LOG.autoFlush(enabledDisabled(flushBeforeCompletion));
@ -111,7 +107,6 @@ public class SettingsFactory implements Serializable {
boolean jdbcBatchVersionedData = ConfigurationHelper.getBoolean(Environment.BATCH_VERSIONED_DATA, properties, false);
if (batchSize > 0) LOG.jdbcBatchUpdates(enabledDisabled(jdbcBatchVersionedData));
settings.setJdbcBatchVersionedData(jdbcBatchVersionedData);
settings.setBatcherBuilder( createBatchBuilder(properties, batchSize) );
boolean useScrollableResultSets = ConfigurationHelper.getBoolean(Environment.USE_SCROLLABLE_RESULTSET, properties, meta.supportsScrollableResults());
LOG.scrollabelResultSets(enabledDisabled(useScrollableResultSets));
@ -133,7 +128,7 @@ public class SettingsFactory implements Serializable {
LOG.connectionReleaseMode(releaseModeName);
ConnectionReleaseMode releaseMode;
if ( "auto".equals(releaseModeName) ) {
releaseMode = transactionFactory.getDefaultReleaseMode();
releaseMode = serviceRegistry.getService( TransactionFactory.class ).getDefaultReleaseMode();
}
else {
releaseMode = ConnectionReleaseMode.parse( releaseModeName );
@ -218,15 +213,6 @@ public class SettingsFactory implements Serializable {
//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);
LOG.statistics( enabledDisabled(useStatistics) );
settings.setStatisticsEnabled(useStatistics);
@ -300,7 +286,9 @@ public class SettingsFactory implements Serializable {
}
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 ) {
String providerClassName = ConfigurationHelper.getString( Environment.CACHE_PROVIDER, properties, null );
if ( providerClassName != null ) {
@ -341,33 +329,4 @@ public class SettingsFactory implements Serializable {
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
*/
package org.hibernate.cfg;
import java.util.Iterator;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.ManyToOne;
@ -34,7 +36,6 @@ import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
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
@ -63,10 +64,12 @@ public class ToOneFkSecondPass extends FkSecondPass {
this.path = entityClassName != null ? path.substring( entityClassName.length() + 1 ) : path;
}
@Override
public String getReferencedEntityName() {
return ( (ToOne) value ).getReferencedEntityName();
}
@Override
public boolean isInPrimaryKey() {
if ( entityClassName == null ) return false;
final PersistentClass persistentClass = mappings.getClass( entityClassName );

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg.annotations;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
@ -91,6 +92,7 @@ import org.hibernate.cfg.PropertyInferredData;
import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.cfg.SecondPass;
import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Backref;
import org.hibernate.mapping.Collection;
@ -107,9 +109,6 @@ import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SingleTableSubclass;
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;
/**
@ -400,22 +399,10 @@ public abstract class CollectionBinder {
OptimisticLock lockAnn = property.getAnnotation( OptimisticLock.class );
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 );
if ( persisterAnn != null ) {
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
if ( orderBy != null ) collection.setOrderBy( orderBy );

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg.annotations;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -74,6 +75,8 @@ import org.hibernate.cfg.UniqueConstraintHolder;
import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.engine.FilterDefinition;
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.Join;
import org.hibernate.mapping.PersistentClass;
@ -82,9 +85,6 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TableOwner;
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;
/**
@ -243,9 +243,6 @@ public class EntityBinder {
persistentClass.setSelectBeforeUpdate( selectBeforeUpdate );
//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 );
Class persister = null;
if ( persisterAnn != null ) {
@ -261,12 +258,6 @@ public class EntityBinder {
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 ) {
persistentClass.setEntityPersisterClass( persister );

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg.annotations;
import java.util.Map;
import org.hibernate.AnnotationException;
import org.hibernate.HibernateLogger;
@ -37,13 +38,13 @@ import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder;
import org.hibernate.cfg.SecondPass;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.IndexBackref;
import org.hibernate.mapping.List;
import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.util.StringHelper;
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.SecondPass;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
@ -66,7 +67,6 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.sql.Template;
import org.hibernate.util.StringHelper;
/**
* Implementation to bind a Map

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg.annotations;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -38,6 +39,8 @@ import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.cfg.ObjectNameSource;
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.Column;
import org.hibernate.mapping.DependantValue;
@ -48,8 +51,6 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.StringHelper;
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.MetadataProvider;
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg.search;
import java.util.Properties;
import org.hibernate.AnnotationException;
import org.hibernate.HibernateLogger;
@ -32,7 +33,7 @@ import org.hibernate.event.PostCollectionUpdateEventListener;
import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.util.ReflectHelper;
import org.hibernate.internal.util.ReflectHelper;
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.Status;
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.pretty.MessageHelper;
import org.hibernate.type.Type;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.EmptyIterator;
import org.hibernate.util.IdentitySet;
import org.hibernate.util.MarkerObject;
import org.hibernate.internal.util.MarkerObject;
/**
* Base class implementing {@link PersistentCollection}

View File

@ -23,6 +23,7 @@
*
*/
package org.hibernate.collection;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -34,10 +35,10 @@ import org.dom4j.Element;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.type.Type;
import org.hibernate.util.CollectionHelper;
/**
* A persistent wrapper for an XML element
@ -69,6 +70,7 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
}
@Override
public Collection getOrphans(Serializable snapshot, String entityName)
throws HibernateException {
//orphan delete not supported for EntityMode.DOM4J
@ -114,6 +116,7 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
return ( (Collection) snapshot ).isEmpty();
}
@Override
public boolean empty() {
return !element.elementIterator().hasNext();
}
@ -143,6 +146,7 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {}
@Override
public boolean isDirectlyAccessible() {
return true;
}
@ -174,6 +178,7 @@ public class PersistentElementHolder extends AbstractPersistentCollection {
return result;
}
@Override
public Object getValue() {
return element;
}

View File

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

View File

@ -23,6 +23,7 @@
*
*/
package org.hibernate.context;
import java.util.Hashtable;
import java.util.Map;
import javax.transaction.Synchronization;
@ -33,7 +34,8 @@ import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger;
import org.hibernate.classic.Session;
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;
/**
@ -74,7 +76,8 @@ public class JTASessionContext implements CurrentSessionContext {
* {@inheritDoc}
*/
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 ) {
throw new HibernateException( "No TransactionManagerLookup specified" );
}
@ -85,9 +88,9 @@ public class JTASessionContext implements CurrentSessionContext {
if ( txn == null ) {
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
// 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).
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 );
}
final Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null
? txn
: factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );
final Object txnIdentifier = jtaPlatform.getTransactionIdentifier( txn );
Session currentSession = ( Session ) currentSessionMap.get( txnIdentifier );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,9 +27,9 @@ import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.CompositeType;
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/**
* 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.HibernateException;
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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
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)
@ -52,7 +52,7 @@ public class PropertyExpression implements Criterion {
String[] ycols = criteriaQuery.findColumns(otherPropertyName, criteria);
String result = StringHelper.join(
" and ",
StringHelper.add(xcols, getOp(), ycols)
StringHelper.add( xcols, getOp(), ycols )
);
if (xcols.length>1) result = '(' + result + ')';
return result;

View File

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

View File

@ -23,11 +23,12 @@
*
*/
package org.hibernate.criterion;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import org.hibernate.internal.util.collections.ArrayHelper;
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

View File

@ -27,8 +27,8 @@ import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/**
* A SQL fragment. The string {alias} will be replaced by the
@ -43,7 +43,7 @@ public class SQLCriterion implements Criterion {
Criteria criteria,
CriteriaQuery criteriaQuery)
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)

View File

@ -25,8 +25,8 @@
package org.hibernate.criterion;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/**
* 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)
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)

View File

@ -50,11 +50,11 @@ import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.id.IdentityGenerator;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.Lockable;
import org.hibernate.sql.CacheJoinFragment;
import org.hibernate.sql.JoinFragment;
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>

View File

@ -22,14 +22,15 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.dialect;
import java.lang.reflect.Method;
import org.hibernate.HibernateLogger;
import org.hibernate.MappingException;
import org.hibernate.dialect.function.AnsiTrimFunction;
import org.hibernate.dialect.function.DerbyConcatFunction;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.DerbyCaseFragment;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger;
/**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.dialect;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -55,6 +56,8 @@ import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.id.IdentityGenerator;
import org.hibernate.id.SequenceGenerator;
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.persister.entity.Lockable;
import org.hibernate.sql.ANSICaseFragment;
@ -63,8 +66,9 @@ import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.ForUpdateFragment;
import org.hibernate.sql.JoinFragment;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
import org.hibernate.type.descriptor.sql.ClobTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
import org.jboss.logging.Logger;
/**
@ -291,6 +295,67 @@ public abstract class Dialect {
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

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

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.dialect;
import java.io.Serializable;
import java.sql.SQLException;
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.SelectLockingStrategy;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
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.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;
import org.jboss.logging.Logger;
/**
@ -309,7 +310,7 @@ public class HSQLDialect extends Dialect {
public String extractConstraintName(SQLException sqle) {
String constraintName = null;
int errorCode = JDBCExceptionHelper.extractErrorCode( sqle );
int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == -8 ) {
constraintName = extractUsingTemplate(
@ -346,7 +347,7 @@ public class HSQLDialect extends Dialect {
public String extractConstraintName(SQLException sqle) {
String constraintName = null;
int errorCode = JDBCExceptionHelper.extractErrorCode( sqle );
int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == -8 ) {
constraintName = extractUsingTemplate(

View File

@ -26,11 +26,11 @@ import java.sql.SQLException;
import java.sql.Types;
import org.hibernate.MappingException;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
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.util.StringHelper;
/**
* Informix dialect.<br>
@ -204,7 +204,7 @@ public class InformixDialect extends Dialect {
public String extractConstraintName(SQLException sqle) {
String constraintName = null;
int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == -268 ) {
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.StandardSQLFunction;
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).

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.dialect;
import java.sql.CallableStatement;
import java.sql.ResultSet;
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.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
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.DecodeCaseFragment;
import org.hibernate.sql.JoinFragment;
import org.hibernate.sql.OracleJoinFragment;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;
/**
* A dialect for Oracle 8i.
@ -379,7 +380,7 @@ public class Oracle8iDialect extends Dialect {
* @return The extracted constraint name.
*/
public String extractConstraintName(SQLException sqle) {
int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
}

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.dialect;
import java.sql.CallableStatement;
import java.sql.ResultSet;
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.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
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.util.ReflectHelper;
import org.jboss.logging.Logger;
/**
@ -279,7 +280,7 @@ public class Oracle9Dialect extends Dialect {
* @return The extracted constraint name.
*/
public String extractConstraintName(SQLException sqle) {
int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
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.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter;
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
@ -142,6 +145,30 @@ public class PostgreSQLDialect extends Dialect {
registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as varchar)") );
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() {
@ -307,7 +334,7 @@ public class PostgreSQLDialect extends Dialect {
private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
public String extractConstraintName(SQLException sqle) {
try {
int sqlState = Integer.valueOf( JDBCExceptionHelper.extractSqlState(sqle)).intValue();
int sqlState = Integer.valueOf( JdbcExceptionHelper.extractSqlState( sqle )).intValue();
switch (sqlState) {
// CHECK VIOLATION
case 23514: return extractUsingTemplate("violates check constraint \"","\"", sqle.getMessage());
@ -362,8 +389,18 @@ public class PostgreSQLDialect extends Dialect {
return false;
}
@Override
public boolean supportsExpectedLobUsagePattern() {
// seems to have spotty LOB suppport
return true;
}
@Override
public boolean supportsLobValueChangePropogation() {
return false;
}
@Override
public boolean supportsUnboundedLobLocatorMaterialization() {
return false;
}

View File

@ -22,16 +22,17 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.DecodeCaseFragment;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.StringHelper;
/**
* An SQL dialect compatible with SAP DB.
@ -153,7 +154,7 @@ public class SAPDBDialect extends Dialect {
.append(" foreign key ")
.append(constraintName)
.append(" (")
.append( StringHelper.join(", ", foreignKey) )
.append( StringHelper.join( ", ", foreignKey ) )
.append(") references ")
.append(referencedTable);

View File

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

View File

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

View File

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

View File

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

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