initial HEM->CORE consolidation work
This commit is contained in:
parent
15c83ab61b
commit
774b805ce1
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import javax.persistence.metamodel.EntityType;
|
||||
import javax.persistence.metamodel.Metamodel;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Metamodel extends javax.persistence.metamodel.Metamodel {
|
||||
EntityType getEntityTypeByName(String entityName);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hibernate.engine.spi;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SharedSessionContractImplementor {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hibernate.engine.transaction.spi;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface TransactionImplementor {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hibernate.graph.spi;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface EntityGraphImplementor {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AbstractSharedSessionContract {
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class ContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable {
|
||||
private AbstractSessionImpl abstractSession;
|
||||
private final SessionEventListener listener;
|
||||
private final MultiTenantConnectionProvider connectionProvider;
|
||||
|
||||
ContextualJdbcConnectionAccess(
|
||||
AbstractSessionImpl abstractSession,
|
||||
SessionEventListener listener,
|
||||
MultiTenantConnectionProvider connectionProvider) {
|
||||
this.abstractSession = abstractSession;
|
||||
this.listener = listener;
|
||||
this.connectionProvider = connectionProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection obtainConnection() throws SQLException {
|
||||
if ( abstractSession.tenantIdentifier == null ) {
|
||||
throw new HibernateException( "Tenant identifier required!" );
|
||||
}
|
||||
|
||||
try {
|
||||
listener.jdbcConnectionAcquisitionStart();
|
||||
return connectionProvider.getConnection( abstractSession.tenantIdentifier );
|
||||
}
|
||||
finally {
|
||||
listener.jdbcConnectionAcquisitionEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseConnection(Connection connection) throws SQLException {
|
||||
if ( abstractSession.tenantIdentifier == null ) {
|
||||
throw new HibernateException( "Tenant identifier required!" );
|
||||
}
|
||||
|
||||
try {
|
||||
listener.jdbcConnectionReleaseStart();
|
||||
connectionProvider.releaseConnection( abstractSession.tenantIdentifier, connection );
|
||||
}
|
||||
finally {
|
||||
listener.jdbcConnectionReleaseEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAggressiveRelease() {
|
||||
return connectionProvider.supportsAggressiveRelease();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import org.hibernate.EntityNameResolver;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class CoordinatingEntityNameResolver implements EntityNameResolver {
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
private final Interceptor interceptor;
|
||||
|
||||
public CoordinatingEntityNameResolver(SessionFactoryImplementor sessionFactory, Interceptor interceptor) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.interceptor = interceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveEntityName(Object entity) {
|
||||
String entityName = interceptor.getEntityName( entity );
|
||||
if ( entityName != null ) {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
for ( EntityNameResolver resolver : sessionFactory.iterateEntityNameResolvers() ) {
|
||||
entityName = resolver.resolveEntityName( entity );
|
||||
if ( entityName != null ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( entityName != null ) {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
// the old-time stand-by...
|
||||
return entity.getClass().getName();
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.internal;
|
||||
package org.hibernate.internal;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
|
@ -0,0 +1,34 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import javax.transaction.SystemException;
|
||||
|
||||
import org.hibernate.TransactionException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ExceptionMapper;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ExceptionMapperStandardImpl implements ExceptionMapper {
|
||||
public static final ExceptionMapper INSTANCE = new ExceptionMapperStandardImpl();
|
||||
|
||||
@Override
|
||||
public RuntimeException mapStatusCheckFailure(
|
||||
String message,
|
||||
SystemException systemException,
|
||||
SessionImplementor sessionImplementor) {
|
||||
return new TransactionException(
|
||||
"could not determine transaction status in beforeCompletion()",
|
||||
systemException
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeException mapManagedFlushFailure(
|
||||
String message,
|
||||
RuntimeException failure,
|
||||
SessionImplementor session) {
|
||||
SessionImpl.log.unableToPerformManagedFlush( failure.getMessage() );
|
||||
return failure;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.internal;
|
||||
package org.hibernate.internal;
|
||||
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.engine.jdbc.spi.ConnectionObserver;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcObserver;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JdbcObserverImpl implements JdbcObserver {
|
||||
|
||||
private final transient List<ConnectionObserver> observers;
|
||||
|
||||
public JdbcObserverImpl() {
|
||||
this.observers = new ArrayList<>();
|
||||
this.observers.add( new ConnectionObserverStatsBridge( factory ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcConnectionAcquisitionStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcConnectionAcquisitionEnd(Connection connection) {
|
||||
for ( ConnectionObserver observer : observers ) {
|
||||
observer.physicalConnectionObtained( connection );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcConnectionReleaseStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcConnectionReleaseEnd() {
|
||||
for ( ConnectionObserver observer : observers ) {
|
||||
observer.physicalConnectionReleased();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcPrepareStatementStart() {
|
||||
getEventListenerManager().jdbcPrepareStatementStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcPrepareStatementEnd() {
|
||||
for ( ConnectionObserver observer : observers ) {
|
||||
observer.statementPrepared();
|
||||
}
|
||||
getEventListenerManager().jdbcPrepareStatementEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcExecuteStatementStart() {
|
||||
getEventListenerManager().jdbcExecuteStatementStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcExecuteStatementEnd() {
|
||||
getEventListenerManager().jdbcExecuteStatementEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcExecuteBatchStart() {
|
||||
getEventListenerManager().jdbcExecuteBatchStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdbcExecuteBatchEnd() {
|
||||
getEventListenerManager().jdbcExecuteBatchEnd();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcObserver;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JdbcSessionContextImpl implements JdbcSessionContext {
|
||||
private final SessionFactoryImpl sessionFactory;
|
||||
private final StatementInspector inspector;
|
||||
private final PhysicalConnectionHandlingMode connectionHandlingMode;
|
||||
|
||||
private final transient ServiceRegistry serviceRegistry;
|
||||
private final transient JdbcObserver jdbcObserver;
|
||||
|
||||
public JdbcSessionContextImpl(SessionFactoryImpl sessionFactory, StatementInspector inspector) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.inspector = inspector;
|
||||
this.connectionHandlingMode = settings().getPhysicalConnectionHandlingMode();
|
||||
this.serviceRegistry = sessionFactory.getServiceRegistry();
|
||||
this.jdbcObserver = new AbstractSessionImpl.JdbcObserverImpl();
|
||||
|
||||
if ( inspector == null ) {
|
||||
throw new IllegalArgumentException( "StatementInspector cannot be null" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScrollableResultSetsEnabled() {
|
||||
return settings().isScrollableResultSetsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGetGeneratedKeysEnabled() {
|
||||
return settings().isGetGeneratedKeysEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchSize() {
|
||||
return settings().getJdbcFetchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() {
|
||||
return connectionHandlingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionReleaseMode getConnectionReleaseMode() {
|
||||
return connectionHandlingMode.getReleaseMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionAcquisitionMode getConnectionAcquisitionMode() {
|
||||
return connectionHandlingMode.getAcquisitionMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatementInspector getStatementInspector() {
|
||||
return inspector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcObserver getObserver() {
|
||||
return this.jdbcObserver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryImplementor getSessionFactory() {
|
||||
return this.sessionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return this.serviceRegistry;
|
||||
}
|
||||
|
||||
private SessionFactoryOptions settings() {
|
||||
return this.sessionFactory.getSessionFactoryOptions();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class NonContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable {
|
||||
private final SessionEventListener listener;
|
||||
private final ConnectionProvider connectionProvider;
|
||||
|
||||
NonContextualJdbcConnectionAccess(
|
||||
SessionEventListener listener,
|
||||
ConnectionProvider connectionProvider) {
|
||||
this.listener = listener;
|
||||
this.connectionProvider = connectionProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection obtainConnection() throws SQLException {
|
||||
try {
|
||||
listener.jdbcConnectionAcquisitionStart();
|
||||
return connectionProvider.getConnection();
|
||||
}
|
||||
finally {
|
||||
listener.jdbcConnectionAcquisitionEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseConnection(Connection connection) throws SQLException {
|
||||
try {
|
||||
listener.jdbcConnectionReleaseStart();
|
||||
connectionProvider.closeConnection( connection );
|
||||
}
|
||||
finally {
|
||||
listener.jdbcConnectionReleaseEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAggressiveRelease() {
|
||||
return connectionProvider.supportsAggressiveRelease();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SessionCreationOptions {
|
||||
}
|
|
@ -4,11 +4,13 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.ejb;
|
||||
package org.hibernate.internal;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.hibernate.jpa.AvailableSettings} instead
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
|
||||
public enum SessionOwnerBehavior {
|
||||
// todo : (5.2) document differences in regard to SessionOwner implementations
|
||||
LEGACY_JPA,
|
||||
LEGACY_NATIVE
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.internal;
|
||||
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl;
|
||||
import org.hibernate.engine.spi.ActionQueue;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
|
||||
/**
|
||||
* An extension of SessionCreationOptions for cases where the Session to be created shares
|
||||
* some part of the "transaction context" of another Session.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @see org.hibernate.SharedSessionBuilder
|
||||
*/
|
||||
public interface SharedSessionCreationOptions extends SessionCreationOptions {
|
||||
TransactionCoordinator getTransactionCoordinator();
|
||||
JdbcCoordinatorImpl getJdbcCoordinator();
|
||||
Transaction getTransaction();
|
||||
ActionQueue.TransactionCompletionProcesses getTransactionCompletionProcesses();
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.internal;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class WrapperOptionsImpl implements WrapperOptions {
|
||||
private final SessionImplementor session;
|
||||
|
||||
private final boolean useStreamForLobBinding;
|
||||
|
||||
public WrapperOptionsImpl(SessionImplementor session) {
|
||||
this.session = session;
|
||||
|
||||
this.useStreamForLobBinding = Environment.useStreamsForBinary()
|
||||
|| session.getFactory().getDialect().useInputStreamToInsertBlob();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useStreamForLobBinding() {
|
||||
return useStreamForLobBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LobCreator getLobCreator() {
|
||||
return Hibernate.getLobCreator( session );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
|
||||
final SqlTypeDescriptor remapped = sqlTypeDescriptor.canBeRemapped()
|
||||
? session.getFactory().getDialect().remapSqlTypeDescriptor( sqlTypeDescriptor )
|
||||
: sqlTypeDescriptor;
|
||||
return remapped == null ? sqlTypeDescriptor : remapped;
|
||||
}
|
||||
}
|
|
@ -15,165 +15,6 @@ package org.hibernate.jpa;
|
|||
*/
|
||||
public interface AvailableSettings {
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// JPA defined settings
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
/**
|
||||
* THe name of the {@link javax.persistence.spi.PersistenceProvider} implementor
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.4
|
||||
*/
|
||||
String PROVIDER = "javax.persistence.provider";
|
||||
|
||||
/**
|
||||
* The type of transactions supported by the entity managers.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.2
|
||||
*/
|
||||
String TRANSACTION_TYPE = "javax.persistence.transactionType";
|
||||
|
||||
/**
|
||||
* The JNDI name of a JTA {@link javax.sql.DataSource}.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.5
|
||||
*/
|
||||
String JTA_DATASOURCE = "javax.persistence.jtaDataSource";
|
||||
|
||||
/**
|
||||
* The JNDI name of a non-JTA {@link javax.sql.DataSource}.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.5
|
||||
*/
|
||||
String NON_JTA_DATASOURCE = "javax.persistence.nonJtaDataSource";
|
||||
|
||||
/**
|
||||
* The name of a JDBC driver to use to connect to the database.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_URL}, {@link #JDBC_USER} and {@link #JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
String JDBC_DRIVER = "javax.persistence.jdbc.driver";
|
||||
|
||||
/**
|
||||
* The JDBC connection url to use to connect to the database.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_DRIVER}, {@link #JDBC_USER} and {@link #JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
String JDBC_URL = "javax.persistence.jdbc.url";
|
||||
|
||||
/**
|
||||
* The JDBC connection user name.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_DRIVER}, {@link #JDBC_URL} and {@link #JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
String JDBC_USER = "javax.persistence.jdbc.user";
|
||||
|
||||
/**
|
||||
* The JDBC connection password.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_DRIVER}, {@link #JDBC_URL} and {@link #JDBC_USER}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
String JDBC_PASSWORD = "javax.persistence.jdbc.password";
|
||||
|
||||
/**
|
||||
* Used to indicate whether second-level (what JPA terms shared cache) caching is
|
||||
* enabled as per the rules defined in JPA 2 section 3.1.7.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.7
|
||||
* @see javax.persistence.SharedCacheMode
|
||||
*/
|
||||
String SHARED_CACHE_MODE = "javax.persistence.sharedCache.mode";
|
||||
|
||||
/**
|
||||
* NOTE : Not a valid EMF property...
|
||||
* <p/>
|
||||
* Used to indicate if the provider should attempt to retrieve requested data
|
||||
* in the shared cache.
|
||||
*
|
||||
* @see javax.persistence.CacheRetrieveMode
|
||||
*/
|
||||
String SHARED_CACHE_RETRIEVE_MODE ="javax.persistence.cache.retrieveMode";
|
||||
|
||||
/**
|
||||
* NOTE : Not a valid EMF property...
|
||||
* <p/>
|
||||
* Used to indicate if the provider should attempt to store data loaded from the database
|
||||
* in the shared cache.
|
||||
*
|
||||
* @see javax.persistence.CacheStoreMode
|
||||
*/
|
||||
String SHARED_CACHE_STORE_MODE ="javax.persistence.cache.storeMode";
|
||||
|
||||
/**
|
||||
* Used to indicate what form of automatic validation is in effect as per rules defined
|
||||
* in JPA 2 section 3.6.1.1
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.8
|
||||
* @see javax.persistence.ValidationMode
|
||||
*/
|
||||
String VALIDATION_MODE = "javax.persistence.validation.mode";
|
||||
|
||||
/**
|
||||
* Used to pass along any discovered validator factory.
|
||||
*/
|
||||
String VALIDATION_FACTORY = "javax.persistence.validation.factory";
|
||||
|
||||
/**
|
||||
* Used to request (hint) a pessimistic lock scope.
|
||||
* <p/>
|
||||
* See JPA 2 sections 8.2.1.9 and 3.4.4.3
|
||||
*/
|
||||
String LOCK_SCOPE = "javax.persistence.lock.scope";
|
||||
|
||||
/**
|
||||
* Used to request (hint) a pessimistic lock timeout (in milliseconds).
|
||||
* <p/>
|
||||
* See JPA 2 sections 8.2.1.9 and 3.4.4.3
|
||||
*/
|
||||
String LOCK_TIMEOUT = "javax.persistence.lock.timeout";
|
||||
|
||||
/**
|
||||
* Used to coordinate with bean validators
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
String PERSIST_VALIDATION_GROUP = "javax.persistence.validation.group.pre-persist";
|
||||
|
||||
/**
|
||||
* Used to coordinate with bean validators
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
String UPDATE_VALIDATION_GROUP = "javax.persistence.validation.group.pre-update";
|
||||
|
||||
/**
|
||||
* Used to coordinate with bean validators
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
String REMOVE_VALIDATION_GROUP = "javax.persistence.validation.group.pre-remove";
|
||||
|
||||
/**
|
||||
* Used to pass along the CDI BeanManager, if any, to be used.
|
||||
*/
|
||||
String CDI_BEAN_MANAGER = "javax.persistence.bean.manager";
|
||||
|
||||
/**
|
||||
* @see org.hibernate.cfg.AvailableSettings#HBM2DDL_CREATE_SOURCE
|
||||
*/
|
||||
|
@ -410,30 +251,6 @@ public interface AvailableSettings {
|
|||
*/
|
||||
String ENTITY_MANAGER_FACTORY_NAME = "hibernate.ejb.entitymanager_factory_name";
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #JPA_METAMODEL_POPULATION} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String JPA_METAMODEL_GENERATION = "hibernate.ejb.metamodel.generation";
|
||||
|
||||
/**
|
||||
* Setting that controls whether we seek out JPA "static metamodel" classes and populate them. Accepts
|
||||
* 3 values:<ul>
|
||||
* <li>
|
||||
* <b>enabled</b> - Do the population
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>disabled</b> - Do not do the population
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>ignoreUnsupported</b> - Do the population, but ignore any non-JPA features that would otherwise
|
||||
* result in the population failing.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
String JPA_METAMODEL_POPULATION = "hibernate.ejb.metamodel.population";
|
||||
|
||||
|
||||
/**
|
||||
* List of classes names
|
|
@ -66,7 +66,7 @@ import org.hibernate.jpa.boot.spi.StrategyRegistrationProviderList;
|
|||
import org.hibernate.jpa.boot.spi.TypeContributorList;
|
||||
import org.hibernate.jpa.event.spi.JpaIntegrator;
|
||||
import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
|
||||
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.jpa.internal.util.LogHelper;
|
||||
import org.hibernate.jpa.internal.util.PersistenceUnitTransactionTypeHelper;
|
||||
import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider;
|
||||
|
@ -92,7 +92,7 @@ import static org.hibernate.jpa.AvailableSettings.DISCARD_PC_ON_CLOSE;
|
|||
import static org.hibernate.jpa.AvailableSettings.PERSISTENCE_UNIT_NAME;
|
||||
import static org.hibernate.jpa.AvailableSettings.SHARED_CACHE_MODE;
|
||||
import static org.hibernate.jpa.AvailableSettings.VALIDATION_MODE;
|
||||
import static org.hibernate.jpa.internal.HEMLogging.messageLogger;
|
||||
import static org.hibernate.internal.HEMLogging.messageLogger;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
|
@ -32,7 +32,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
|||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.xml.XsdException;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.jpa.internal.util.ConfigurationHelper;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
@ -44,7 +44,7 @@ import org.xml.sax.InputSource;
|
|||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import static org.hibernate.jpa.internal.HEMLogging.messageLogger;
|
||||
import static org.hibernate.internal.HEMLogging.messageLogger;
|
||||
|
||||
/**
|
||||
* Used by Hibernate to parse {@code persistence.xml} files in SE environments.
|
|
@ -20,8 +20,8 @@ import org.hibernate.graph.spi.AttributeNodeImplementor;
|
|||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
|
||||
import org.hibernate.jpa.internal.metamodel.Helper;
|
||||
import org.hibernate.jpa.internal.metamodel.PluralAttributeImpl;
|
||||
import org.hibernate.metamodel.internal.Helper;
|
||||
import org.hibernate.metamodel.internal.PluralAttributeImpl;
|
||||
import org.hibernate.jpa.spi.HibernateEntityManagerFactoryAware;
|
||||
import org.hibernate.persister.collection.QueryableCollection;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.internal;
|
||||
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.AfterCompletionAction;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AfterCompletionActionLegacyJpaImpl implements AfterCompletionAction {
|
||||
/**
|
||||
* Singleton access
|
||||
*/
|
||||
public static final AfterCompletionActionLegacyJpaImpl INSTANCE = new AfterCompletionActionLegacyJpaImpl();
|
||||
|
||||
@Override
|
||||
public void doAction(boolean successful, SessionImplementor session) {
|
||||
if ( session.isClosed() ) {
|
||||
EntityManagerImpl.LOG.trace( "Session was closed; nothing to do" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !successful && session.getTransactionType() == PersistenceUnitTransactionType.JTA ) {
|
||||
session.clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.internal;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.transaction.SystemException;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ExceptionMapper;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ExceptionMapperLegacyJpaImpl implements ExceptionMapper {
|
||||
/**
|
||||
* Singleton access
|
||||
*/
|
||||
public static final ExceptionMapperLegacyJpaImpl INSTANCE = new ExceptionMapperLegacyJpaImpl();
|
||||
|
||||
@Override
|
||||
public RuntimeException mapStatusCheckFailure(String message, SystemException systemException, SessionImplementor session) {
|
||||
throw new PersistenceException( message, systemException );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeException mapManagedFlushFailure(String message, RuntimeException failure, SessionImplementor session) {
|
||||
if ( HibernateException.class.isInstance( failure ) ) {
|
||||
throw session.convert( failure );
|
||||
}
|
||||
if ( PersistenceException.class.isInstance( failure ) ) {
|
||||
throw failure;
|
||||
}
|
||||
throw new PersistenceException( message, failure );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.internal;
|
||||
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.internal.SessionImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ManagedFlushChecker;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class ManagedFlushCheckerLegacyJpaImpl implements ManagedFlushChecker {
|
||||
@Override
|
||||
public boolean shouldDoManagedFlush(SessionImplementor session) {
|
||||
return !session.isClosed()
|
||||
&& session.getHibernateFlushMode() == FlushMode.MANUAL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.PersistenceUnitUtil;
|
||||
import javax.persistence.spi.LoadState;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.ejb.HibernateEntityManagerFactory;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.jpa.internal.util.PersistenceUtilHelper;
|
||||
import org.hibernate.metadata.ClassMetadata;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class PersistenceUnitUtilImpl implements PersistenceUnitUtil, Serializable {
|
||||
private static final Logger log = Logger.getLogger( PersistenceUnitUtilImpl.class );
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
private final transient PersistenceUtilHelper.MetadataCache cache = new PersistenceUtilHelper.MetadataCache();
|
||||
|
||||
PersistenceUnitUtilImpl(SessionFactoryImplementor sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded(Object entity, String attributeName) {
|
||||
// added log message to help with HHH-7454, if state == LoadState,NOT_LOADED, returning true or false is not accurate.
|
||||
log.debug( "PersistenceUnitUtil#isLoaded is not always accurate; consider using EntityManager#contains instead" );
|
||||
LoadState state = PersistenceUtilHelper.isLoadedWithoutReference( entity, attributeName, cache );
|
||||
if ( state == LoadState.LOADED ) {
|
||||
return true;
|
||||
}
|
||||
else if ( state == LoadState.NOT_LOADED ) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return PersistenceUtilHelper.isLoadedWithReference(
|
||||
entity,
|
||||
attributeName,
|
||||
cache
|
||||
) != LoadState.NOT_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded(Object entity) {
|
||||
// added log message to help with HHH-7454, if state == LoadState,NOT_LOADED, returning true or false is not accurate.
|
||||
log.debug( "PersistenceUnitUtil#isLoaded is not always accurate; consider using EntityManager#contains instead" );
|
||||
return PersistenceUtilHelper.isLoaded( entity ) != LoadState.NOT_LOADED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getIdentifier(Object entity) {
|
||||
final Class entityClass = Hibernate.getClass( entity );
|
||||
final EntityPersister persister = sessionFactory.getMetamodel().entityPersister( entityClass );
|
||||
if ( persister == null ) {
|
||||
throw new IllegalArgumentException( entityClass + " is not an entity" );
|
||||
}
|
||||
//TODO does that work for @IdClass?
|
||||
return persister.getIdentifier( entity );
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ import org.hibernate.engine.query.spi.OrdinalParameterDescriptor;
|
|||
import org.hibernate.engine.query.spi.ParameterMetadata;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.hql.internal.QueryExecutionRequestException;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.SQLQueryImpl;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateQuery;
|
||||
|
@ -49,7 +50,7 @@ import org.hibernate.type.Type;
|
|||
import static javax.persistence.TemporalType.DATE;
|
||||
import static javax.persistence.TemporalType.TIME;
|
||||
import static javax.persistence.TemporalType.TIMESTAMP;
|
||||
import static org.hibernate.jpa.internal.HEMLogging.messageLogger;
|
||||
import static org.hibernate.internal.HEMLogging.messageLogger;
|
||||
|
||||
/**
|
||||
* Hibernate implementation of both the {@link Query} and {@link TypedQuery} contracts.
|
||||
|
@ -59,7 +60,7 @@ import static org.hibernate.jpa.internal.HEMLogging.messageLogger;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class QueryImpl<X> extends AbstractQueryImpl<X>
|
||||
implements TypedQuery<X>, HibernateQuery, org.hibernate.ejb.HibernateQuery {
|
||||
implements TypedQuery<X>, HibernateQuery {
|
||||
public static final EntityManagerMessageLogger LOG = messageLogger( QueryImpl.class );
|
||||
|
||||
private org.hibernate.Query query;
|
|
@ -8,4 +8,4 @@
|
|||
/**
|
||||
* Defines Hibernate implementation of Java Persistence specification.
|
||||
*/
|
||||
package org.hibernate.jpa;
|
||||
package org.hibernate.jpa.internal;
|
|
@ -0,0 +1,7 @@
|
|||
package org.hibernate.jpa.internal.util;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class FlushModeTypeHelper {
|
||||
}
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
|
@ -88,15 +88,15 @@ import org.hibernate.internal.util.collections.CollectionHelper;
|
|||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.jpa.criteria.ValueHandlerFactory;
|
||||
import org.hibernate.jpa.criteria.compile.CompilableCriteria;
|
||||
import org.hibernate.jpa.criteria.compile.CriteriaCompiler;
|
||||
import org.hibernate.jpa.criteria.expression.CompoundSelectionImpl;
|
||||
import org.hibernate.query.criteria.internal.ValueHandlerFactory;
|
||||
import org.hibernate.query.criteria.internal.compile.CompilableCriteria;
|
||||
import org.hibernate.query.criteria.internal.compile.CriteriaCompiler;
|
||||
import org.hibernate.query.criteria.internal.expression.CompoundSelectionImpl;
|
||||
import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
|
||||
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.jpa.internal.QueryImpl;
|
||||
import org.hibernate.jpa.internal.StoredProcedureQueryImpl;
|
||||
import org.hibernate.jpa.internal.TransactionImpl;
|
||||
import org.hibernate.engine.transaction.internal.TransactionImpl;
|
||||
import org.hibernate.jpa.internal.util.CacheModeHelper;
|
||||
import org.hibernate.jpa.internal.util.ConfigurationHelper;
|
||||
import org.hibernate.jpa.internal.util.LockModeTypeHelper;
|
||||
|
@ -107,7 +107,7 @@ import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
|
|||
import org.hibernate.transform.BasicTransformerAdapter;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import static org.hibernate.jpa.internal.HEMLogging.messageLogger;
|
||||
import static org.hibernate.internal.HEMLogging.messageLogger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gavin@hibernate.org">Gavin King</a>
|
|
@ -31,7 +31,7 @@ import org.hibernate.jpa.AvailableSettings;
|
|||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.jpa.TypedParameterValue;
|
||||
import org.hibernate.jpa.graph.internal.EntityGraphImpl;
|
||||
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.jpa.internal.util.CacheModeHelper;
|
||||
import org.hibernate.jpa.internal.util.ConfigurationHelper;
|
||||
import org.hibernate.jpa.internal.util.LockModeTypeHelper;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue