HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (first sucessful full compile of consolidated hibernate-core)
This commit is contained in:
parent
774b805ce1
commit
87e3f0fd28
|
@ -61,7 +61,7 @@ The previous tutorials used the Hibernate native APIs. This tutorial uses the J
|
|||
[source, JAVA]
|
||||
----
|
||||
protected void setUp() throws Exception {
|
||||
entityManagerFactory = Persistence.createEntityManagerFactory( "org.hibernate.tutorial.jpa" );
|
||||
sessionFactory = Persistence.createEntityManagerFactory( "org.hibernate.tutorial.jpa" );
|
||||
}
|
||||
----
|
||||
====
|
||||
|
@ -74,7 +74,7 @@ Notice again that the persistence unit name is `org.hibernate.tutorial.jpa`, whi
|
|||
====
|
||||
[source, JAVA]
|
||||
----
|
||||
EntityManager entityManager = entityManagerFactory.createEntityManager();
|
||||
EntityManager entityManager = sessionFactory.createEntityManager();
|
||||
entityManager.getTransaction().begin();
|
||||
entityManager.persist( new Event( "Our very first event!", new Date() ) );
|
||||
entityManager.persist( new Event( "A follow up event", new Date() ) );
|
||||
|
@ -92,7 +92,7 @@ is used instead of the `org.hibernate.Session` interface. JPA calls this operat
|
|||
====
|
||||
[source, JAVA]
|
||||
----
|
||||
entityManager = entityManagerFactory.createEntityManager();
|
||||
entityManager = sessionFactory.createEntityManager();
|
||||
entityManager.getTransaction().begin();
|
||||
List<Event> result = entityManager.createQuery( "from Event", Event.class ).getResultList();
|
||||
for ( Event event : result ) {
|
||||
|
|
|
@ -916,7 +916,7 @@
|
|||
<listitem>
|
||||
<para>
|
||||
<literal>hibernate.query.plan_parameter_metadata_max_size</literal> - Controls the maximum number of
|
||||
<interfacename>org.hibernate.engine.query.spi.ParameterMetadata</interfacename> instances Hibernate
|
||||
<interfacename>org.hibernate.query.internal.ParameterMetadata</interfacename> instances Hibernate
|
||||
will maintain in its QueryPlanCache. The default is 128.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.c3p0.internal;
|
|||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.log.ConnectionPoolingLogger;
|
||||
|
||||
import org.jboss.logging.annotations.Cause;
|
||||
|
@ -23,7 +22,7 @@ import static org.jboss.logging.Logger.Level.WARN;
|
|||
* The jboss-logging {@link MessageLogger} for the hibernate-c3p0 module. It reserves message ids ranging from
|
||||
* 10001 to 15000 inclusively.
|
||||
* <p/>
|
||||
* New messages must be added after the last message defined to ensure message codes are unique.
|
||||
* New messages must be added afterQuery the last message defined to ensure message codes are unique.
|
||||
*/
|
||||
@MessageLogger(projectCode = "HHH")
|
||||
public interface C3P0MessageLogger extends ConnectionPoolingLogger {
|
||||
|
|
|
@ -30,6 +30,7 @@ dependencies {
|
|||
provided( libraries.jacc )
|
||||
provided( libraries.validation )
|
||||
provided( libraries.ant )
|
||||
provided( "javax.enterprise:cdi-api:1.1-PFD" )
|
||||
|
||||
testCompile( project(':hibernate-testing') )
|
||||
testCompile( libraries.validation )
|
||||
|
|
|
@ -12,18 +12,38 @@ import org.hibernate.type.Type;
|
|||
* Defines the aspects of query definition that apply to all forms of querying.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated (since 5.2) use {@link org.hibernate.query.BasicQueryContract} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface BasicQueryContract {
|
||||
/**
|
||||
* (Re)set the current FlushMode in effect for this query.
|
||||
*
|
||||
* @param flushMode The new FlushMode to use.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @see #getHibernateFlushMode()
|
||||
*
|
||||
* @deprecated (since 5.2) use {@link #setHibernateFlushMode} instead
|
||||
*/
|
||||
@Deprecated
|
||||
default org.hibernate.query.BasicQueryContract setFlushMode(FlushMode flushMode) {
|
||||
setHibernateFlushMode( flushMode );
|
||||
return (org.hibernate.query.BasicQueryContract) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the FlushMode in effect for this query. By default, the query inherits the FlushMode of the Session
|
||||
* from which is originates.
|
||||
* from which it originates.
|
||||
*
|
||||
* @return The query FlushMode.
|
||||
*
|
||||
* @see Session#getFlushMode()
|
||||
* @see FlushMode
|
||||
*/
|
||||
public FlushMode getFlushMode();
|
||||
FlushMode getHibernateFlushMode();
|
||||
|
||||
/**
|
||||
* (Re)set the current FlushMode in effect for this query.
|
||||
|
@ -32,9 +52,9 @@ public interface BasicQueryContract {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @see #getFlushMode()
|
||||
* @see #getHibernateFlushMode()
|
||||
*/
|
||||
public BasicQueryContract setFlushMode(FlushMode flushMode);
|
||||
org.hibernate.query.BasicQueryContract setHibernateFlushMode(FlushMode flushMode);
|
||||
|
||||
/**
|
||||
* Obtain the CacheMode in effect for this query. By default, the query inherits the CacheMode of the Session
|
||||
|
@ -48,7 +68,7 @@ public interface BasicQueryContract {
|
|||
* @see Session#getCacheMode()
|
||||
* @see CacheMode
|
||||
*/
|
||||
public CacheMode getCacheMode();
|
||||
CacheMode getCacheMode();
|
||||
|
||||
/**
|
||||
* (Re)set the current CacheMode in effect for this query.
|
||||
|
@ -59,7 +79,7 @@ public interface BasicQueryContract {
|
|||
*
|
||||
* @see #getCacheMode()
|
||||
*/
|
||||
public BasicQueryContract setCacheMode(CacheMode cacheMode);
|
||||
org.hibernate.query.BasicQueryContract setCacheMode(CacheMode cacheMode);
|
||||
|
||||
/**
|
||||
* Are the results of this query eligible for second level query caching? This is different that second level
|
||||
|
@ -73,7 +93,7 @@ public interface BasicQueryContract {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_QUERY_CACHE
|
||||
*/
|
||||
public boolean isCacheable();
|
||||
boolean isCacheable();
|
||||
|
||||
/**
|
||||
* Enable/disable second level query (result) caching for this query.
|
||||
|
@ -84,7 +104,7 @@ public interface BasicQueryContract {
|
|||
*
|
||||
* @see #isCacheable
|
||||
*/
|
||||
public BasicQueryContract setCacheable(boolean cacheable);
|
||||
org.hibernate.query.BasicQueryContract setCacheable(boolean cacheable);
|
||||
|
||||
/**
|
||||
* Obtain the name of the second level query cache region in which query results will be stored (if they are
|
||||
|
@ -94,7 +114,7 @@ public interface BasicQueryContract {
|
|||
* @return The specified cache region name into which query results should be placed; {@code null} indicates
|
||||
* the default region.
|
||||
*/
|
||||
public String getCacheRegion();
|
||||
String getCacheRegion();
|
||||
|
||||
/**
|
||||
* Set the name of the cache region where query results should be cached (if cached at all).
|
||||
|
@ -106,7 +126,7 @@ public interface BasicQueryContract {
|
|||
*
|
||||
* @see #getCacheRegion()
|
||||
*/
|
||||
public BasicQueryContract setCacheRegion(String cacheRegion);
|
||||
org.hibernate.query.BasicQueryContract setCacheRegion(String cacheRegion);
|
||||
|
||||
/**
|
||||
* Obtain the query timeout <b>in seconds</b>. This value is eventually passed along to the JDBC query via
|
||||
|
@ -117,7 +137,7 @@ public interface BasicQueryContract {
|
|||
* @see java.sql.Statement#getQueryTimeout()
|
||||
* @see java.sql.Statement#setQueryTimeout(int)
|
||||
*/
|
||||
public Integer getTimeout();
|
||||
Integer getTimeout();
|
||||
|
||||
/**
|
||||
* Set the query timeout <b>in seconds</b>.
|
||||
|
@ -131,7 +151,7 @@ public interface BasicQueryContract {
|
|||
*
|
||||
* @see #getTimeout()
|
||||
*/
|
||||
public BasicQueryContract setTimeout(int timeout);
|
||||
org.hibernate.query.BasicQueryContract setTimeout(int timeout);
|
||||
|
||||
/**
|
||||
* Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC
|
||||
|
@ -146,7 +166,7 @@ public interface BasicQueryContract {
|
|||
* @see java.sql.Statement#getFetchSize()
|
||||
* @see java.sql.Statement#setFetchSize(int)
|
||||
*/
|
||||
public Integer getFetchSize();
|
||||
Integer getFetchSize();
|
||||
|
||||
/**
|
||||
* Sets a JDBC fetch size hint for the query.
|
||||
|
@ -157,22 +177,23 @@ public interface BasicQueryContract {
|
|||
*
|
||||
* @see #getFetchSize()
|
||||
*/
|
||||
public BasicQueryContract setFetchSize(int fetchSize);
|
||||
org.hibernate.query.BasicQueryContract setFetchSize(int fetchSize);
|
||||
|
||||
/**
|
||||
* Should entities and proxies loaded by this Query be put in read-only mode? If the
|
||||
* read-only/modifiable setting was not initialized, then the default
|
||||
* read-only/modifiable setting for the persistence context is returned instead.
|
||||
* @see Query#setReadOnly(boolean)
|
||||
*
|
||||
* @see #setReadOnly(boolean)
|
||||
* @see org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly()
|
||||
*
|
||||
* The read-only/modifiable setting has no impact on entities/proxies returned by the
|
||||
* query that existed in the session before the query was executed.
|
||||
* query that existed in the session beforeQuery the query was executed.
|
||||
*
|
||||
* @return true, entities and proxies loaded by the query will be put in read-only mode
|
||||
* false, entities and proxies loaded by the query will be put in modifiable mode
|
||||
* @return {@code true} if the entities and proxies loaded by the query will be put
|
||||
* in read-only mode; {@code false} otherwise (they will be modifiable)
|
||||
*/
|
||||
public boolean isReadOnly();
|
||||
boolean isReadOnly();
|
||||
|
||||
/**
|
||||
* Set the read-only/modifiable mode for entities and proxies
|
||||
|
@ -183,7 +204,7 @@ public interface BasicQueryContract {
|
|||
* To set the default read-only/modifiable setting used for
|
||||
* entities and proxies that are loaded into the session:
|
||||
* @see org.hibernate.engine.spi.PersistenceContext#setDefaultReadOnly(boolean)
|
||||
* @see org.hibernate.Session#setDefaultReadOnly(boolean)
|
||||
* @see Session#setDefaultReadOnly(boolean)
|
||||
*
|
||||
* Read-only entities are not dirty-checked and snapshots of persistent
|
||||
* state are not maintained. Read-only entities can be modified, but
|
||||
|
@ -194,19 +215,23 @@ public interface BasicQueryContract {
|
|||
* proxy has, regardless of the session's current setting.
|
||||
*
|
||||
* The read-only/modifiable setting has no impact on entities/proxies
|
||||
* returned by the query that existed in the session before the query was executed.
|
||||
* returned by the query that existed in the session beforeQuery the query was executed.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @param readOnly true, entities and proxies loaded by the query will be put in read-only mode
|
||||
* false, entities and proxies loaded by the query will be put in modifiable mode
|
||||
* @param readOnly {@code true} indicates that entities and proxies loaded by the query
|
||||
* are to be put in read-only mode; {@code false} indicates that entities and proxies
|
||||
* loaded by the query will be put in modifiable mode
|
||||
*/
|
||||
public BasicQueryContract setReadOnly(boolean readOnly);
|
||||
org.hibernate.query.BasicQueryContract setReadOnly(boolean readOnly);
|
||||
|
||||
/**
|
||||
* Return the Hibernate types of the query results.
|
||||
*
|
||||
* @return an array of types
|
||||
*
|
||||
* @deprecated (since 5.2) with no replacement; to be removed in 6.0
|
||||
*/
|
||||
public Type[] getReturnTypes();
|
||||
@Deprecated
|
||||
Type[] getReturnTypes();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +18,14 @@ import java.io.Serializable;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Cache {
|
||||
public interface Cache extends javax.persistence.Cache {
|
||||
/**
|
||||
* Access to the SessionFactory this Cache is bound to.
|
||||
*
|
||||
* @return The SessionFactory
|
||||
*/
|
||||
SessionFactory getSessionFactory();
|
||||
|
||||
/**
|
||||
* Determine whether the cache contains data for the given entity "instance".
|
||||
* <p/>
|
||||
|
@ -30,7 +38,7 @@ public interface Cache {
|
|||
* @return True if the underlying cache contains corresponding data; false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean containsEntity(Class entityClass, Serializable identifier);
|
||||
boolean containsEntity(Class entityClass, Serializable identifier);
|
||||
|
||||
/**
|
||||
* Determine whether the cache contains data for the given entity "instance".
|
||||
|
@ -43,7 +51,7 @@ public interface Cache {
|
|||
*
|
||||
* @return True if the underlying cache contains corresponding data; false otherwise.
|
||||
*/
|
||||
public boolean containsEntity(String entityName, Serializable identifier);
|
||||
boolean containsEntity(String entityName, Serializable identifier);
|
||||
|
||||
/**
|
||||
* Evicts the entity data for a particular entity "instance".
|
||||
|
@ -51,7 +59,7 @@ public interface Cache {
|
|||
* @param entityClass The entity class.
|
||||
* @param identifier The entity identifier
|
||||
*/
|
||||
public void evictEntity(Class entityClass, Serializable identifier);
|
||||
void evictEntity(Class entityClass, Serializable identifier);
|
||||
|
||||
/**
|
||||
* Evicts the entity data for a particular entity "instance".
|
||||
|
@ -59,7 +67,7 @@ public interface Cache {
|
|||
* @param entityName The entity name.
|
||||
* @param identifier The entity identifier
|
||||
*/
|
||||
public void evictEntity(String entityName, Serializable identifier);
|
||||
void evictEntity(String entityName, Serializable identifier);
|
||||
|
||||
/**
|
||||
* Evicts all entity data from the given region (i.e. for all entities of
|
||||
|
@ -67,7 +75,7 @@ public interface Cache {
|
|||
*
|
||||
* @param entityClass The entity class.
|
||||
*/
|
||||
public void evictEntityRegion(Class entityClass);
|
||||
void evictEntityRegion(Class entityClass);
|
||||
|
||||
/**
|
||||
* Evicts all entity data from the given region (i.e. for all entities of
|
||||
|
@ -75,12 +83,12 @@ public interface Cache {
|
|||
*
|
||||
* @param entityName The entity name.
|
||||
*/
|
||||
public void evictEntityRegion(String entityName);
|
||||
void evictEntityRegion(String entityName);
|
||||
|
||||
/**
|
||||
* Evict data from all entity regions.
|
||||
*/
|
||||
public void evictEntityRegions();
|
||||
void evictEntityRegions();
|
||||
|
||||
/**
|
||||
* Evicts all naturalId data from the given region (i.e. for all entities of
|
||||
|
@ -89,7 +97,7 @@ public interface Cache {
|
|||
* @param naturalIdClass The naturalId class.
|
||||
*/
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public void evictNaturalIdRegion(Class naturalIdClass);
|
||||
void evictNaturalIdRegion(Class naturalIdClass);
|
||||
|
||||
/**
|
||||
* Evicts all naturalId data from the given region (i.e. for all entities of
|
||||
|
@ -97,12 +105,12 @@ public interface Cache {
|
|||
*
|
||||
* @param naturalIdName The naturalId name.
|
||||
*/
|
||||
public void evictNaturalIdRegion(String naturalIdName);
|
||||
void evictNaturalIdRegion(String naturalIdName);
|
||||
|
||||
/**
|
||||
* Evict data from all naturalId regions.
|
||||
*/
|
||||
public void evictNaturalIdRegions();
|
||||
void evictNaturalIdRegions();
|
||||
|
||||
/**
|
||||
* Determine whether the cache contains data for the given collection.
|
||||
|
@ -118,7 +126,7 @@ public interface Cache {
|
|||
* @return True if the underlying cache contains corresponding data; false otherwise.
|
||||
*/
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public boolean containsCollection(String role, Serializable ownerIdentifier);
|
||||
boolean containsCollection(String role, Serializable ownerIdentifier);
|
||||
|
||||
/**
|
||||
* Evicts the cache data for the given identified collection instance.
|
||||
|
@ -126,7 +134,7 @@ public interface Cache {
|
|||
* @param role The "collection role" (in form [owner-entity-name].[collection-property-name]).
|
||||
* @param ownerIdentifier The identifier of the owning entity
|
||||
*/
|
||||
public void evictCollection(String role, Serializable ownerIdentifier);
|
||||
void evictCollection(String role, Serializable ownerIdentifier);
|
||||
|
||||
/**
|
||||
* Evicts all entity data from the given region (i.e. evicts cached data
|
||||
|
@ -134,12 +142,12 @@ public interface Cache {
|
|||
*
|
||||
* @param role The "collection role" (in form [owner-entity-name].[collection-property-name]).
|
||||
*/
|
||||
public void evictCollectionRegion(String role);
|
||||
void evictCollectionRegion(String role);
|
||||
|
||||
/**
|
||||
* Evict data from all collection regions.
|
||||
*/
|
||||
public void evictCollectionRegions();
|
||||
void evictCollectionRegions();
|
||||
|
||||
/**
|
||||
* Determine whether the cache contains data for the given query.
|
||||
|
@ -152,27 +160,27 @@ public interface Cache {
|
|||
* @return True if the underlying cache contains corresponding data; false otherwise.
|
||||
*/
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public boolean containsQuery(String regionName);
|
||||
boolean containsQuery(String regionName);
|
||||
|
||||
/**
|
||||
* Evicts all cached query results from the default region.
|
||||
*/
|
||||
public void evictDefaultQueryRegion();
|
||||
void evictDefaultQueryRegion();
|
||||
|
||||
/**
|
||||
* Evicts all cached query results under the given name.
|
||||
*
|
||||
* @param regionName The cache name associated to the queries being cached.
|
||||
*/
|
||||
public void evictQueryRegion(String regionName);
|
||||
void evictQueryRegion(String regionName);
|
||||
|
||||
/**
|
||||
* Evict data from all query regions.
|
||||
*/
|
||||
public void evictQueryRegions();
|
||||
void evictQueryRegions();
|
||||
|
||||
/**
|
||||
* Evict all data from the cache.
|
||||
*/
|
||||
public void evictAllRegions();
|
||||
void evictAllRegions();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate;
|
|||
/**
|
||||
* Intended to be thrown from {@link org.hibernate.classic.Lifecycle} and {@link Interceptor} callbacks.
|
||||
* <p/>
|
||||
* IMPL NOTE : This is a legacy exception type from back in the day before Hibernate moved to a untyped (runtime)
|
||||
* IMPL NOTE : This is a legacy exception type from back in the day beforeQuery Hibernate moved to a untyped (runtime)
|
||||
* exception strategy.
|
||||
*
|
||||
* @author Gavin King
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.Locale;
|
|||
*/
|
||||
public enum ConnectionReleaseMode{
|
||||
/**
|
||||
* Indicates that JDBC connection should be aggressively released after each
|
||||
* Indicates that JDBC connection should be aggressively released afterQuery each
|
||||
* SQL statement is executed. In this mode, the application <em>must</em>
|
||||
* explicitly close all iterators and scrollable results. This mode may
|
||||
* only be used with a JTA datasource.
|
||||
|
@ -24,7 +24,7 @@ public enum ConnectionReleaseMode{
|
|||
AFTER_STATEMENT,
|
||||
|
||||
/**
|
||||
* Indicates that JDBC connections should be released after each transaction
|
||||
* Indicates that JDBC connections should be released afterQuery each transaction
|
||||
* ends (works with both JTA-registered synch and HibernateTransaction API).
|
||||
* This mode may not be used with an application server JTA datasource.
|
||||
* <p/>
|
||||
|
|
|
@ -403,7 +403,7 @@ public interface Criteria extends CriteriaSpecification {
|
|||
* @see org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly()
|
||||
*
|
||||
* The read-only/modifiable setting has no impact on entities/proxies returned by the
|
||||
* Criteria that existed in the session before the Criteria was executed.
|
||||
* Criteria that existed in the session beforeQuery the Criteria was executed.
|
||||
*
|
||||
* @return true, entities and proxies loaded by the criteria will be put in read-only mode
|
||||
* false, entities and proxies loaded by the criteria will be put in modifiable mode
|
||||
|
@ -433,7 +433,7 @@ public interface Criteria extends CriteriaSpecification {
|
|||
* proxy has, regardless of the session's current setting.
|
||||
*
|
||||
* The read-only/modifiable setting has no impact on entities/proxies
|
||||
* returned by the criteria that existed in the session before the criteria was executed.
|
||||
* returned by the criteria that existed in the session beforeQuery the criteria was executed.
|
||||
*
|
||||
* @param readOnly true, entities and proxies loaded by the criteria will be put in read-only mode
|
||||
* false, entities and proxies loaded by the criteria will be put in modifiable mode
|
||||
|
|
|
@ -47,7 +47,7 @@ public interface CustomEntityDirtinessStrategy {
|
|||
|
||||
/**
|
||||
* Callback used by Hibernate to signal that the entity dirty flag should be cleared. Generally this
|
||||
* happens after previous dirty changes were written to the database.
|
||||
* happens afterQuery previous dirty changes were written to the database.
|
||||
*
|
||||
* @param entity The entity to reset
|
||||
* @param persister The persister corresponding to the given entity
|
||||
|
|
|
@ -64,7 +64,7 @@ public interface Filter {
|
|||
|
||||
/**
|
||||
* Perform validation of the filter state. This is used to verify the
|
||||
* state of the filter after its enablement and before its use.
|
||||
* state of the filter afterQuery its enablement and beforeQuery its use.
|
||||
*
|
||||
* @throws HibernateException If the state is not currently valid.
|
||||
*/
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.hibernate.jpa.internal.util.FlushModeTypeHelper;
|
||||
|
||||
/**
|
||||
* Represents a flushing strategy. The flush process synchronizes
|
||||
|
@ -20,16 +20,6 @@ import java.util.Locale;
|
|||
* @author Gavin King
|
||||
*/
|
||||
public enum FlushMode {
|
||||
/**
|
||||
* The {@link Session} is never flushed unless {@link Session#flush}
|
||||
* is explicitly called by the application. This mode is very
|
||||
* efficient for read only transactions.
|
||||
*
|
||||
* @deprecated use {@link #MANUAL} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
NEVER ( 0 ),
|
||||
|
||||
/**
|
||||
* The {@link Session} is only ever flushed when {@link Session#flush}
|
||||
* is explicitly called by the application. This mode is very
|
||||
|
@ -44,14 +34,14 @@ public enum FlushMode {
|
|||
COMMIT(5 ),
|
||||
|
||||
/**
|
||||
* The {@link Session} is sometimes flushed before query execution
|
||||
* The {@link Session} is sometimes flushed beforeQuery query execution
|
||||
* in order to ensure that queries never return stale state. This
|
||||
* is the default flush mode.
|
||||
*/
|
||||
AUTO(10 ),
|
||||
|
||||
/**
|
||||
* The {@link Session} is flushed before every query. This is
|
||||
* The {@link Session} is flushed beforeQuery every query. This is
|
||||
* almost always unnecessary and inefficient.
|
||||
*/
|
||||
ALWAYS(20 );
|
||||
|
@ -80,7 +70,7 @@ public enum FlushMode {
|
|||
*
|
||||
* @return true/false
|
||||
*
|
||||
* @deprecated Just use equality check against {@link #MANUAL}. Legacy from before this was an enum
|
||||
* @deprecated Just use equality check against {@link #MANUAL}. Legacy from beforeQuery this was an enum
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isManualFlushMode(FlushMode mode) {
|
||||
|
@ -99,15 +89,6 @@ public enum FlushMode {
|
|||
* @throws MappingException Indicates an unrecognized external representation
|
||||
*/
|
||||
public static FlushMode interpretExternalSetting(String externalName) {
|
||||
if ( externalName == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return FlushMode.valueOf( externalName.toUpperCase(Locale.ROOT) );
|
||||
}
|
||||
catch ( IllegalArgumentException e ) {
|
||||
throw new MappingException( "unknown FlushMode : " + externalName );
|
||||
}
|
||||
return FlushModeTypeHelper.interpretExternalSetting( externalName );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
|
|||
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.proxy.LazyInitializer;
|
||||
|
||||
|
@ -113,6 +114,20 @@ public final class Hibernate {
|
|||
return getLobCreator( (SessionImplementor) session );
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a lob creator for the given session.
|
||||
*
|
||||
* @param session The session for which to obtain a lob creator
|
||||
*
|
||||
* @return The log creator reference
|
||||
*/
|
||||
public static LobCreator getLobCreator(SharedSessionContractImplementor session) {
|
||||
return session.getFactory()
|
||||
.getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getLobCreator( session );
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a lob creator for the given session.
|
||||
*
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.type.Type;
|
|||
/**
|
||||
* Allows user code to inspect and/or change property values.
|
||||
*
|
||||
* Inspection occurs before property values are written and after they are read
|
||||
* Inspection occurs beforeQuery property values are written and afterQuery they are read
|
||||
* from the database.
|
||||
*
|
||||
* There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance
|
||||
|
@ -37,7 +37,7 @@ import org.hibernate.type.Type;
|
|||
*/
|
||||
public interface Interceptor {
|
||||
/**
|
||||
* Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will
|
||||
* Called just beforeQuery an object is initialized. The interceptor may change the <tt>state</tt>, which will
|
||||
* be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be
|
||||
* an empty uninitialized instance of the class.
|
||||
* <p/>
|
||||
|
@ -85,7 +85,7 @@ public interface Interceptor {
|
|||
Type[] types) throws CallbackException;
|
||||
|
||||
/**
|
||||
* Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for
|
||||
* Called beforeQuery an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for
|
||||
* the SQL <tt>INSERT</tt> and propagated to the persistent object.
|
||||
*
|
||||
* @param entity The entity instance whose state is being inserted
|
||||
|
@ -101,7 +101,7 @@ public interface Interceptor {
|
|||
boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
|
||||
|
||||
/**
|
||||
* Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>.
|
||||
* Called beforeQuery an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>.
|
||||
*
|
||||
* @param entity The entity instance being deleted
|
||||
* @param id The identifier of the entity
|
||||
|
@ -114,7 +114,7 @@ public interface Interceptor {
|
|||
void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
|
||||
|
||||
/**
|
||||
* Called before a collection is (re)created.
|
||||
* Called beforeQuery a collection is (re)created.
|
||||
*
|
||||
* @param collection The collection instance.
|
||||
* @param key The collection key value.
|
||||
|
@ -124,7 +124,7 @@ public interface Interceptor {
|
|||
void onCollectionRecreate(Object collection, Serializable key) throws CallbackException;
|
||||
|
||||
/**
|
||||
* Called before a collection is deleted.
|
||||
* Called beforeQuery a collection is deleted.
|
||||
*
|
||||
* @param collection The collection instance.
|
||||
* @param key The collection key value.
|
||||
|
@ -134,7 +134,7 @@ public interface Interceptor {
|
|||
void onCollectionRemove(Object collection, Serializable key) throws CallbackException;
|
||||
|
||||
/**
|
||||
* Called before a collection is updated.
|
||||
* Called beforeQuery a collection is updated.
|
||||
*
|
||||
* @param collection The collection instance.
|
||||
* @param key The collection key value.
|
||||
|
@ -144,7 +144,7 @@ public interface Interceptor {
|
|||
void onCollectionUpdate(Object collection, Serializable key) throws CallbackException;
|
||||
|
||||
/**
|
||||
* Called before a flush.
|
||||
* Called beforeQuery a flush.
|
||||
*
|
||||
* @param entities The entities to be flushed.
|
||||
*
|
||||
|
@ -153,7 +153,7 @@ public interface Interceptor {
|
|||
void preFlush(Iterator entities) throws CallbackException;
|
||||
|
||||
/**
|
||||
* Called after a flush that actually ends in execution of the SQL statements required to synchronize
|
||||
* Called afterQuery a flush that actually ends in execution of the SQL statements required to synchronize
|
||||
* in-memory state with the database.
|
||||
*
|
||||
* @param entities The entities that were flushed.
|
||||
|
@ -250,14 +250,14 @@ public interface Interceptor {
|
|||
void afterTransactionBegin(Transaction tx);
|
||||
|
||||
/**
|
||||
* Called before a transaction is committed (but not before rollback).
|
||||
* Called beforeQuery a transaction is committed (but not beforeQuery rollback).
|
||||
*
|
||||
* @param tx The Hibernate transaction facade object
|
||||
*/
|
||||
void beforeTransactionCompletion(Transaction tx);
|
||||
|
||||
/**
|
||||
* Called after a transaction is committed or rolled back.
|
||||
* Called afterQuery a transaction is committed or rolled back.
|
||||
*
|
||||
* @param tx The Hibernate transaction facade object
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.jboss.logging.Logger;
|
|||
/**
|
||||
* Indicates an attempt to access not-yet-fetched data outside of a session context.
|
||||
*
|
||||
* For example, when an uninitialized proxy or collection is accessed after the session was closed.
|
||||
* For example, when an uninitialized proxy or collection is accessed afterQuery the session was closed.
|
||||
*
|
||||
* @see Hibernate#initialize(java.lang.Object)
|
||||
* @see Hibernate#isInitialized(java.lang.Object)
|
||||
|
|
|
@ -7,11 +7,37 @@
|
|||
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);
|
||||
/**
|
||||
* Access to the SessionFactory that this Metamodel instance is bound to.
|
||||
*
|
||||
* @return The SessionFactory
|
||||
*/
|
||||
SessionFactory getSessionFactory();
|
||||
|
||||
@Deprecated
|
||||
default EntityType getEntityTypeByName(String entityName) {
|
||||
return entity( entityName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to an entity supporting Hibernate's entity-name feature
|
||||
*
|
||||
* @param entityName The entity-name
|
||||
*
|
||||
* @return The entity descriptor
|
||||
*/
|
||||
<X> EntityType<X> entity(String entityName);
|
||||
|
||||
String getImportedClassName(String className);
|
||||
|
||||
/**
|
||||
* Get the names of all persistent classes that implement/extend the given interface/class
|
||||
*/
|
||||
String[] getImplementors(String entityName);
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,9 +5,19 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.persistence.FlushModeType;
|
||||
import javax.persistence.Parameter;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
import org.hibernate.query.QueryParameter;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
@ -42,17 +52,11 @@ import org.hibernate.type.Type;
|
|||
*
|
||||
* @author Gavin King
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated (since 5.2) use {@link NativeQuery} instead.
|
||||
*/
|
||||
public interface SQLQuery extends Query, SynchronizeableQuery {
|
||||
@Override
|
||||
SQLQuery addSynchronizedQuerySpace(String querySpace);
|
||||
|
||||
@Override
|
||||
SQLQuery addSynchronizedEntityName(String entityName) throws MappingException;
|
||||
|
||||
@Override
|
||||
SQLQuery addSynchronizedEntityClass(Class entityClass) throws MappingException;
|
||||
|
||||
@Deprecated
|
||||
public interface SQLQuery extends Query<Object>, SynchronizeableQuery {
|
||||
/**
|
||||
* Use a predefined named result-set mapping. This might be defined by a {@code <result-set/>} element in a
|
||||
* Hibernate <tt>hbm.xml</tt> file or through a {@link javax.persistence.SqlResultSetMapping} annotation.
|
||||
|
@ -61,21 +65,21 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return this, for method chaining
|
||||
*/
|
||||
public SQLQuery setResultSetMapping(String name);
|
||||
NativeQuery setResultSetMapping(String name);
|
||||
|
||||
/**
|
||||
* Is this native-SQL query known to be callable?
|
||||
*
|
||||
* @return {@code true} if the query is known to be callable; {@code false} otherwise.
|
||||
*/
|
||||
public boolean isCallable();
|
||||
boolean isCallable();
|
||||
|
||||
/**
|
||||
* Retrieve the returns associated with this query.
|
||||
*
|
||||
* @return The return descriptors
|
||||
*/
|
||||
public List<NativeSQLQueryReturn> getQueryReturns();
|
||||
List<NativeSQLQueryReturn> getQueryReturns();
|
||||
|
||||
/**
|
||||
* Declare a scalar query result. Hibernate will attempt to automatically detect the underlying type.
|
||||
|
@ -86,7 +90,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addScalar(String columnAlias);
|
||||
NativeQuery addScalar(String columnAlias);
|
||||
|
||||
/**
|
||||
* Declare a scalar query result.
|
||||
|
@ -98,10 +102,10 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addScalar(String columnAlias, Type type);
|
||||
NativeQuery addScalar(String columnAlias, Type type);
|
||||
|
||||
/**
|
||||
* Add a new root return mapping, returning a {@link RootReturn} to allow further definition.
|
||||
* Add a new root return mapping, returning a {@link NativeQuery.RootReturn} to allow further definition.
|
||||
*
|
||||
* @param tableAlias The SQL table alias to map to this entity
|
||||
* @param entityName The name of the entity.
|
||||
|
@ -110,10 +114,10 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
public RootReturn addRoot(String tableAlias, String entityName);
|
||||
RootReturn addRoot(String tableAlias, String entityName);
|
||||
|
||||
/**
|
||||
* Add a new root return mapping, returning a {@link RootReturn} to allow further definition.
|
||||
* Add a new root return mapping, returning a {@link NativeQuery.RootReturn} to allow further definition.
|
||||
*
|
||||
* @param tableAlias The SQL table alias to map to this entity
|
||||
* @param entityType The java type of the entity.
|
||||
|
@ -122,7 +126,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
public RootReturn addRoot(String tableAlias, Class entityType);
|
||||
RootReturn addRoot(String tableAlias, Class entityType);
|
||||
|
||||
/**
|
||||
* Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the
|
||||
|
@ -134,7 +138,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addEntity(String entityName);
|
||||
NativeQuery addEntity(String entityName);
|
||||
|
||||
/**
|
||||
* Declare a "root" entity.
|
||||
|
@ -144,7 +148,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addEntity(String tableAlias, String entityName);
|
||||
NativeQuery addEntity(String tableAlias, String entityName);
|
||||
|
||||
/**
|
||||
* Declare a "root" entity, specifying a lock mode.
|
||||
|
@ -155,7 +159,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addEntity(String tableAlias, String entityName, LockMode lockMode);
|
||||
NativeQuery addEntity(String tableAlias, String entityName, LockMode lockMode);
|
||||
|
||||
/**
|
||||
* Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the
|
||||
|
@ -165,7 +169,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addEntity(Class entityType);
|
||||
NativeQuery addEntity(Class entityType);
|
||||
|
||||
/**
|
||||
* Declare a "root" entity.
|
||||
|
@ -175,18 +179,18 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addEntity(String tableAlias, Class entityType);
|
||||
NativeQuery addEntity(String tableAlias, Class entityType);
|
||||
|
||||
/**
|
||||
* Declare a "root" entity, specifying a lock mode.
|
||||
*
|
||||
* @param tableAlias The SQL table alias
|
||||
* @param entityName The entity name
|
||||
* @param entityClass The entity Class
|
||||
* @param lockMode The lock mode for this return.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addEntity(String tableAlias, Class entityName, LockMode lockMode);
|
||||
NativeQuery addEntity(String tableAlias, Class entityClass, LockMode lockMode);
|
||||
|
||||
/**
|
||||
* Declare a join fetch result.
|
||||
|
@ -200,7 +204,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
public FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
|
||||
/**
|
||||
* Declare a join fetch result.
|
||||
|
@ -210,7 +214,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addJoin(String tableAlias, String path);
|
||||
NativeQuery addJoin(String tableAlias, String path);
|
||||
|
||||
/**
|
||||
* Declare a join fetch result.
|
||||
|
@ -224,7 +228,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
public SQLQuery addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
NativeQuery addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
|
||||
/**
|
||||
* Declare a join fetch result, specifying a lock mode.
|
||||
|
@ -235,13 +239,13 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SQLQuery addJoin(String tableAlias, String path, LockMode lockMode);
|
||||
NativeQuery addJoin(String tableAlias, String path, LockMode lockMode);
|
||||
|
||||
/**
|
||||
* Allows access to further control how properties within a root or join fetch are mapped back from the result set.
|
||||
* Generally used in composite value scenarios.
|
||||
*/
|
||||
public static interface ReturnProperty {
|
||||
interface ReturnProperty {
|
||||
/**
|
||||
* Add a column alias to this property mapping.
|
||||
*
|
||||
|
@ -249,13 +253,13 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public ReturnProperty addColumnAlias(String columnAlias);
|
||||
ReturnProperty addColumnAlias(String columnAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows access to further control how root returns are mapped back from result sets.
|
||||
*/
|
||||
public static interface RootReturn {
|
||||
interface RootReturn {
|
||||
/**
|
||||
* Set the lock mode for this return.
|
||||
*
|
||||
|
@ -263,7 +267,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public RootReturn setLockMode(LockMode lockMode);
|
||||
RootReturn setLockMode(LockMode lockMode);
|
||||
|
||||
/**
|
||||
* Name the column alias that identifies the entity's discriminator.
|
||||
|
@ -272,7 +276,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public RootReturn setDiscriminatorAlias(String columnAlias);
|
||||
RootReturn setDiscriminatorAlias(String columnAlias);
|
||||
|
||||
/**
|
||||
* Add a simple property-to-one-column mapping.
|
||||
|
@ -282,7 +286,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public RootReturn addProperty(String propertyName, String columnAlias);
|
||||
RootReturn addProperty(String propertyName, String columnAlias);
|
||||
|
||||
/**
|
||||
* Add a property, presumably with more than one column.
|
||||
|
@ -291,13 +295,13 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return The config object for further control.
|
||||
*/
|
||||
public ReturnProperty addProperty(String propertyName);
|
||||
ReturnProperty addProperty(String propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows access to further control how join fetch returns are mapped back from result sets.
|
||||
*/
|
||||
public static interface FetchReturn {
|
||||
interface FetchReturn {
|
||||
/**
|
||||
* Set the lock mode for this return.
|
||||
*
|
||||
|
@ -305,7 +309,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public FetchReturn setLockMode(LockMode lockMode);
|
||||
FetchReturn setLockMode(LockMode lockMode);
|
||||
|
||||
/**
|
||||
* Add a simple property-to-one-column mapping.
|
||||
|
@ -315,7 +319,7 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public FetchReturn addProperty(String propertyName, String columnAlias);
|
||||
FetchReturn addProperty(String propertyName, String columnAlias);
|
||||
|
||||
/**
|
||||
* Add a property, presumably with more than one column.
|
||||
|
@ -324,6 +328,129 @@ public interface SQLQuery extends Query, SynchronizeableQuery {
|
|||
*
|
||||
* @return The config object for further control.
|
||||
*/
|
||||
public ReturnProperty addProperty(String propertyName);
|
||||
ReturnProperty addProperty(String propertyName);
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// overrides
|
||||
|
||||
|
||||
@Override
|
||||
NativeQuery setHibernateFlushMode(FlushMode flushMode);
|
||||
|
||||
@Override
|
||||
NativeQuery setFlushMode(FlushModeType flushMode);
|
||||
|
||||
@Override
|
||||
NativeQuery setCacheMode(CacheMode cacheMode);
|
||||
|
||||
@Override
|
||||
NativeQuery setCacheable(boolean cacheable);
|
||||
|
||||
@Override
|
||||
NativeQuery setCacheRegion(String cacheRegion);
|
||||
|
||||
@Override
|
||||
NativeQuery setTimeout(int timeout);
|
||||
|
||||
@Override
|
||||
NativeQuery setFetchSize(int fetchSize);
|
||||
|
||||
@Override
|
||||
NativeQuery setReadOnly(boolean readOnly);
|
||||
|
||||
@Override
|
||||
NativeQuery setLockOptions(LockOptions lockOptions);
|
||||
|
||||
@Override
|
||||
NativeQuery setLockMode(String alias, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQuery setComment(String comment);
|
||||
|
||||
@Override
|
||||
NativeQuery addQueryHint(String hint);
|
||||
|
||||
@Override
|
||||
<T> NativeQuery setParameter(QueryParameter<T> parameter, T val);
|
||||
|
||||
@Override
|
||||
<T> NativeQuery setParameter(Parameter<T> param, T value);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(String name, Object val);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(int position, Object val);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery setParameter(QueryParameter<P> parameter, P val, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(String name, Object val, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(int position, Object val, Type type);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery setParameter(QueryParameter<P> parameter, P val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(String name, Object val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(int position, Object val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery setParameterList(QueryParameter<P> parameter, Collection<P> values);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameterList(String name, Collection values);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameterList(String name, Collection values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameterList(String name, Object[] values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameterList(String name, Object[] values);
|
||||
|
||||
@Override
|
||||
NativeQuery setProperties(Object bean);
|
||||
|
||||
@Override
|
||||
NativeQuery setProperties(Map bean);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(String name, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(String name, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(int position, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery setParameter(int position, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery addSynchronizedQuerySpace(String querySpace);
|
||||
|
||||
@Override
|
||||
NativeQuery addSynchronizedEntityName(String entityName) throws MappingException;
|
||||
|
||||
@Override
|
||||
NativeQuery addSynchronizedEntityClass(Class entityClass) throws MappingException;
|
||||
|
||||
@Override
|
||||
NativeQuery setFlushMode(FlushMode flushMode);
|
||||
|
||||
}
|
||||
|
|
|
@ -68,13 +68,13 @@ public interface ScrollableResults extends java.io.Closeable {
|
|||
public boolean first();
|
||||
|
||||
/**
|
||||
* Go to a location just before first result, This is the location of the cursor on a newly returned
|
||||
* Go to a location just beforeQuery first result, This is the location of the cursor on a newly returned
|
||||
* scrollable result.
|
||||
*/
|
||||
public void beforeFirst();
|
||||
|
||||
/**
|
||||
* Go to a location just after the last result.
|
||||
* Go to a location just afterQuery the last result.
|
||||
*/
|
||||
public void afterLast();
|
||||
|
||||
|
|
|
@ -8,9 +8,15 @@ package org.hibernate;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Connection;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.FlushModeType;
|
||||
import javax.persistence.criteria.CriteriaDelete;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.CriteriaUpdate;
|
||||
|
||||
import org.hibernate.jdbc.ReturningWork;
|
||||
import org.hibernate.jdbc.Work;
|
||||
import org.hibernate.jpa.HibernateEntityManager;
|
||||
import org.hibernate.stat.SessionStatistics;
|
||||
|
||||
/**
|
||||
|
@ -67,12 +73,14 @@ import org.hibernate.stat.SessionStatistics;
|
|||
* <br>
|
||||
* If the <tt>Session</tt> throws an exception, the transaction must be rolled back
|
||||
* and the session discarded. The internal state of the <tt>Session</tt> might not
|
||||
* be consistent with the database after the exception occurs.
|
||||
* be consistent with the database afterQuery the exception occurs.
|
||||
*
|
||||
* @see SessionFactory
|
||||
*
|
||||
* @author Gavin King
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Session extends SharedSessionContract, java.io.Closeable {
|
||||
public interface Session extends SharedSessionContract, EntityManager, HibernateEntityManager, java.io.Closeable {
|
||||
/**
|
||||
* Obtain a {@link Session} builder with the ability to grab certain information from this session.
|
||||
*
|
||||
|
@ -82,7 +90,7 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
|
||||
/**
|
||||
* Force this session to flush. Must be called at the end of a
|
||||
* unit of work, before committing the transaction and closing the
|
||||
* unit of work, beforeQuery committing the transaction and closing the
|
||||
* session (depending on {@link #setFlushMode(FlushMode)},
|
||||
* {@link Transaction#commit()} calls this method).
|
||||
* <p/>
|
||||
|
@ -106,16 +114,46 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
* order to achieve some extra performance).
|
||||
*
|
||||
* @param flushMode the new flush mode
|
||||
* @see FlushMode
|
||||
*
|
||||
* @deprecated (since 6.0) use {@link #setHibernateFlushMode(FlushMode)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
void setFlushMode(FlushMode flushMode);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p/>
|
||||
* For users of the Hibernate native APIs, we've had to rename this method
|
||||
* as defined by Hibernate historically because the JPA contract defines a method of the same
|
||||
* name, but returning the JPA {@link FlushModeType} rather than Hibernate's {@link FlushMode}. For
|
||||
* the former behavior, use {@link Session#getHibernateFlushMode()} instead.
|
||||
*
|
||||
* @return The FlushModeType in effect for this Session.
|
||||
*/
|
||||
@Override
|
||||
FlushModeType getFlushMode();
|
||||
|
||||
/**
|
||||
* Set the flush mode for this session.
|
||||
* <p/>
|
||||
* The flush mode determines the points at which the session is flushed.
|
||||
* <i>Flushing</i> is the process of synchronizing the underlying persistent
|
||||
* store with persistable state held in memory.
|
||||
* <p/>
|
||||
* For a logically "read only" session, it is reasonable to set the session's
|
||||
* flush mode to {@link FlushMode#MANUAL} at the start of the session (in
|
||||
* order to achieve some extra performance).
|
||||
*
|
||||
* @param flushMode the new flush mode
|
||||
*/
|
||||
void setHibernateFlushMode(FlushMode flushMode);
|
||||
|
||||
/**
|
||||
* Get the current flush mode for this session.
|
||||
*
|
||||
* @return The flush mode
|
||||
*/
|
||||
FlushMode getFlushMode();
|
||||
FlushMode getHibernateFlushMode();
|
||||
|
||||
/**
|
||||
* Set the cache mode.
|
||||
|
@ -142,15 +180,6 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
*/
|
||||
SessionFactory getSessionFactory();
|
||||
|
||||
/**
|
||||
* End the session by releasing the JDBC connection and cleaning up. It is
|
||||
* not strictly necessary to close the session but you must at least
|
||||
* {@link #disconnect()} it.
|
||||
*
|
||||
* @throws HibernateException Indicates problems cleaning up.
|
||||
*/
|
||||
void close() throws HibernateException;
|
||||
|
||||
/**
|
||||
* Cancel the execution of the current query.
|
||||
* <p/>
|
||||
|
@ -161,20 +190,6 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
*/
|
||||
void cancelQuery() throws HibernateException;
|
||||
|
||||
/**
|
||||
* Check if the session is still open.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isOpen();
|
||||
|
||||
/**
|
||||
* Check if the session is currently connected.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isConnected();
|
||||
|
||||
/**
|
||||
* Does this session contain any changes which must be synchronized with
|
||||
* the database? In other words, would any DML operations be executed if
|
||||
|
@ -583,8 +598,8 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
* For example
|
||||
* <ul>
|
||||
* <li>where a database trigger alters the object state upon insert or update
|
||||
* <li>after executing direct SQL (eg. a mass update) in the same session
|
||||
* <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt>
|
||||
* <li>afterQuery executing direct SQL (eg. a mass update) in the same session
|
||||
* <li>afterQuery inserting a <tt>Blob</tt> or <tt>Clob</tt>
|
||||
* </ul>
|
||||
*
|
||||
* @param object a persistent or detached instance
|
||||
|
@ -598,8 +613,8 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
* For example
|
||||
* <ul>
|
||||
* <li>where a database trigger alters the object state upon insert or update
|
||||
* <li>after executing direct SQL (eg. a mass update) in the same session
|
||||
* <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt>
|
||||
* <li>afterQuery executing direct SQL (eg. a mass update) in the same session
|
||||
* <li>afterQuery inserting a <tt>Blob</tt> or <tt>Clob</tt>
|
||||
* </ul>
|
||||
*
|
||||
* @param entityName a persistent class
|
||||
|
@ -664,7 +679,7 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
*
|
||||
* @return The query instance for manipulation and execution
|
||||
*/
|
||||
Query createFilter(Object collection, String queryString);
|
||||
org.hibernate.query.Query createFilter(Object collection, String queryString);
|
||||
|
||||
/**
|
||||
* Completely clear the session. Evict all loaded instances and cancel all pending
|
||||
|
@ -1119,4 +1134,21 @@ public interface Session extends SharedSessionContract, java.io.Closeable {
|
|||
* @param listeners The listener(s) to add
|
||||
*/
|
||||
void addEventListeners(SessionEventListener... listeners);
|
||||
|
||||
@Override
|
||||
org.hibernate.query.Query createQuery(String queryString);
|
||||
|
||||
@Override
|
||||
<T> org.hibernate.query.Query<T> createQuery(String queryString, Class<T> resultType);
|
||||
|
||||
@Override
|
||||
<T> org.hibernate.query.Query<T> createQuery(CriteriaQuery<T> criteriaQuery);
|
||||
|
||||
@Override
|
||||
org.hibernate.query.Query createQuery(CriteriaUpdate updateQuery);
|
||||
|
||||
@Override
|
||||
org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
|
||||
|
||||
<T> org.hibernate.query.Query<T> createNamedQuery(String name, Class<T> resultType);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
package org.hibernate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
|
||||
/**
|
||||
|
@ -15,13 +17,13 @@ import org.hibernate.resource.jdbc.spi.StatementInspector;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SessionBuilder {
|
||||
public interface SessionBuilder<T extends SessionBuilder> {
|
||||
/**
|
||||
* Opens a session with the specified options.
|
||||
*
|
||||
* @return The session
|
||||
*/
|
||||
public Session openSession();
|
||||
Session openSession();
|
||||
|
||||
/**
|
||||
* Adds a specific interceptor to the session options.
|
||||
|
@ -30,7 +32,7 @@ public interface SessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder interceptor(Interceptor interceptor);
|
||||
T interceptor(Interceptor interceptor);
|
||||
|
||||
/**
|
||||
* Signifies that no {@link Interceptor} should be used.
|
||||
|
@ -43,7 +45,7 @@ public interface SessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder noInterceptor();
|
||||
T noInterceptor();
|
||||
|
||||
/**
|
||||
* Applies a specific StatementInspector to the session options.
|
||||
|
@ -52,7 +54,7 @@ public interface SessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder statementInspector(StatementInspector statementInspector);
|
||||
T statementInspector(StatementInspector statementInspector);
|
||||
|
||||
/**
|
||||
* Adds a specific connection to the session options.
|
||||
|
@ -61,7 +63,7 @@ public interface SessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder connection(Connection connection);
|
||||
T connection(Connection connection);
|
||||
|
||||
/**
|
||||
* Use a specific connection release mode for these session options.
|
||||
|
@ -69,8 +71,20 @@ public interface SessionBuilder {
|
|||
* @param connectionReleaseMode The connection release mode to use.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated (since 6.0) use {@link #connectionHandlingMode} instead
|
||||
*/
|
||||
public SessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode);
|
||||
@Deprecated
|
||||
T connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode);
|
||||
|
||||
/**
|
||||
* Signifies that the connection release mode from the original session should be used to create the new session.
|
||||
*
|
||||
* @param mode The connection handling mode to use.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
T connectionHandlingMode(PhysicalConnectionHandlingMode mode);
|
||||
|
||||
/**
|
||||
* Should the session built automatically join in any ongoing JTA transactions.
|
||||
|
@ -79,10 +93,10 @@ public interface SessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder autoJoinTransactions(boolean autoJoinTransactions);
|
||||
T autoJoinTransactions(boolean autoJoinTransactions);
|
||||
|
||||
/**
|
||||
* Should the session be automatically closed after transaction completion.
|
||||
* Should the session be automatically closed afterQuery transaction completion.
|
||||
*
|
||||
* @param autoClose Should the session be automatically closed
|
||||
*
|
||||
|
@ -92,16 +106,16 @@ public interface SessionBuilder {
|
|||
* {@link org.hibernate.engine.spi.SessionOwner}
|
||||
*/
|
||||
@Deprecated
|
||||
public SessionBuilder autoClose(boolean autoClose);
|
||||
T autoClose(boolean autoClose);
|
||||
|
||||
/**
|
||||
* Should the session be automatically flushed during the "before completion" phase of transaction handling.
|
||||
* Should the session be automatically flushed during the "beforeQuery completion" phase of transaction handling.
|
||||
*
|
||||
* @param flushBeforeCompletion Should the session be automatically flushed
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion);
|
||||
T flushBeforeCompletion(boolean flushBeforeCompletion);
|
||||
|
||||
/**
|
||||
* Define the tenant identifier to be associated with the opened session.
|
||||
|
@ -110,7 +124,7 @@ public interface SessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder tenantIdentifier(String tenantIdentifier);
|
||||
T tenantIdentifier(String tenantIdentifier);
|
||||
|
||||
/**
|
||||
* Apply one or more SessionEventListener instances to the listeners for the Session to be built.
|
||||
|
@ -119,7 +133,7 @@ public interface SessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder eventListeners(SessionEventListener... listeners);
|
||||
T eventListeners(SessionEventListener... listeners);
|
||||
|
||||
/**
|
||||
* Remove all listeners intended for the built Session currently held here, including any auto-apply ones; in other
|
||||
|
@ -127,5 +141,8 @@ public interface SessionBuilder {
|
|||
*
|
||||
* {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder clearEventListeners();
|
||||
T clearEventListeners();
|
||||
|
||||
T persistenceUnitTransactionType(PersistenceUnitTransactionType persistenceUnitTransactionType);
|
||||
|
||||
}
|
||||
|
|
|
@ -11,9 +11,11 @@ import java.sql.Connection;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.naming.Referenceable;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.metadata.ClassMetadata;
|
||||
import org.hibernate.metadata.CollectionMetadata;
|
||||
import org.hibernate.stat.Statistics;
|
||||
|
@ -34,7 +36,7 @@ import org.hibernate.stat.Statistics;
|
|||
* @author Gavin King
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SessionFactory extends Referenceable, Serializable, java.io.Closeable {
|
||||
public interface SessionFactory extends EntityManagerFactory, HibernateEntityManagerFactory, Referenceable, Serializable, java.io.Closeable {
|
||||
/**
|
||||
* Get the special options used to build the factory.
|
||||
*
|
||||
|
@ -101,64 +103,6 @@ public interface SessionFactory extends Referenceable, Serializable, java.io.Clo
|
|||
*/
|
||||
StatelessSession openStatelessSession(Connection connection);
|
||||
|
||||
/**
|
||||
* Retrieve the {@link ClassMetadata} associated with the given entity class.
|
||||
*
|
||||
* @param entityClass The entity class
|
||||
*
|
||||
* @return The metadata associated with the given entity; may be null if no such
|
||||
* entity was mapped.
|
||||
*
|
||||
* @throws HibernateException Generally null is returned instead of throwing.
|
||||
*/
|
||||
ClassMetadata getClassMetadata(Class entityClass);
|
||||
|
||||
/**
|
||||
* Retrieve the {@link ClassMetadata} associated with the given entity class.
|
||||
*
|
||||
* @param entityName The entity class
|
||||
*
|
||||
* @return The metadata associated with the given entity; may be null if no such
|
||||
* entity was mapped.
|
||||
*
|
||||
* @throws HibernateException Generally null is returned instead of throwing.
|
||||
* @since 3.0
|
||||
*/
|
||||
ClassMetadata getClassMetadata(String entityName);
|
||||
|
||||
/**
|
||||
* Get the {@link CollectionMetadata} associated with the named collection role.
|
||||
*
|
||||
* @param roleName The collection role (in form [owning-entity-name].[collection-property-name]).
|
||||
*
|
||||
* @return The metadata associated with the given collection; may be null if no such
|
||||
* collection was mapped.
|
||||
*
|
||||
* @throws HibernateException Generally null is returned instead of throwing.
|
||||
*/
|
||||
CollectionMetadata getCollectionMetadata(String roleName);
|
||||
|
||||
/**
|
||||
* Retrieve the {@link ClassMetadata} for all mapped entities.
|
||||
*
|
||||
* @return A map containing all {@link ClassMetadata} keyed by the
|
||||
* corresponding {@link String} entity-name.
|
||||
*
|
||||
* @throws HibernateException Generally empty map is returned instead of throwing.
|
||||
*
|
||||
* @since 3.0 changed key from {@link Class} to {@link String}.
|
||||
*/
|
||||
Map<String,ClassMetadata> getAllClassMetadata();
|
||||
|
||||
/**
|
||||
* Get the {@link CollectionMetadata} for all mapped collections.
|
||||
*
|
||||
* @return a map from <tt>String</tt> to <tt>CollectionMetadata</tt>
|
||||
*
|
||||
* @throws HibernateException Generally empty map is returned instead of throwing.
|
||||
*/
|
||||
Map getAllCollectionMetadata();
|
||||
|
||||
/**
|
||||
* Retrieve the statistics fopr this factory.
|
||||
*
|
||||
|
@ -171,7 +115,7 @@ public interface SessionFactory extends Referenceable, Serializable, java.io.Clo
|
|||
* connection pools, etc).
|
||||
* <p/>
|
||||
* It is the responsibility of the application to ensure that there are no
|
||||
* open {@link Session sessions} before calling this method as the impact
|
||||
* open {@link Session sessions} beforeQuery calling this method as the impact
|
||||
* on those {@link Session sessions} is indeterminate.
|
||||
* <p/>
|
||||
* No-ops if already {@link #isClosed closed}.
|
||||
|
@ -192,6 +136,7 @@ public interface SessionFactory extends Referenceable, Serializable, java.io.Clo
|
|||
*
|
||||
* @return The direct cache access API.
|
||||
*/
|
||||
@Override
|
||||
Cache getCache();
|
||||
|
||||
/**
|
||||
|
@ -225,4 +170,81 @@ public interface SessionFactory extends Referenceable, Serializable, java.io.Clo
|
|||
* @return The factory's {@link TypeHelper}
|
||||
*/
|
||||
TypeHelper getTypeHelper();
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Deprecations
|
||||
|
||||
/**
|
||||
* Retrieve the {@link ClassMetadata} associated with the given entity class.
|
||||
*
|
||||
* @param entityClass The entity class
|
||||
*
|
||||
* @return The metadata associated with the given entity; may be null if no such
|
||||
* entity was mapped.
|
||||
*
|
||||
* @throws HibernateException Generally null is returned instead of throwing.
|
||||
*
|
||||
* @deprecated Use the descriptors from {@link #getMetamodel()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
ClassMetadata getClassMetadata(Class entityClass);
|
||||
|
||||
/**
|
||||
* Retrieve the {@link ClassMetadata} associated with the given entity class.
|
||||
*
|
||||
* @param entityName The entity class
|
||||
*
|
||||
* @return The metadata associated with the given entity; may be null if no such
|
||||
* entity was mapped.
|
||||
*
|
||||
* @throws HibernateException Generally null is returned instead of throwing.
|
||||
* @since 3.0
|
||||
*
|
||||
* @deprecated Use the descriptors from {@link #getMetamodel()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
ClassMetadata getClassMetadata(String entityName);
|
||||
|
||||
/**
|
||||
* Get the {@link CollectionMetadata} associated with the named collection role.
|
||||
*
|
||||
* @param roleName The collection role (in form [owning-entity-name].[collection-property-name]).
|
||||
*
|
||||
* @return The metadata associated with the given collection; may be null if no such
|
||||
* collection was mapped.
|
||||
*
|
||||
* @throws HibernateException Generally null is returned instead of throwing.
|
||||
*
|
||||
* @deprecated Use the descriptors from {@link #getMetamodel()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
CollectionMetadata getCollectionMetadata(String roleName);
|
||||
|
||||
/**
|
||||
* Retrieve the {@link ClassMetadata} for all mapped entities.
|
||||
*
|
||||
* @return A map containing all {@link ClassMetadata} keyed by the
|
||||
* corresponding {@link String} entity-name.
|
||||
*
|
||||
* @throws HibernateException Generally empty map is returned instead of throwing.
|
||||
*
|
||||
* @since 3.0 changed key from {@link Class} to {@link String}.
|
||||
*
|
||||
* @deprecated Use the descriptors from {@link #getMetamodel()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
Map<String,ClassMetadata> getAllClassMetadata();
|
||||
|
||||
/**
|
||||
* Get the {@link CollectionMetadata} for all mapped collections.
|
||||
*
|
||||
* @return a map from <tt>String</tt> to <tt>CollectionMetadata</tt>
|
||||
*
|
||||
* @throws HibernateException Generally empty map is returned instead of throwing.
|
||||
*
|
||||
* @deprecated Use the descriptors from {@link #getMetamodel()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
Map getAllCollectionMetadata();
|
||||
}
|
||||
|
|
|
@ -6,41 +6,62 @@
|
|||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* Specialized {@link SessionBuilder} with access to stuff from another session.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SharedSessionBuilder extends SessionBuilder {
|
||||
public interface SharedSessionBuilder<T extends SharedSessionBuilder> extends SessionBuilder<T> {
|
||||
|
||||
/**
|
||||
* Signifies the interceptor from the original session should be used to create the new session.
|
||||
* Signifies that the transaction context from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated Use {@link #connection()} instead
|
||||
*/
|
||||
public SharedSessionBuilder interceptor();
|
||||
@Deprecated
|
||||
default T transactionContext() {
|
||||
return connection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Signifies that the connection from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SharedSessionBuilder connection();
|
||||
T connection();
|
||||
|
||||
/**
|
||||
* Signifies the interceptor from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
T interceptor();
|
||||
|
||||
/**
|
||||
* Signifies that the connection release mode from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated (snce 6.0) use {@link #connectionHandlingMode} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
T connectionReleaseMode();
|
||||
|
||||
/**
|
||||
* Signifies that the connection release mode from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SharedSessionBuilder connectionReleaseMode();
|
||||
T connectionHandlingMode();
|
||||
|
||||
/**
|
||||
* Signifies that the autoJoinTransaction flag from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SharedSessionBuilder autoJoinTransactions();
|
||||
T autoJoinTransactions();
|
||||
|
||||
/**
|
||||
* Signifies that the autoClose flag from the original session should be used to create the new session.
|
||||
|
@ -51,40 +72,12 @@ public interface SharedSessionBuilder extends SessionBuilder {
|
|||
* session builders can use {@link #autoClose(boolean)} since they do not "inherit" the owner.
|
||||
*/
|
||||
@Deprecated
|
||||
public SharedSessionBuilder autoClose();
|
||||
T autoClose();
|
||||
|
||||
/**
|
||||
* Signifies that the flushBeforeCompletion flag from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SharedSessionBuilder flushBeforeCompletion();
|
||||
|
||||
/**
|
||||
* Signifies that the transaction context from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SharedSessionBuilder transactionContext();
|
||||
|
||||
@Override
|
||||
SharedSessionBuilder interceptor(Interceptor interceptor);
|
||||
|
||||
@Override
|
||||
SharedSessionBuilder noInterceptor();
|
||||
|
||||
@Override
|
||||
SharedSessionBuilder connection(Connection connection);
|
||||
|
||||
@Override
|
||||
SharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode);
|
||||
|
||||
@Override
|
||||
SharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions);
|
||||
|
||||
@Override
|
||||
SharedSessionBuilder autoClose(boolean autoClose);
|
||||
|
||||
@Override
|
||||
SharedSessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion);
|
||||
T flushBeforeCompletion();
|
||||
}
|
||||
|
|
|
@ -9,19 +9,44 @@ package org.hibernate;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.procedure.ProcedureCall;
|
||||
import org.hibernate.query.QueryProducer;
|
||||
|
||||
/**
|
||||
* Contract methods shared between {@link Session} and {@link StatelessSession}.
|
||||
* <p/>
|
||||
* NOTE : Poorly named. "shared" simply indicates that its a unified contract between {@link Session} and
|
||||
* {@link StatelessSession}.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SharedSessionContract extends Serializable {
|
||||
public interface SharedSessionContract extends QueryProducer, Serializable {
|
||||
/**
|
||||
* Obtain the tenant identifier associated with this session.
|
||||
*
|
||||
* @return The tenant identifier associated with this session, or {@code null}
|
||||
*/
|
||||
public String getTenantIdentifier();
|
||||
String getTenantIdentifier();
|
||||
|
||||
/**
|
||||
* End the session by releasing the JDBC connection and cleaning up.
|
||||
*
|
||||
* @throws HibernateException Indicates problems cleaning up.
|
||||
*/
|
||||
void close() throws HibernateException;
|
||||
|
||||
/**
|
||||
* Check if the session is still open.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isOpen();
|
||||
|
||||
/**
|
||||
* Check if the session is currently connected.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isConnected();
|
||||
|
||||
/**
|
||||
* Begin a unit of work and return the associated {@link Transaction} object. If a new underlying transaction is
|
||||
|
@ -32,7 +57,7 @@ public interface SharedSessionContract extends Serializable {
|
|||
*
|
||||
* @see #getTransaction
|
||||
*/
|
||||
public Transaction beginTransaction();
|
||||
Transaction beginTransaction();
|
||||
|
||||
/**
|
||||
* Get the {@link Transaction} instance associated with this session. The concrete type of the returned
|
||||
|
@ -40,34 +65,7 @@ public interface SharedSessionContract extends Serializable {
|
|||
*
|
||||
* @return a Transaction instance
|
||||
*/
|
||||
public Transaction getTransaction();
|
||||
|
||||
/**
|
||||
* Create a {@link Query} instance for the named query string defined in the metadata.
|
||||
*
|
||||
* @param queryName the name of a query defined externally
|
||||
*
|
||||
* @return The query instance for manipulation and execution
|
||||
*/
|
||||
public Query getNamedQuery(String queryName);
|
||||
|
||||
/**
|
||||
* Create a {@link Query} instance for the given HQL query string.
|
||||
*
|
||||
* @param queryString The HQL query
|
||||
*
|
||||
* @return The query instance for manipulation and execution
|
||||
*/
|
||||
public Query createQuery(String queryString);
|
||||
|
||||
/**
|
||||
* Create a {@link SQLQuery} instance for the given SQL query string.
|
||||
*
|
||||
* @param queryString The SQL query
|
||||
*
|
||||
* @return The query instance for manipulation and execution
|
||||
*/
|
||||
public SQLQuery createSQLQuery(String queryString);
|
||||
Transaction getTransaction();
|
||||
|
||||
/**
|
||||
* Gets a ProcedureCall based on a named template
|
||||
|
@ -78,7 +76,7 @@ public interface SharedSessionContract extends Serializable {
|
|||
*
|
||||
* @see javax.persistence.NamedStoredProcedureQuery
|
||||
*/
|
||||
public ProcedureCall getNamedProcedureCall(String name);
|
||||
ProcedureCall getNamedProcedureCall(String name);
|
||||
|
||||
/**
|
||||
* Creates a call to a stored procedure.
|
||||
|
@ -87,7 +85,7 @@ public interface SharedSessionContract extends Serializable {
|
|||
*
|
||||
* @return The representation of the procedure call.
|
||||
*/
|
||||
public ProcedureCall createStoredProcedureCall(String procedureName);
|
||||
ProcedureCall createStoredProcedureCall(String procedureName);
|
||||
|
||||
/**
|
||||
* Creates a call to a stored procedure with specific result set entity mappings. Each class named
|
||||
|
@ -98,7 +96,7 @@ public interface SharedSessionContract extends Serializable {
|
|||
*
|
||||
* @return The representation of the procedure call.
|
||||
*/
|
||||
public ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses);
|
||||
ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses);
|
||||
|
||||
/**
|
||||
* Creates a call to a stored procedure with specific result set entity mappings.
|
||||
|
@ -108,7 +106,7 @@ public interface SharedSessionContract extends Serializable {
|
|||
*
|
||||
* @return The representation of the procedure call.
|
||||
*/
|
||||
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings);
|
||||
ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings);
|
||||
|
||||
/**
|
||||
* Create {@link Criteria} instance for the given class (entity or subclasses/implementors).
|
||||
|
@ -116,8 +114,11 @@ public interface SharedSessionContract extends Serializable {
|
|||
* @param persistentClass The class, which is an entity, or has entity subclasses/implementors
|
||||
*
|
||||
* @return The criteria instance for manipulation and execution
|
||||
*
|
||||
* @deprecated (since 6.0) for Session, use the JPA Criteria
|
||||
*/
|
||||
public Criteria createCriteria(Class persistentClass);
|
||||
@Deprecated
|
||||
Criteria createCriteria(Class persistentClass);
|
||||
|
||||
/**
|
||||
* Create {@link Criteria} instance for the given class (entity or subclasses/implementors), using a specific
|
||||
|
@ -127,8 +128,11 @@ public interface SharedSessionContract extends Serializable {
|
|||
* @param alias The alias to use
|
||||
*
|
||||
* @return The criteria instance for manipulation and execution
|
||||
*
|
||||
* @deprecated (since 6.0) for Session, use the JPA Criteria
|
||||
*/
|
||||
public Criteria createCriteria(Class persistentClass, String alias);
|
||||
@Deprecated
|
||||
Criteria createCriteria(Class persistentClass, String alias);
|
||||
|
||||
/**
|
||||
* Create {@link Criteria} instance for the given entity name.
|
||||
|
@ -136,8 +140,11 @@ public interface SharedSessionContract extends Serializable {
|
|||
* @param entityName The entity name
|
||||
|
||||
* @return The criteria instance for manipulation and execution
|
||||
*
|
||||
* @deprecated (since 6.0) for Session, use the JPA Criteria
|
||||
*/
|
||||
public Criteria createCriteria(String entityName);
|
||||
@Deprecated
|
||||
Criteria createCriteria(String entityName);
|
||||
|
||||
/**
|
||||
* Create {@link Criteria} instance for the given entity name, using a specific alias.
|
||||
|
@ -146,6 +153,9 @@ public interface SharedSessionContract extends Serializable {
|
|||
* @param alias The alias to use
|
||||
*
|
||||
* @return The criteria instance for manipulation and execution
|
||||
*
|
||||
* @deprecated (since 6.0) for Session, use the JPA Criteria
|
||||
*/
|
||||
public Criteria createCriteria(String entityName, String alias);
|
||||
@Deprecated
|
||||
Criteria createCriteria(String entityName, String alias);
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ import java.sql.Connection;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface StatelessSessionBuilder {
|
||||
public interface StatelessSessionBuilder<T extends StatelessSessionBuilder> {
|
||||
/**
|
||||
* Opens a session with the specified options.
|
||||
*
|
||||
* @return The session
|
||||
*/
|
||||
public StatelessSession openStatelessSession();
|
||||
StatelessSession openStatelessSession();
|
||||
|
||||
/**
|
||||
* Adds a specific connection to the session options.
|
||||
|
@ -28,7 +28,7 @@ public interface StatelessSessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public StatelessSessionBuilder connection(Connection connection);
|
||||
T connection(Connection connection);
|
||||
|
||||
/**
|
||||
* Define the tenant identifier to be associated with the opened session.
|
||||
|
@ -37,5 +37,5 @@ public interface StatelessSessionBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public StatelessSessionBuilder tenantIdentifier(String tenantIdentifier);
|
||||
T tenantIdentifier(String tenantIdentifier);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public interface SynchronizeableQuery {
|
|||
*
|
||||
* @return The list of query spaces upon which the query is synchronized.
|
||||
*/
|
||||
public Collection<String> getSynchronizedQuerySpaces();
|
||||
Collection<String> getSynchronizedQuerySpaces();
|
||||
|
||||
/**
|
||||
* Adds a query space.
|
||||
|
@ -34,7 +34,7 @@ public interface SynchronizeableQuery {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SynchronizeableQuery addSynchronizedQuerySpace(String querySpace);
|
||||
SynchronizeableQuery addSynchronizedQuerySpace(String querySpace);
|
||||
|
||||
/**
|
||||
* Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking. Same as
|
||||
|
@ -46,7 +46,7 @@ public interface SynchronizeableQuery {
|
|||
*
|
||||
* @throws MappingException Indicates the given name could not be resolved as an entity
|
||||
*/
|
||||
public SynchronizeableQuery addSynchronizedEntityName(String entityName) throws MappingException;
|
||||
SynchronizeableQuery addSynchronizedEntityName(String entityName) throws MappingException;
|
||||
|
||||
/**
|
||||
* Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking. Same as
|
||||
|
@ -58,5 +58,5 @@ public interface SynchronizeableQuery {
|
|||
*
|
||||
* @throws MappingException Indicates the given class could not be resolved as an entity
|
||||
*/
|
||||
public SynchronizeableQuery addSynchronizedEntityClass(Class entityClass) throws MappingException;
|
||||
SynchronizeableQuery addSynchronizedEntityClass(Class entityClass) throws MappingException;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import javax.persistence.EntityTransaction;
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
@ -26,42 +27,7 @@ import org.hibernate.resource.transaction.spi.TransactionStatus;
|
|||
* @author Anton van Straaten
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Transaction {
|
||||
|
||||
/**
|
||||
* 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 Indicates a problem beginning the transaction.
|
||||
*/
|
||||
void begin();
|
||||
|
||||
/**
|
||||
* Commit this transaction. This might entail a number of things depending on the context:<ul>
|
||||
* <li>
|
||||
* If the underlying transaction was initiated from this Transaction the Session will be flushed,
|
||||
* unless the Session is in {@link FlushMode#MANUAL} FlushMode.
|
||||
* </li>
|
||||
* <li>
|
||||
* If the underlying transaction was initiated from this Transaction, commit the underlying transaction.
|
||||
* </li>
|
||||
* <li>
|
||||
* Coordinate various callbacks
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @throws HibernateException Indicates a problem committing the transaction.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
void rollback();
|
||||
|
||||
public interface Transaction extends EntityTransaction {
|
||||
/**
|
||||
* Get the current local status of this transaction.
|
||||
* <p/>
|
||||
|
@ -84,7 +50,7 @@ public interface Transaction {
|
|||
/**
|
||||
* 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.
|
||||
* @param seconds The number of seconds beforeQuery a timeout.
|
||||
*/
|
||||
void setTimeout(int seconds);
|
||||
|
||||
|
@ -98,6 +64,8 @@ public interface Transaction {
|
|||
/**
|
||||
* Make a best effort to mark the underlying transaction for rollback only.
|
||||
*/
|
||||
void markRollbackOnly();
|
||||
default void markRollbackOnly() {
|
||||
setRollbackOnly();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.type.BasicType;
|
||||
|
@ -18,6 +19,12 @@ import org.hibernate.type.Type;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface TypeHelper {
|
||||
// todo : deprecate all these BasicType methods with overloaded forms taking:
|
||||
// * Java type
|
||||
// * Converter
|
||||
// * Java type + sql-type indicator (type code/SqlTypeDescriptor)
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the basic type registered against the given name.
|
||||
*
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.engine.internal.Versioning;
|
|||
import org.hibernate.engine.spi.CachedNaturalIdValueSource;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.EntityKey;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
|
|||
Object instance,
|
||||
boolean isVersionIncrementDisabled,
|
||||
EntityPersister persister,
|
||||
SessionImplementor session) {
|
||||
SharedSessionContractImplementor session) {
|
||||
super( session, id, instance, persister );
|
||||
this.state = state;
|
||||
this.isVersionIncrementDisabled = isVersionIncrementDisabled;
|
||||
|
@ -150,7 +150,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
|
|||
protected abstract EntityKey getEntityKey();
|
||||
|
||||
@Override
|
||||
public void afterDeserialize(SessionImplementor session) {
|
||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
||||
super.afterDeserialize( session );
|
||||
// IMPL NOTE: non-flushed changes code calls this method with session == null...
|
||||
// guard against NullPointerException
|
||||
|
@ -161,10 +161,10 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
|
|||
}
|
||||
|
||||
/**
|
||||
* Handle sending notifications needed for natural-id before saving
|
||||
* Handle sending notifications needed for natural-id beforeQuery saving
|
||||
*/
|
||||
protected void handleNaturalIdPreSaveNotifications() {
|
||||
// before save, we need to add a local (transactional) natural id cross-reference
|
||||
// beforeQuery save, we need to add a local (transactional) natural id cross-reference
|
||||
getSession().getPersistenceContext().getNaturalIdHelper().manageLocalNaturalIdCrossReference(
|
||||
getPersister(),
|
||||
getId(),
|
||||
|
@ -175,7 +175,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
|
|||
}
|
||||
|
||||
/**
|
||||
* Handle sending notifications needed for natural-id after saving
|
||||
* Handle sending notifications needed for natural-id afterQuery saving
|
||||
*
|
||||
* @param generatedId The generated entity identifier
|
||||
*/
|
||||
|
@ -190,7 +190,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
|
|||
CachedNaturalIdValueSource.INSERT
|
||||
);
|
||||
}
|
||||
// after save, we need to manage the shared cache entries
|
||||
// afterQuery save, we need to manage the shared cache entries
|
||||
getSession().getPersistenceContext().getNaturalIdHelper().manageSharedNaturalIdCrossReference(
|
||||
getPersister(),
|
||||
getId(),
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
|
|||
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
|
||||
import org.hibernate.cache.spi.access.SoftLock;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Queryable;
|
||||
|
@ -41,9 +41,9 @@ import org.hibernate.persister.entity.Queryable;
|
|||
public class BulkOperationCleanupAction implements Executable, Serializable {
|
||||
private final Serializable[] affectedTableSpaces;
|
||||
|
||||
private final Set<EntityCleanup> entityCleanups = new HashSet<EntityCleanup>();
|
||||
private final Set<CollectionCleanup> collectionCleanups = new HashSet<CollectionCleanup>();
|
||||
private final Set<NaturalIdCleanup> naturalIdCleanups = new HashSet<NaturalIdCleanup>();
|
||||
private final Set<EntityCleanup> entityCleanups = new HashSet<>();
|
||||
private final Set<CollectionCleanup> collectionCleanups = new HashSet<>();
|
||||
private final Set<NaturalIdCleanup> naturalIdCleanups = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Constructs an action to cleanup "affected cache regions" based on the
|
||||
|
@ -55,7 +55,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
|||
* @param session The session to which this request is tied.
|
||||
* @param affectedQueryables The affected entity persisters.
|
||||
*/
|
||||
public BulkOperationCleanupAction(SessionImplementor session, Queryable... affectedQueryables) {
|
||||
public BulkOperationCleanupAction(SharedSessionContractImplementor session, Queryable... affectedQueryables) {
|
||||
final SessionFactoryImplementor factory = session.getFactory();
|
||||
final LinkedHashSet<String> spacesList = new LinkedHashSet<String>();
|
||||
for ( Queryable persister : affectedQueryables ) {
|
||||
|
@ -84,7 +84,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
|||
|
||||
/**
|
||||
* Constructs an action to cleanup "affected cache regions" based on a
|
||||
* set of affected table spaces. This differs from {@link #BulkOperationCleanupAction(SessionImplementor, Queryable[])}
|
||||
* set of affected table spaces. This differs from {@link #BulkOperationCleanupAction(SharedSessionContractImplementor, Queryable[])}
|
||||
* in that here we have the affected <strong>table names</strong>. From those
|
||||
* we deduce the entity persisters which are affected based on the defined
|
||||
* {@link EntityPersister#getQuerySpaces() table spaces}; and from there, we
|
||||
|
@ -95,7 +95,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
|||
* @param tableSpaces The table spaces.
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public BulkOperationCleanupAction(SessionImplementor session, Set tableSpaces) {
|
||||
public BulkOperationCleanupAction(SharedSessionContractImplementor session, Set tableSpaces) {
|
||||
final LinkedHashSet<String> spacesList = new LinkedHashSet<String>();
|
||||
spacesList.addAll( tableSpaces );
|
||||
|
||||
|
@ -170,7 +170,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
|||
public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess() {
|
||||
return new AfterTransactionCompletionProcess() {
|
||||
@Override
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
|
||||
public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) {
|
||||
for ( EntityCleanup cleanup : entityCleanups ) {
|
||||
cleanup.release();
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void afterDeserialize(SessionImplementor session) {
|
||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.cache.CacheException;
|
|||
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
|
||||
import org.hibernate.cache.spi.access.SoftLock;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
|
@ -31,7 +31,7 @@ import org.hibernate.pretty.MessageHelper;
|
|||
*/
|
||||
public abstract class CollectionAction implements Executable, Serializable, Comparable {
|
||||
private transient CollectionPersister persister;
|
||||
private transient SessionImplementor session;
|
||||
private transient SharedSessionContractImplementor session;
|
||||
private final PersistentCollection collection;
|
||||
|
||||
private final Serializable key;
|
||||
|
@ -41,7 +41,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
|||
final CollectionPersister persister,
|
||||
final PersistentCollection collection,
|
||||
final Serializable key,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
this.persister = persister;
|
||||
this.session = session;
|
||||
this.key = key;
|
||||
|
@ -54,11 +54,11 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
|||
}
|
||||
|
||||
/**
|
||||
* Reconnect to session after deserialization...
|
||||
* Reconnect to session afterQuery deserialization...
|
||||
*
|
||||
* @param session The session being deserialized
|
||||
*/
|
||||
public void afterDeserialize(SessionImplementor session) {
|
||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
||||
if ( this.session != null || this.persister != null ) {
|
||||
throw new IllegalStateException( "already attached to a session." );
|
||||
}
|
||||
|
@ -66,13 +66,13 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
|||
// guard against NullPointerException
|
||||
if ( session != null ) {
|
||||
this.session = session;
|
||||
this.persister = session.getFactory().getCollectionPersister( collectionRole );
|
||||
this.persister = session.getFactory().getMetamodel().collectionPersister( collectionRole );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void beforeExecutions() throws CacheException {
|
||||
// we need to obtain the lock before any actions are executed, since this may be an inverse="true"
|
||||
// we need to obtain the lock beforeQuery any actions are executed, since this may be an inverse="true"
|
||||
// bidirectional association and it is one of the earlier entity actions which actually updates
|
||||
// the database (this action is responsible for second-level cache invalidation only)
|
||||
if ( persister.hasCache() ) {
|
||||
|
@ -123,7 +123,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
|||
return finalKey;
|
||||
}
|
||||
|
||||
protected final SessionImplementor getSession() {
|
||||
protected final SharedSessionContractImplementor getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
|
||||
public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) {
|
||||
final CollectionRegionAccessStrategy cache = persister.getCacheAccessStrategy();
|
||||
final Object ck = cache.generateCacheKey(
|
||||
key,
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.io.Serializable;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostCollectionRecreateEvent;
|
||||
|
@ -36,7 +36,7 @@ public final class CollectionRecreateAction extends CollectionAction {
|
|||
final PersistentCollection collection,
|
||||
final CollectionPersister persister,
|
||||
final Serializable id,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
super( persister, collection, id, session );
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public final class CollectionRecreateAction extends CollectionAction {
|
|||
postRecreate();
|
||||
|
||||
if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
|
||||
getSession().getFactory().getStatisticsImplementor().recreateCollection( getPersister().getRole() );
|
||||
getSession().getFactory().getStatistics().recreateCollection( getPersister().getRole() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.io.Serializable;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostCollectionRemoveEvent;
|
||||
|
@ -45,13 +45,13 @@ public final class CollectionRemoveAction extends CollectionAction {
|
|||
final CollectionPersister persister,
|
||||
final Serializable id,
|
||||
final boolean emptySnapshot,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
super( persister, collection, id, session );
|
||||
if ( collection == null ) {
|
||||
throw new AssertionFailure("collection == null");
|
||||
}
|
||||
this.emptySnapshot = emptySnapshot;
|
||||
// the loaded owner will be set to null after the collection is removed,
|
||||
// the loaded owner will be set to null afterQuery the collection is removed,
|
||||
// so capture its value as the affected owner so it is accessible to
|
||||
// both pre- and post- events
|
||||
this.affectedOwner = session.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
|
||||
|
@ -75,7 +75,7 @@ public final class CollectionRemoveAction extends CollectionAction {
|
|||
final CollectionPersister persister,
|
||||
final Serializable id,
|
||||
final boolean emptySnapshot,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
super( persister, null, id, session );
|
||||
if ( affectedOwner == null ) {
|
||||
throw new AssertionFailure("affectedOwner == null");
|
||||
|
@ -105,7 +105,7 @@ public final class CollectionRemoveAction extends CollectionAction {
|
|||
postRemove();
|
||||
|
||||
if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
|
||||
getSession().getFactory().getStatisticsImplementor().removeCollection( getPersister().getRole() );
|
||||
getSession().getFactory().getStatistics().removeCollection( getPersister().getRole() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.io.Serializable;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostCollectionUpdateEvent;
|
||||
|
@ -41,7 +41,7 @@ public final class CollectionUpdateAction extends CollectionAction {
|
|||
final CollectionPersister persister,
|
||||
final Serializable id,
|
||||
final boolean emptySnapshot,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
super( persister, collection, id, session );
|
||||
this.emptySnapshot = emptySnapshot;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public final class CollectionUpdateAction extends CollectionAction {
|
|||
@Override
|
||||
public void execute() throws HibernateException {
|
||||
final Serializable id = getKey();
|
||||
final SessionImplementor session = getSession();
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
final CollectionPersister persister = getPersister();
|
||||
final PersistentCollection collection = getCollection();
|
||||
final boolean affectedByFilters = persister.isAffectedByEnabledFilters( session );
|
||||
|
@ -90,7 +90,7 @@ public final class CollectionUpdateAction extends CollectionAction {
|
|||
postUpdate();
|
||||
|
||||
if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
|
||||
getSession().getFactory().getStatisticsImplementor().updateCollection( getPersister().getRole() );
|
||||
getSession().getFactory().getStatistics().updateCollection( getPersister().getRole() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.AssertionFailure;
|
|||
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
|
||||
import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
|
||||
import org.hibernate.action.spi.Executable;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
|
@ -34,7 +34,7 @@ public abstract class EntityAction
|
|||
private final Serializable id;
|
||||
|
||||
private transient Object instance;
|
||||
private transient SessionImplementor session;
|
||||
private transient SharedSessionContractImplementor session;
|
||||
private transient EntityPersister persister;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ public abstract class EntityAction
|
|||
* @param instance The entity instance
|
||||
* @param persister The entity persister
|
||||
*/
|
||||
protected EntityAction(SessionImplementor session, Serializable id, Object instance, EntityPersister persister) {
|
||||
protected EntityAction(SharedSessionContractImplementor session, Serializable id, Object instance, EntityPersister persister) {
|
||||
this.entityName = persister.getEntityName();
|
||||
this.id = id;
|
||||
this.instance = instance;
|
||||
|
@ -113,7 +113,7 @@ public abstract class EntityAction
|
|||
*
|
||||
* @return The session from which this action originated.
|
||||
*/
|
||||
public final SessionImplementor getSession() {
|
||||
public final SharedSessionContractImplementor getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
|
@ -156,12 +156,12 @@ public abstract class EntityAction
|
|||
}
|
||||
|
||||
/**
|
||||
* Reconnect to session after deserialization...
|
||||
* Reconnect to session afterQuery deserialization...
|
||||
*
|
||||
* @param session The session being deserialized
|
||||
*/
|
||||
@Override
|
||||
public void afterDeserialize(SessionImplementor session) {
|
||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
||||
if ( this.session != null || this.persister != null ) {
|
||||
throw new IllegalStateException( "already attached to a session." );
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ public abstract class EntityAction
|
|||
// guard against NullPointerException
|
||||
if ( session != null ) {
|
||||
this.session = session;
|
||||
this.persister = session.getFactory().getEntityPersister( entityName );
|
||||
this.persister = session.getFactory().getMetamodel().entityPersister( entityName );
|
||||
this.instance = session.getPersistenceContext().getEntity( session.generateEntityKey( id, persister ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.cache.spi.access.SoftLock;
|
|||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostCommitDeleteEventListener;
|
||||
|
@ -59,7 +60,7 @@ public class EntityDeleteAction extends EntityAction {
|
|||
this.isCascadeDeleteEnabled = isCascadeDeleteEnabled;
|
||||
this.state = state;
|
||||
|
||||
// before remove we need to remove the local (transactional) natural id cross-reference
|
||||
// beforeQuery remove we need to remove the local (transactional) natural id cross-reference
|
||||
naturalIdValues = session.getPersistenceContext().getNaturalIdHelper().removeLocalNaturalIdCrossReference(
|
||||
getPersister(),
|
||||
getId(),
|
||||
|
@ -71,7 +72,7 @@ public class EntityDeleteAction extends EntityAction {
|
|||
public void execute() throws HibernateException {
|
||||
final Serializable id = getId();
|
||||
final EntityPersister persister = getPersister();
|
||||
final SessionImplementor session = getSession();
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
final Object instance = getInstance();
|
||||
|
||||
final boolean veto = preDelete();
|
||||
|
@ -121,7 +122,7 @@ public class EntityDeleteAction extends EntityAction {
|
|||
postDelete();
|
||||
|
||||
if ( getSession().getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
|
||||
getSession().getFactory().getStatisticsImplementor().deleteEntity( getPersister().getEntityName() );
|
||||
getSession().getFactory().getStatistics().deleteEntity( getPersister().getEntityName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +185,7 @@ public class EntityDeleteAction extends EntityAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException {
|
||||
public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) throws HibernateException {
|
||||
EntityPersister entityPersister = getPersister();
|
||||
if ( entityPersister.hasCache() ) {
|
||||
EntityRegionAccessStrategy cache = entityPersister.getCacheAccessStrategy();
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.io.Serializable;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.EntityKey;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostCommitInsertEventListener;
|
||||
|
@ -50,7 +50,7 @@ public final class EntityIdentityInsertAction extends AbstractEntityInsertAction
|
|||
Object instance,
|
||||
EntityPersister persister,
|
||||
boolean isVersionIncrementDisabled,
|
||||
SessionImplementor session,
|
||||
SharedSessionContractImplementor session,
|
||||
boolean isDelayed) {
|
||||
super(
|
||||
( isDelayed ? generateDelayedPostInsertIdentifier() : null ),
|
||||
|
@ -69,7 +69,7 @@ public final class EntityIdentityInsertAction extends AbstractEntityInsertAction
|
|||
nullifyTransientReferencesIfNotAlready();
|
||||
|
||||
final EntityPersister persister = getPersister();
|
||||
final SessionImplementor session = getSession();
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
final Object instance = getInstance();
|
||||
|
||||
final boolean veto = preInsert();
|
||||
|
@ -91,7 +91,7 @@ public final class EntityIdentityInsertAction extends AbstractEntityInsertAction
|
|||
}
|
||||
|
||||
|
||||
//TODO: this bit actually has to be called after all cascades!
|
||||
//TODO: this bit actually has to be called afterQuery all cascades!
|
||||
// but since identity insert is called *synchronously*,
|
||||
// instead of asynchronously as other actions, it isn't
|
||||
/*if ( persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
|
||||
|
@ -127,7 +127,7 @@ public final class EntityIdentityInsertAction extends AbstractEntityInsertAction
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
|
||||
public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) {
|
||||
//TODO: reenable if we also fix the above todo
|
||||
/*EntityPersister persister = getEntityPersister();
|
||||
if ( success && persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
|
||||
/**
|
||||
* A BeforeTransactionCompletionProcess impl to verify and increment an entity version as party
|
||||
* of before-transaction-completion processing
|
||||
* of beforeQuery-transaction-completion processing
|
||||
*
|
||||
* @author Scott Marlow
|
||||
*/
|
||||
|
@ -33,7 +33,7 @@ public class EntityIncrementVersionProcess implements BeforeTransactionCompletio
|
|||
}
|
||||
|
||||
/**
|
||||
* Perform whatever processing is encapsulated here before completion of the transaction.
|
||||
* Perform whatever processing is encapsulated here beforeQuery completion of the transaction.
|
||||
*
|
||||
* @param session The session on which the transaction is preparing to complete.
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.engine.spi.EntityKey;
|
|||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostCommitInsertEventListener;
|
||||
|
@ -55,7 +55,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
Object version,
|
||||
EntityPersister persister,
|
||||
boolean isVersionIncrementDisabled,
|
||||
SessionImplementor session) {
|
||||
SharedSessionContractImplementor session) {
|
||||
super( id, state, instance, isVersionIncrementDisabled, persister, session );
|
||||
this.version = version;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
nullifyTransientReferencesIfNotAlready();
|
||||
|
||||
final EntityPersister persister = getPersister();
|
||||
final SessionImplementor session = getSession();
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
final Object instance = getInstance();
|
||||
final Serializable id = getId();
|
||||
|
||||
|
@ -122,7 +122,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
final boolean put = cacheInsert( persister, ck );
|
||||
|
||||
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
|
||||
factory.getStatisticsImplementor().secondLevelCachePut( cache.getRegion().getName() );
|
||||
factory.getStatistics().secondLevelCachePut( cache.getRegion().getName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,14 +131,14 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
postInsert();
|
||||
|
||||
if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
|
||||
factory.getStatisticsImplementor().insertEntity( getPersister().getEntityName() );
|
||||
factory.getStatistics().insertEntity( getPersister().getEntityName() );
|
||||
}
|
||||
|
||||
markExecuted();
|
||||
}
|
||||
|
||||
private boolean cacheInsert(EntityPersister persister, Object ck) {
|
||||
SessionImplementor session = getSession();
|
||||
SharedSessionContractImplementor session = getSession();
|
||||
try {
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
return persister.getCacheAccessStrategy().insert( session, ck, cacheEntry, version);
|
||||
|
@ -208,7 +208,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException {
|
||||
public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) throws HibernateException {
|
||||
final EntityPersister persister = getPersister();
|
||||
if ( success && isCachePutEnabled( persister, getSession() ) ) {
|
||||
final EntityRegionAccessStrategy cache = persister.getCacheAccessStrategy();
|
||||
|
@ -225,7 +225,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
}
|
||||
|
||||
private boolean cacheAfterInsert(EntityRegionAccessStrategy cache, Object ck) {
|
||||
SessionImplementor session = getSession();
|
||||
SharedSessionContractImplementor session = getSession();
|
||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
|
@ -248,7 +248,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean isCachePutEnabled(EntityPersister persister, SessionImplementor session) {
|
||||
private boolean isCachePutEnabled(EntityPersister persister, SharedSessionContractImplementor session) {
|
||||
return persister.hasCache()
|
||||
&& !persister.isCacheInvalidationRequired()
|
||||
&& session.getCacheMode().isPutEnabled();
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.hibernate.engine.spi.CachedNaturalIdValueSource;
|
|||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
|
@ -72,7 +72,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
final Object instance,
|
||||
final Object rowId,
|
||||
final EntityPersister persister,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
super( session, id, instance, persister );
|
||||
this.state = state;
|
||||
this.previousState = previousState;
|
||||
|
@ -95,7 +95,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
private Object[] determinePreviousNaturalIdValues(
|
||||
EntityPersister persister,
|
||||
Object[] previousState,
|
||||
SessionImplementor session,
|
||||
SharedSessionContractImplementor session,
|
||||
Serializable id) {
|
||||
if ( ! persister.hasNaturalIdentifier() ) {
|
||||
return null;
|
||||
|
@ -112,7 +112,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
public void execute() throws HibernateException {
|
||||
final Serializable id = getId();
|
||||
final EntityPersister persister = getPersister();
|
||||
final SessionImplementor session = getSession();
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
final Object instance = getInstance();
|
||||
|
||||
final boolean veto = preUpdate();
|
||||
|
@ -195,7 +195,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
|
||||
final boolean put = cacheUpdate( persister, previousVersion, ck );
|
||||
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
|
||||
factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
|
||||
factory.getStatistics().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,12 +211,12 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
postUpdate();
|
||||
|
||||
if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
|
||||
factory.getStatisticsImplementor().updateEntity( getPersister().getEntityName() );
|
||||
factory.getStatistics().updateEntity( getPersister().getEntityName() );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cacheUpdate(EntityPersister persister, Object previousVersion, Object ck) {
|
||||
final SessionImplementor session = getSession();
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
try {
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
return persister.getCacheAccessStrategy().update( session, ck, cacheEntry, nextVersion, previousVersion );
|
||||
|
@ -308,7 +308,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws CacheException {
|
||||
public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) throws CacheException {
|
||||
final EntityPersister persister = getPersister();
|
||||
if ( persister.hasCache() ) {
|
||||
final EntityRegionAccessStrategy cache = persister.getCacheAccessStrategy();
|
||||
|
@ -324,7 +324,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
final boolean put = cacheAfterUpdate( cache, ck );
|
||||
|
||||
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
|
||||
getSession().getFactory().getStatisticsImplementor().secondLevelCachePut( cache.getRegion().getName() );
|
||||
getSession().getFactory().getStatistics().secondLevelCachePut( cache.getRegion().getName() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -335,7 +335,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
}
|
||||
|
||||
private boolean cacheAfterUpdate(EntityRegionAccessStrategy cache, Object ck) {
|
||||
final SessionImplementor session = getSession();
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.pretty.MessageHelper;
|
|||
|
||||
/**
|
||||
* A BeforeTransactionCompletionProcess impl to verify an entity version as part of
|
||||
* before-transaction-completion processing
|
||||
* beforeQuery-transaction-completion processing
|
||||
*
|
||||
* @author Scott Marlow
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.io.Serializable;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ public final class QueuedOperationCollectionAction extends CollectionAction {
|
|||
final PersistentCollection collection,
|
||||
final CollectionPersister persister,
|
||||
final Serializable id,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
super( persister, collection, id, session );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.hibernate.TransientPropertyValueException;
|
|||
import org.hibernate.engine.internal.NonNullableTransientDependencies;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.collections.IdentitySet;
|
||||
|
@ -36,7 +37,7 @@ import org.jboss.logging.Logger;
|
|||
* an unsaved transient entity, and the foreign key points to that
|
||||
* unsaved transient entity.
|
||||
*
|
||||
* These references must be resolved before an insert action can be
|
||||
* These references must be resolved beforeQuery an insert action can be
|
||||
* executed.
|
||||
*
|
||||
* @author Gail Badner
|
||||
|
@ -49,10 +50,8 @@ public class UnresolvedEntityInsertActions {
|
|||
|
||||
private static final int INIT_SIZE = 5;
|
||||
|
||||
private final Map<AbstractEntityInsertAction,NonNullableTransientDependencies> dependenciesByAction =
|
||||
new IdentityHashMap<AbstractEntityInsertAction,NonNullableTransientDependencies>( INIT_SIZE );
|
||||
private final Map<Object,Set<AbstractEntityInsertAction>> dependentActionsByTransientEntity =
|
||||
new IdentityHashMap<Object,Set<AbstractEntityInsertAction>>( INIT_SIZE );
|
||||
private final Map<AbstractEntityInsertAction,NonNullableTransientDependencies> dependenciesByAction = new IdentityHashMap<>( INIT_SIZE );
|
||||
private final Map<Object,Set<AbstractEntityInsertAction>> dependentActionsByTransientEntity = new IdentityHashMap<>( INIT_SIZE );
|
||||
|
||||
/**
|
||||
* Add an unresolved insert action.
|
||||
|
@ -92,7 +91,7 @@ public class UnresolvedEntityInsertActions {
|
|||
* Throws {@link org.hibernate.PropertyValueException} if there are any unresolved
|
||||
* entity insert actions that depend on non-nullable associations with
|
||||
* a transient entity. This method should be called on completion of
|
||||
* an operation (after all cascades are completed) that saves an entity.
|
||||
* an operation (afterQuery all cascades are completed) that saves an entity.
|
||||
*
|
||||
* @throws org.hibernate.PropertyValueException if there are any unresolved entity
|
||||
* insert actions; {@link org.hibernate.PropertyValueException#getEntityName()}
|
||||
|
@ -118,7 +117,7 @@ public class UnresolvedEntityInsertActions {
|
|||
nonNullableTransientDependencies.getNonNullableTransientPropertyPaths( firstTransientDependency ).iterator().next();
|
||||
|
||||
throw new TransientPropertyValueException(
|
||||
"Not-null property references a transient value - transient instance must be saved before current operation",
|
||||
"Not-null property references a transient value - transient instance must be saved beforeQuery current operation",
|
||||
firstDependentAction.getSession().guessEntityName( firstTransientDependency ),
|
||||
firstDependentAction.getEntityName(),
|
||||
firstPropertyPath
|
||||
|
@ -126,14 +125,14 @@ public class UnresolvedEntityInsertActions {
|
|||
}
|
||||
}
|
||||
|
||||
private void logCannotResolveNonNullableTransientDependencies(SessionImplementor session) {
|
||||
private void logCannotResolveNonNullableTransientDependencies(SharedSessionContractImplementor session) {
|
||||
for ( Map.Entry<Object,Set<AbstractEntityInsertAction>> entry : dependentActionsByTransientEntity.entrySet() ) {
|
||||
final Object transientEntity = entry.getKey();
|
||||
final String transientEntityName = session.guessEntityName( transientEntity );
|
||||
final Serializable transientEntityId = session.getFactory().getEntityPersister( transientEntityName ).getIdentifier( transientEntity, session );
|
||||
final Serializable transientEntityId = session.getFactory().getMetamodel().entityPersister( transientEntityName ).getIdentifier( transientEntity, session );
|
||||
final String transientEntityString = MessageHelper.infoString( transientEntityName, transientEntityId );
|
||||
final Set<String> dependentEntityStrings = new TreeSet<String>();
|
||||
final Set<String> nonNullableTransientPropertyPaths = new TreeSet<String>();
|
||||
final Set<String> dependentEntityStrings = new TreeSet<>();
|
||||
final Set<String> nonNullableTransientPropertyPaths = new TreeSet<>();
|
||||
for ( AbstractEntityInsertAction dependentAction : entry.getValue() ) {
|
||||
dependentEntityStrings.add( MessageHelper.infoString( dependentAction.getEntityName(), dependentAction.getId() ) );
|
||||
for ( String path : dependenciesByAction.get( dependentAction ).getNonNullableTransientPropertyPaths( transientEntity ) ) {
|
||||
|
@ -204,7 +203,7 @@ public class UnresolvedEntityInsertActions {
|
|||
final Set<AbstractEntityInsertAction> resolvedActions = new IdentitySet( );
|
||||
if ( traceEnabled ) {
|
||||
LOG.tracev(
|
||||
"Unresolved inserts before resolving [{0}]: [{1}]",
|
||||
"Unresolved inserts beforeQuery resolving [{0}]: [{1}]",
|
||||
MessageHelper.infoString( entityEntry.getEntityName(), entityEntry.getId() ),
|
||||
toString()
|
||||
);
|
||||
|
@ -234,7 +233,7 @@ public class UnresolvedEntityInsertActions {
|
|||
}
|
||||
if ( traceEnabled ) {
|
||||
LOG.tracev(
|
||||
"Unresolved inserts after resolving [{0}]: [{1}]",
|
||||
"Unresolved inserts afterQuery resolving [{0}]: [{1}]",
|
||||
MessageHelper.infoString( entityEntry.getEntityName(), entityEntry.getId() ),
|
||||
toString()
|
||||
);
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
*/
|
||||
package org.hibernate.action.spi;
|
||||
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* Contract representing some process that needs to occur during after transaction completion.
|
||||
* Contract representing some process that needs to occur during afterQuery transaction completion.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AfterTransactionCompletionProcess {
|
||||
/**
|
||||
* Perform whatever processing is encapsulated here after completion of the transaction.
|
||||
* Perform whatever processing is encapsulated here afterQuery completion of the transaction.
|
||||
*
|
||||
* @param success Did the transaction complete successfully? True means it did.
|
||||
* @param session The session on which the transaction is completing.
|
||||
*/
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session);
|
||||
void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session);
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@ package org.hibernate.action.spi;
|
|||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
|
||||
/**
|
||||
* Contract representing some process that needs to occur during before transaction completion.
|
||||
* Contract representing some process that needs to occur during beforeQuery transaction completion.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface BeforeTransactionCompletionProcess {
|
||||
/**
|
||||
* Perform whatever processing is encapsulated here before completion of the transaction.
|
||||
* Perform whatever processing is encapsulated here beforeQuery completion of the transaction.
|
||||
*
|
||||
* @param session The session on which the transaction is preparing to complete.
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.action.spi;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* An operation which may be scheduled for later execution. Usually, the operation is a database
|
||||
|
@ -24,42 +24,42 @@ public interface Executable {
|
|||
*
|
||||
* @return The spaces affected by this action.
|
||||
*/
|
||||
public Serializable[] getPropertySpaces();
|
||||
Serializable[] getPropertySpaces();
|
||||
|
||||
/**
|
||||
* Called before executing any actions. Gives actions a chance to perform any preparation.
|
||||
* Called beforeQuery executing any actions. Gives actions a chance to perform any preparation.
|
||||
*
|
||||
* @throws HibernateException Indicates a problem during preparation.
|
||||
*/
|
||||
public void beforeExecutions() throws HibernateException;
|
||||
void beforeExecutions() throws HibernateException;
|
||||
|
||||
/**
|
||||
* Execute this action.
|
||||
*
|
||||
* @throws HibernateException Indicates a problem during execution.
|
||||
*/
|
||||
public void execute() throws HibernateException;
|
||||
void execute() throws HibernateException;
|
||||
|
||||
/**
|
||||
* Get the after-transaction-completion process, if any, for this action.
|
||||
* Get the afterQuery-transaction-completion process, if any, for this action.
|
||||
*
|
||||
* @return The after-transaction-completion process, or null if we have no
|
||||
* after-transaction-completion process
|
||||
* @return The afterQuery-transaction-completion process, or null if we have no
|
||||
* afterQuery-transaction-completion process
|
||||
*/
|
||||
public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess();
|
||||
AfterTransactionCompletionProcess getAfterTransactionCompletionProcess();
|
||||
|
||||
/**
|
||||
* Get the before-transaction-completion process, if any, for this action.
|
||||
* Get the beforeQuery-transaction-completion process, if any, for this action.
|
||||
*
|
||||
* @return The before-transaction-completion process, or null if we have no
|
||||
* before-transaction-completion process
|
||||
* @return The beforeQuery-transaction-completion process, or null if we have no
|
||||
* beforeQuery-transaction-completion process
|
||||
*/
|
||||
public BeforeTransactionCompletionProcess getBeforeTransactionCompletionProcess();
|
||||
BeforeTransactionCompletionProcess getBeforeTransactionCompletionProcess();
|
||||
|
||||
/**
|
||||
* Reconnect to session after deserialization
|
||||
* Reconnect to session afterQuery deserialization
|
||||
*
|
||||
* @param session The session being deserialized
|
||||
*/
|
||||
public void afterDeserialize(SessionImplementor session);
|
||||
void afterDeserialize(SharedSessionContractImplementor session);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||
* For updating, should this entity use dynamic sql generation where only changed columns get referenced in the
|
||||
* prepared sql statement?
|
||||
* <p/>
|
||||
* Note, for re-attachment of detached entities this is not possible without select-before-update being enabled.
|
||||
* Note, for re-attachment of detached entities this is not possible without select-beforeQuery-update being enabled.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
|
|
|
@ -43,7 +43,7 @@ public @interface Entity {
|
|||
@Deprecated
|
||||
boolean dynamicUpdate() default false;
|
||||
/**
|
||||
* Do a select to retrieve the entity before any potential update.
|
||||
* Do a select to retrieve the entity beforeQuery any potential update.
|
||||
* @deprecated Use {@link SelectBeforeUpdate} instead
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -23,7 +23,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||
@Retention(RUNTIME)
|
||||
public @interface NamedNativeQuery {
|
||||
/**
|
||||
* The name. It is a named query after all :)
|
||||
* The name. It is a named query afterQuery all :)
|
||||
*/
|
||||
String name();
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||
public @interface SelectBeforeUpdate {
|
||||
/**
|
||||
* {@code true} (which is the default when this annotation is present) indicates that
|
||||
* {@code select-before-update} processing should occur. {@code false} indicates
|
||||
* {@code select-before-update} processing should not occur.
|
||||
* {@code select-beforeQuery-update} processing should occur. {@code false} indicates
|
||||
* {@code select-beforeQuery-update} processing should not occur.
|
||||
*/
|
||||
boolean value() default true;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder applyValidatorFactory(Object validatorFactory);
|
||||
SessionFactoryBuilder applyValidatorFactory(Object validatorFactory);
|
||||
|
||||
/**
|
||||
* Apply a CDI BeanManager to the SessionFactory being built.
|
||||
|
@ -57,7 +57,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder applyBeanManager(Object beanManager);
|
||||
SessionFactoryBuilder applyBeanManager(Object beanManager);
|
||||
|
||||
/**
|
||||
* Applies a SessionFactory name.
|
||||
|
@ -68,7 +68,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#SESSION_FACTORY_NAME
|
||||
*/
|
||||
public SessionFactoryBuilder applyName(String sessionFactoryName);
|
||||
SessionFactoryBuilder applyName(String sessionFactoryName);
|
||||
|
||||
/**
|
||||
* Applies a SessionFactory name.
|
||||
|
@ -80,7 +80,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#SESSION_FACTORY_NAME_IS_JNDI
|
||||
*/
|
||||
public SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName);
|
||||
SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName);
|
||||
|
||||
/**
|
||||
* Applies whether Sessions should be automatically closed at the end of the transaction.
|
||||
|
@ -91,7 +91,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#AUTO_CLOSE_SESSION
|
||||
*/
|
||||
public SessionFactoryBuilder applyAutoClosing(boolean enabled);
|
||||
SessionFactoryBuilder applyAutoClosing(boolean enabled);
|
||||
|
||||
/**
|
||||
* Applies whether Sessions should be automatically flushed at the end of the transaction.
|
||||
|
@ -102,7 +102,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#FLUSH_BEFORE_COMPLETION
|
||||
*/
|
||||
public SessionFactoryBuilder applyAutoFlushing(boolean enabled);
|
||||
SessionFactoryBuilder applyAutoFlushing(boolean enabled);
|
||||
|
||||
/**
|
||||
* Applies whether statistics gathering is enabled.
|
||||
|
@ -113,7 +113,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#GENERATE_STATISTICS
|
||||
*/
|
||||
public SessionFactoryBuilder applyStatisticsSupport(boolean enabled);
|
||||
SessionFactoryBuilder applyStatisticsSupport(boolean enabled);
|
||||
|
||||
/**
|
||||
* Names an interceptor to be applied to the SessionFactory, which in turn means it will be used by all
|
||||
|
@ -125,7 +125,19 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#INTERCEPTOR
|
||||
*/
|
||||
public SessionFactoryBuilder applyInterceptor(Interceptor interceptor);
|
||||
SessionFactoryBuilder applyInterceptor(Interceptor interceptor);
|
||||
|
||||
/**
|
||||
* Names an interceptor Class to be applied to the SessionFactory, which in turn means it will be used by all
|
||||
* Sessions unless one is explicitly specified in {@link org.hibernate.SessionBuilder#interceptor}
|
||||
*
|
||||
* @param statelessInterceptorClass The interceptor class
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#SESSION_SCOPED_INTERCEPTOR
|
||||
*/
|
||||
SessionFactoryBuilder applyStatelessInterceptor(Class<? extends Interceptor> statelessInterceptorClass);
|
||||
|
||||
/**
|
||||
* Names a StatementInspector to be applied to the SessionFactory, which in turn means it will be used by all
|
||||
|
@ -137,7 +149,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#STATEMENT_INSPECTOR
|
||||
*/
|
||||
public SessionFactoryBuilder applyStatementInspector(StatementInspector statementInspector);
|
||||
SessionFactoryBuilder applyStatementInspector(StatementInspector statementInspector);
|
||||
|
||||
/**
|
||||
* Specifies one or more observers to be applied to the SessionFactory. Can be called multiple times to add
|
||||
|
@ -147,7 +159,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers);
|
||||
SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers);
|
||||
|
||||
/**
|
||||
* Specifies a custom entity dirtiness strategy to be applied to the SessionFactory. See the contract
|
||||
|
@ -159,7 +171,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#CUSTOM_ENTITY_DIRTINESS_STRATEGY
|
||||
*/
|
||||
public SessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy);
|
||||
SessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy);
|
||||
|
||||
/**
|
||||
* Specifies one or more entity name resolvers to be applied to the SessionFactory (see the {@link org.hibernate.EntityNameResolver}
|
||||
|
@ -169,7 +181,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers);
|
||||
SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers);
|
||||
|
||||
/**
|
||||
* Names the {@link org.hibernate.proxy.EntityNotFoundDelegate} to be applied to the SessionFactory. EntityNotFoundDelegate is a
|
||||
|
@ -179,7 +191,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate);
|
||||
SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate);
|
||||
|
||||
/**
|
||||
* Should generated identifiers be "unset" on entities during a rollback?
|
||||
|
@ -190,7 +202,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_IDENTIFIER_ROLLBACK
|
||||
*/
|
||||
public SessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled);
|
||||
SessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled);
|
||||
|
||||
/**
|
||||
* Applies the given entity mode as the default for the SessionFactory.
|
||||
|
@ -204,7 +216,7 @@ public interface SessionFactoryBuilder {
|
|||
* @deprecated Different entity modes per entity is soon to be removed as a feature.
|
||||
*/
|
||||
@Deprecated
|
||||
public SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode);
|
||||
SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode);
|
||||
|
||||
/**
|
||||
* Should attributes using columns marked as not-null be checked (by Hibernate) for nullness?
|
||||
|
@ -216,7 +228,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#CHECK_NULLABILITY
|
||||
*/
|
||||
public SessionFactoryBuilder applyNullabilityChecking(boolean enabled);
|
||||
SessionFactoryBuilder applyNullabilityChecking(boolean enabled);
|
||||
|
||||
/**
|
||||
* Should the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?
|
||||
|
@ -228,7 +240,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#ENABLE_LAZY_LOAD_NO_TRANS
|
||||
*/
|
||||
public SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled);
|
||||
SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled);
|
||||
|
||||
/**
|
||||
* Specify the EntityTuplizerFactory to use.
|
||||
|
@ -237,7 +249,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory);
|
||||
SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory);
|
||||
|
||||
/**
|
||||
* Register the default {@link org.hibernate.tuple.entity.EntityTuplizer} to be applied to the SessionFactory.
|
||||
|
@ -247,7 +259,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder applyEntityTuplizer(
|
||||
SessionFactoryBuilder applyEntityTuplizer(
|
||||
EntityMode entityMode,
|
||||
Class<? extends EntityTuplizer> tuplizerClass);
|
||||
|
||||
|
@ -260,9 +272,9 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#HQL_BULK_ID_STRATEGY
|
||||
*/
|
||||
public SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy);
|
||||
SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy);
|
||||
|
||||
public SessionFactoryBuilder applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling);
|
||||
SessionFactoryBuilder applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling);
|
||||
|
||||
/**
|
||||
* What style of batching should be used?
|
||||
|
@ -273,7 +285,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#BATCH_FETCH_STYLE
|
||||
*/
|
||||
public SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style);
|
||||
SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style);
|
||||
|
||||
/**
|
||||
* Allows specifying a default batch-fetch size for all entities and collections
|
||||
|
@ -286,7 +298,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_BATCH_FETCH_SIZE
|
||||
*/
|
||||
public SessionFactoryBuilder applyDefaultBatchFetchSize(int size);
|
||||
SessionFactoryBuilder applyDefaultBatchFetchSize(int size);
|
||||
|
||||
/**
|
||||
* Apply a limit to the depth Hibernate will use for outer joins. Note that this is different than an
|
||||
|
@ -298,7 +310,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#MAX_FETCH_DEPTH
|
||||
*/
|
||||
public SessionFactoryBuilder applyMaximumFetchDepth(int depth);
|
||||
SessionFactoryBuilder applyMaximumFetchDepth(int depth);
|
||||
|
||||
/**
|
||||
* Apply a null precedence (NULLS FIRST, NULLS LAST) to be applied order-by clauses rendered into
|
||||
|
@ -310,7 +322,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_NULL_ORDERING
|
||||
*/
|
||||
public SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence);
|
||||
SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence);
|
||||
|
||||
/**
|
||||
* Apply whether ordering of inserts should be enabled. This allows more efficient SQL
|
||||
|
@ -323,7 +335,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#ORDER_INSERTS
|
||||
*/
|
||||
public SessionFactoryBuilder applyOrderingOfInserts(boolean enabled);
|
||||
SessionFactoryBuilder applyOrderingOfInserts(boolean enabled);
|
||||
|
||||
/**
|
||||
* Apply whether ordering of updates should be enabled. This allows more efficient SQL
|
||||
|
@ -336,7 +348,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#ORDER_UPDATES
|
||||
*/
|
||||
public SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled);
|
||||
SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled);
|
||||
|
||||
/**
|
||||
* Apply the form of multi-tenancy used by the application
|
||||
|
@ -347,7 +359,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#MULTI_TENANT
|
||||
*/
|
||||
public SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy);
|
||||
SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy);
|
||||
|
||||
/**
|
||||
* Specifies a strategy for resolving the notion of a "current" tenant-identifier when using multi-tenancy
|
||||
|
@ -359,7 +371,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#MULTI_TENANT_IDENTIFIER_RESOLVER
|
||||
*/
|
||||
public SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver);
|
||||
SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver);
|
||||
|
||||
/**
|
||||
* If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it track JTA
|
||||
|
@ -371,7 +383,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#JTA_TRACK_BY_THREAD
|
||||
*/
|
||||
public SessionFactoryBuilder applyJtaTrackingByThread(boolean enabled);
|
||||
SessionFactoryBuilder applyJtaTrackingByThread(boolean enabled);
|
||||
|
||||
/**
|
||||
* If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it prefer to use
|
||||
|
@ -384,7 +396,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#PREFER_USER_TRANSACTION
|
||||
*/
|
||||
public SessionFactoryBuilder applyPreferUserTransactions(boolean preferUserTransactions);
|
||||
SessionFactoryBuilder applyPreferUserTransactions(boolean preferUserTransactions);
|
||||
|
||||
/**
|
||||
* Apply query substitutions to use in HQL queries. Note, this is a legacy feature and almost always
|
||||
|
@ -399,7 +411,7 @@ public interface SessionFactoryBuilder {
|
|||
* @deprecated This is a legacy feature and should never be needed anymore...
|
||||
*/
|
||||
@Deprecated
|
||||
public SessionFactoryBuilder applyQuerySubstitutions(Map substitutions);
|
||||
SessionFactoryBuilder applyQuerySubstitutions(Map substitutions);
|
||||
|
||||
/**
|
||||
* Should we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support
|
||||
|
@ -415,7 +427,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#JPAQL_STRICT_COMPLIANCE
|
||||
*/
|
||||
public SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled);
|
||||
SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled);
|
||||
|
||||
/**
|
||||
* Should named queries be checked on startup?
|
||||
|
@ -426,7 +438,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#QUERY_STARTUP_CHECKING
|
||||
*/
|
||||
public SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled);
|
||||
SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled);
|
||||
|
||||
/**
|
||||
* Should second level caching support be enabled?
|
||||
|
@ -438,7 +450,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_SECOND_LEVEL_CACHE
|
||||
*/
|
||||
public SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled);
|
||||
SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled);
|
||||
|
||||
/**
|
||||
* Should second level query caching support be enabled?
|
||||
|
@ -450,7 +462,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_QUERY_CACHE
|
||||
*/
|
||||
public SessionFactoryBuilder applyQueryCacheSupport(boolean enabled);
|
||||
SessionFactoryBuilder applyQueryCacheSupport(boolean enabled);
|
||||
|
||||
/**
|
||||
* Specifies a QueryCacheFactory to use for building query cache handlers.
|
||||
|
@ -461,7 +473,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#QUERY_CACHE_FACTORY
|
||||
*/
|
||||
public SessionFactoryBuilder applyQueryCacheFactory(QueryCacheFactory factory);
|
||||
SessionFactoryBuilder applyQueryCacheFactory(QueryCacheFactory factory);
|
||||
|
||||
/**
|
||||
* Apply a prefix to prepended to all cache region names for this SessionFactory.
|
||||
|
@ -472,7 +484,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#CACHE_REGION_PREFIX
|
||||
*/
|
||||
public SessionFactoryBuilder applyCacheRegionPrefix(String prefix);
|
||||
SessionFactoryBuilder applyCacheRegionPrefix(String prefix);
|
||||
|
||||
/**
|
||||
* By default, Hibernate will always just push data into the cache without first checking
|
||||
|
@ -492,7 +504,7 @@ public interface SessionFactoryBuilder {
|
|||
* @see org.hibernate.cfg.AvailableSettings#USE_MINIMAL_PUTS
|
||||
* @see org.hibernate.cache.spi.RegionFactory#isMinimalPutsEnabledByDefault()
|
||||
*/
|
||||
public SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled);
|
||||
SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled);
|
||||
|
||||
/**
|
||||
* By default, Hibernate stores data in the cache in its own optimized format. However,
|
||||
|
@ -506,7 +518,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_STRUCTURED_CACHE
|
||||
*/
|
||||
public SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled);
|
||||
SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled);
|
||||
|
||||
/**
|
||||
* Generally, Hibernate will extract the information from an entity and put that
|
||||
|
@ -523,7 +535,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_DIRECT_REFERENCE_CACHE_ENTRIES
|
||||
*/
|
||||
public SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled);
|
||||
SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled);
|
||||
|
||||
/**
|
||||
* When using bi-directional many-to-one associations and caching the one-to-many side
|
||||
|
@ -540,7 +552,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#AUTO_EVICT_COLLECTION_CACHE
|
||||
*/
|
||||
public SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(boolean enabled);
|
||||
SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(boolean enabled);
|
||||
|
||||
/**
|
||||
* Specifies the maximum number of statements to batch together in a JDBC batch for
|
||||
|
@ -554,7 +566,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#STATEMENT_BATCH_SIZE
|
||||
*/
|
||||
public SessionFactoryBuilder applyJdbcBatchSize(int size);
|
||||
SessionFactoryBuilder applyJdbcBatchSize(int size);
|
||||
|
||||
/**
|
||||
* This setting controls whether versioned entities will be included in JDBC batching. The reason
|
||||
|
@ -567,7 +579,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#BATCH_VERSIONED_DATA
|
||||
*/
|
||||
public SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled);
|
||||
SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled);
|
||||
|
||||
/**
|
||||
* Should scrollable results be supported in queries? We ask the JDBC driver whether it
|
||||
|
@ -581,7 +593,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_SCROLLABLE_RESULTSET
|
||||
*/
|
||||
public SessionFactoryBuilder applyScrollableResultsSupport(boolean enabled);
|
||||
SessionFactoryBuilder applyScrollableResultsSupport(boolean enabled);
|
||||
|
||||
/**
|
||||
* Hibernate currently accesses results from the JDBC ResultSet by name. This is known
|
||||
|
@ -596,7 +608,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#WRAP_RESULT_SETS
|
||||
*/
|
||||
public SessionFactoryBuilder applyResultSetsWrapping(boolean enabled);
|
||||
SessionFactoryBuilder applyResultSetsWrapping(boolean enabled);
|
||||
|
||||
/**
|
||||
* Should JDBC {@link java.sql.PreparedStatement#getGeneratedKeys()} feature be used for
|
||||
|
@ -609,7 +621,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_GET_GENERATED_KEYS
|
||||
*/
|
||||
public SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled);
|
||||
SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled);
|
||||
|
||||
/**
|
||||
* Apply a fetch size to the JDBC driver for fetching results.
|
||||
|
@ -621,7 +633,7 @@ public interface SessionFactoryBuilder {
|
|||
* @see org.hibernate.cfg.AvailableSettings#USE_GET_GENERATED_KEYS
|
||||
* @see java.sql.Statement#setFetchSize(int)
|
||||
*/
|
||||
public SessionFactoryBuilder applyJdbcFetchSize(int size);
|
||||
SessionFactoryBuilder applyJdbcFetchSize(int size);
|
||||
|
||||
/**
|
||||
* Apply the specified handling mode for JDBC connections
|
||||
|
@ -660,7 +672,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_SQL_COMMENTS
|
||||
*/
|
||||
public SessionFactoryBuilder applySqlComments(boolean enabled);
|
||||
SessionFactoryBuilder applySqlComments(boolean enabled);
|
||||
|
||||
/**
|
||||
* Apply a SQLFunction to the underlying {@link org.hibernate.dialect.function.SQLFunctionRegistry}.
|
||||
|
@ -673,7 +685,7 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionFactoryBuilder applySqlFunction(String registrationName, SQLFunction sqlFunction);
|
||||
SessionFactoryBuilder applySqlFunction(String registrationName, SQLFunction sqlFunction);
|
||||
|
||||
/**
|
||||
* Allows unwrapping this builder as another, more specific type.
|
||||
|
@ -683,12 +695,12 @@ public interface SessionFactoryBuilder {
|
|||
*
|
||||
* @return The unwrapped builder.
|
||||
*/
|
||||
public <T extends SessionFactoryBuilder> T unwrap(Class<T> type);
|
||||
<T extends SessionFactoryBuilder> T unwrap(Class<T> type);
|
||||
|
||||
/**
|
||||
* After all options have been set, build the SessionFactory.
|
||||
*
|
||||
* @return The built SessionFactory.
|
||||
*/
|
||||
public SessionFactory build();
|
||||
SessionFactory build();
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ import org.hibernate.id.factory.IdentifierGeneratorFactory;
|
|||
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.NamedQueryRepository;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.mapping.Collection;
|
||||
|
@ -97,6 +96,7 @@ import org.hibernate.mapping.RootClass;
|
|||
import org.hibernate.mapping.SimpleValue;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.UniqueKey;
|
||||
import org.hibernate.query.spi.NamedQueryRepository;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
|
||||
/**
|
||||
|
@ -1567,7 +1567,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
|||
|
||||
|
||||
/**
|
||||
* Ugh! But we need this done before we ask Envers to produce its entities.
|
||||
* Ugh! But we need this done beforeQuery we ask Envers to produce its entities.
|
||||
*/
|
||||
public void processSecondPasses(MetadataBuildingContext buildingContext) {
|
||||
inSecondPass = true;
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.hibernate.engine.spi.NamedQueryDefinition;
|
|||
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
|
||||
import org.hibernate.id.factory.IdentifierGeneratorFactory;
|
||||
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
|
||||
import org.hibernate.internal.NamedQueryRepository;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.Collection;
|
||||
|
@ -47,6 +46,7 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.procedure.ProcedureCallMemento;
|
||||
import org.hibernate.query.spi.NamedQueryRepository;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
final SessionFactoryBuilder returnedBuilder = discoveredBuilderFactory.getSessionFactoryBuilder( this, defaultBuilder );
|
||||
if ( returnedBuilder != null ) {
|
||||
if ( activeFactoryNames == null ) {
|
||||
activeFactoryNames = new ArrayList<String>();
|
||||
activeFactoryNames = new ArrayList<>();
|
||||
}
|
||||
activeFactoryNames.add( discoveredBuilderFactory.getClass().getName() );
|
||||
builder = returnedBuilder;
|
||||
|
@ -292,7 +292,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
|
||||
@Override
|
||||
public java.util.Collection<Table> collectTableMappings() {
|
||||
ArrayList<Table> tables = new ArrayList<Table>();
|
||||
ArrayList<Table> tables = new ArrayList<>();
|
||||
for ( Namespace namespace : database.getNamespaces() ) {
|
||||
tables.addAll( namespace.getTables() );
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
}
|
||||
|
||||
public Map<String, ProcedureCallMemento> buildProcedureCallMementos(SessionFactoryImpl sessionFactory) {
|
||||
final Map<String, ProcedureCallMemento> rtn = new HashMap<String, ProcedureCallMemento>();
|
||||
final Map<String, ProcedureCallMemento> rtn = new HashMap<>();
|
||||
if ( namedProcedureCallMap != null ) {
|
||||
for ( NamedProcedureCallDefinition procedureCallDefinition : namedProcedureCallMap.values() ) {
|
||||
rtn.put(
|
||||
|
@ -337,8 +337,8 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
@Override
|
||||
public Set<MappedSuperclass> getMappedSuperclassMappingsCopy() {
|
||||
return mappedSuperclassMap == null
|
||||
? Collections.<MappedSuperclass>emptySet()
|
||||
: new HashSet<MappedSuperclass>( mappedSuperclassMap.values() );
|
||||
? Collections.emptySet()
|
||||
: new HashSet<>( mappedSuperclassMap.values() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
|||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
import org.hibernate.tuple.entity.EntityTuplizerFactory;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.hibernate.cfg.AvailableSettings.ACQUIRE_CONNECTIONS;
|
||||
|
@ -88,6 +89,7 @@ import static org.hibernate.cfg.AvailableSettings.QUERY_SUBSTITUTIONS;
|
|||
import static org.hibernate.cfg.AvailableSettings.RELEASE_CONNECTIONS;
|
||||
import static org.hibernate.cfg.AvailableSettings.SESSION_FACTORY_NAME;
|
||||
import static org.hibernate.cfg.AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI;
|
||||
import static org.hibernate.cfg.AvailableSettings.SESSION_SCOPED_INTERCEPTOR;
|
||||
import static org.hibernate.cfg.AvailableSettings.STATEMENT_BATCH_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.STATEMENT_FETCH_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.STATEMENT_INSPECTOR;
|
||||
|
@ -190,6 +192,12 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStatelessInterceptor(Class<? extends Interceptor> statelessInterceptorClass) {
|
||||
this.options.statelessInterceptorClass = statelessInterceptorClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStatementInspector(StatementInspector statementInspector) {
|
||||
this.options.statementInspector = statementInspector;
|
||||
|
@ -496,13 +504,14 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
// Statistics/Interceptor/observers
|
||||
private boolean statisticsEnabled;
|
||||
private Interceptor interceptor;
|
||||
private Class<? extends Interceptor> statelessInterceptorClass;
|
||||
private StatementInspector statementInspector;
|
||||
private List<SessionFactoryObserver> sessionFactoryObserverList = new ArrayList<SessionFactoryObserver>();
|
||||
private List<SessionFactoryObserver> sessionFactoryObserverList = new ArrayList<>();
|
||||
private BaselineSessionEventsListenerBuilder baselineSessionEventsListenerBuilder; // not exposed on builder atm
|
||||
|
||||
// persistence behavior
|
||||
private CustomEntityDirtinessStrategy customEntityDirtinessStrategy;
|
||||
private List<EntityNameResolver> entityNameResolvers = new ArrayList<EntityNameResolver>();
|
||||
private List<EntityNameResolver> entityNameResolvers = new ArrayList<>();
|
||||
private EntityNotFoundDelegate entityNotFoundDelegate;
|
||||
private boolean identifierRollbackEnabled;
|
||||
private EntityMode defaultEntityMode;
|
||||
|
@ -587,6 +596,17 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
configurationSettings.get( INTERCEPTOR ),
|
||||
EmptyInterceptor.INSTANCE
|
||||
);
|
||||
|
||||
final Object statelessInterceptorSetting = configurationSettings.get( SESSION_SCOPED_INTERCEPTOR );
|
||||
if ( statelessInterceptorSetting instanceof Class ) {
|
||||
this.statelessInterceptorClass = (Class<? extends Interceptor>) statelessInterceptorSetting;
|
||||
}
|
||||
else {
|
||||
this.statelessInterceptorClass = strategySelector.selectStrategyImplementor(
|
||||
Interceptor.class,
|
||||
statelessInterceptorSetting.toString()
|
||||
);
|
||||
}
|
||||
this.statementInspector = strategySelector.resolveStrategy(
|
||||
StatementInspector.class,
|
||||
configurationSettings.get( STATEMENT_INSPECTOR )
|
||||
|
@ -782,6 +802,11 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
return interceptor == null ? EmptyInterceptor.INSTANCE : interceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Interceptor> getStatelessInterceptorImplementor() {
|
||||
return statelessInterceptorClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatementInspector getStatementInspector() {
|
||||
return statementInspector;
|
||||
|
@ -1058,6 +1083,11 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
return options.getInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Interceptor> getStatelessInterceptorImplementor() {
|
||||
return options.getStatelessInterceptorImplementor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatementInspector getStatementInspector() {
|
||||
return options.getStatementInspector();
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.boot.internal;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EntityMode;
|
||||
|
@ -59,6 +58,7 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
|
|||
// Statistics/Interceptor/observers
|
||||
private final boolean statisticsEnabled;
|
||||
private final Interceptor interceptor;
|
||||
private Class<? extends Interceptor> statelessInterceptorClass;
|
||||
private final StatementInspector statementInspector;
|
||||
private final SessionFactoryObserver[] sessionFactoryObserverList;
|
||||
private final BaselineSessionEventsListenerBuilder baselineSessionEventsListenerBuilder; // not exposed on builder atm
|
||||
|
@ -133,6 +133,7 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
|
|||
|
||||
this.statisticsEnabled = state.isStatisticsEnabled();
|
||||
this.interceptor = state.getInterceptor();
|
||||
this.statelessInterceptorClass = state.getStatelessInterceptorImplementor();
|
||||
this.statementInspector = state.getStatementInspector();
|
||||
this.sessionFactoryObserverList = state.getSessionFactoryObservers();
|
||||
this.baselineSessionEventsListenerBuilder = state.getBaselineSessionEventsListenerBuilder();
|
||||
|
@ -229,6 +230,11 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
|
|||
return interceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Interceptor> getStatelessInterceptorImplementor() {
|
||||
return statelessInterceptorClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatementInspector getStatementInspector() {
|
||||
return statementInspector;
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.boot.internal;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EntityMode;
|
||||
|
@ -55,6 +54,8 @@ public interface SessionFactoryOptionsState {
|
|||
|
||||
Interceptor getInterceptor();
|
||||
|
||||
Class<? extends Interceptor> getStatelessInterceptorImplementor();
|
||||
|
||||
StatementInspector getStatementInspector();
|
||||
|
||||
SessionFactoryObserver[] getSessionFactoryObservers();
|
||||
|
@ -150,5 +151,4 @@ public interface SessionFactoryOptionsState {
|
|||
Map<String, SQLFunction> getCustomSqlFunctionMap();
|
||||
|
||||
boolean isPreferUserTransaction();
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ import org.hibernate.HibernateException;
|
|||
* JAXB marshalling for the FlushMode enum
|
||||
* <p/>
|
||||
* NOTE : The XML schemas define the use of {@code "never"}, which corresponds
|
||||
* to the deprecated {@link FlushMode#NEVER}. Here we will also handle mapping
|
||||
* {@link FlushMode#NEVER} and {@link FlushMode#MANUAL} as equivalent
|
||||
* to the removed FlushMode#NEVER. Here we will also handle mapping
|
||||
* FlushMode#NEVER to FlushMode#MANUAL
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ public class FlushModeConverter {
|
|||
|
||||
// conversely, we want to map MANUAL -> "never" here
|
||||
if ( mode == FlushMode.MANUAL ) {
|
||||
mode = FlushMode.NEVER;
|
||||
return "never";
|
||||
}
|
||||
|
||||
// todo : what to do if the incoming value does not conform to allowed values?
|
||||
|
|
|
@ -162,7 +162,7 @@ public class BufferedXMLEventReader extends BaseXMLEventReader {
|
|||
}
|
||||
|
||||
/**
|
||||
* If reading from the buffer after a {@link #reset()} call an {@link IllegalStateException} will be thrown.
|
||||
* If reading from the buffer afterQuery a {@link #reset()} call an {@link IllegalStateException} will be thrown.
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
|
|
|
@ -19,7 +19,7 @@ import javax.xml.stream.events.XMLEvent;
|
|||
/**
|
||||
* Base class for {@link javax.xml.stream.XMLEventReader}s that want to modify or remove events from the reader stream.
|
||||
* If a {@link javax.xml.stream.events.StartElement} event is removed the subclass's {@link #filterEvent(javax.xml.stream.events.XMLEvent, boolean)} will
|
||||
* not see any events until after the matching {@link javax.xml.stream.events.EndElement} event.
|
||||
* not see any events until afterQuery the matching {@link javax.xml.stream.events.EndElement} event.
|
||||
*
|
||||
* Note, copied from the uPortal project by permission of author. See
|
||||
* https://github.com/Jasig/uPortal/blob/master/uportal-war/src/main/java/org/jasig/portal/xml/stream/FilteringXMLEventReader.java
|
||||
|
|
|
@ -135,7 +135,7 @@ public class MetadataBuildingProcess {
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Set up the processors and start binding
|
||||
// NOTE : this becomes even more simplified after we move purely
|
||||
// NOTE : this becomes even more simplified afterQuery we move purely
|
||||
// to unified model
|
||||
|
||||
final MetadataSourceProcessor processor = new MetadataSourceProcessor() {
|
||||
|
|
|
@ -27,15 +27,15 @@ public interface AuxiliaryDatabaseObject extends Exportable, Serializable {
|
|||
public boolean appliesToDialect(Dialect dialect);
|
||||
|
||||
/**
|
||||
* Defines a simple precedence. Should creation of this auxiliary object happen before creation of
|
||||
* tables? If {@code true}, the auxiliary object creation will happen after any explicit schema creations
|
||||
* but before table/sequence creations; if {@code false}, the auxiliary object creation will happen after
|
||||
* explicit schema creations and after table/sequence creations.
|
||||
* Defines a simple precedence. Should creation of this auxiliary object happen beforeQuery creation of
|
||||
* tables? If {@code true}, the auxiliary object creation will happen afterQuery any explicit schema creations
|
||||
* but beforeQuery table/sequence creations; if {@code false}, the auxiliary object creation will happen afterQuery
|
||||
* explicit schema creations and afterQuery table/sequence creations.
|
||||
*
|
||||
* This precedence is automatically inverted for dropping.
|
||||
*
|
||||
* @return {@code true} indicates this object should be created before tables; {@code false} indicates
|
||||
* it should be created after.
|
||||
* @return {@code true} indicates this object should be created beforeQuery tables; {@code false} indicates
|
||||
* it should be created afterQuery.
|
||||
*/
|
||||
public boolean beforeTablesOnCreation();
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class EntityHierarchyBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
* To be called after all mapping documents have been processed (via {@link #indexMappingDocument})
|
||||
* To be called afterQuery all mapping documents have been processed (via {@link #indexMappingDocument})
|
||||
*
|
||||
* @return The built hierarchies
|
||||
*
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.boot.model.source.internal.hbm;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.jaxb.hbm.internal.ImplicitResultSetMappingDefinition;
|
||||
|
@ -156,7 +156,7 @@ public class NamedQueryBinder {
|
|||
// returns it defines. But binding for those entities may have not been
|
||||
// completed yet. For "normal" ResultSet mappings, this is already handled by
|
||||
// the fact that MetadataSourceProcessor#processResultSetMappings() is called
|
||||
// after all entity hierarchies have been processed. However, here we are in
|
||||
// afterQuery all entity hierarchies have been processed. However, here we are in
|
||||
// the middle of processing named-queries (either top-level or entity-level)
|
||||
// and have no guarantee that any entity bindings we may need here are bound.
|
||||
// So we add the second-pass to bind the implicit resultSet mapping.
|
||||
|
|
|
@ -88,7 +88,7 @@ public class StrategySelectorImpl implements StrategySelector {
|
|||
}
|
||||
}
|
||||
|
||||
// try tp clean up after ourselves...
|
||||
// try tp clean up afterQuery ourselves...
|
||||
if ( namedStrategyImplementorMap.isEmpty() ) {
|
||||
namedStrategyImplementorByStrategyMap.remove( strategy );
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ import org.hibernate.engine.spi.FilterDefinition;
|
|||
import org.hibernate.engine.spi.NamedQueryDefinition;
|
||||
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
|
||||
import org.hibernate.id.factory.IdentifierGeneratorFactory;
|
||||
import org.hibernate.internal.NamedQueryRepository;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.hibernate.mapping.FetchProfile;
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.query.spi.NamedQueryRepository;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
|
|||
|
||||
/**
|
||||
* Contract for contributing to the initialization of MetadataBuilder. Called
|
||||
* immediately after any configuration settings have been applied from
|
||||
* immediately afterQuery any configuration settings have been applied from
|
||||
* {@link org.hibernate.engine.config.spi.ConfigurationService}. Any values specified
|
||||
* here override those. Any values set here can still be overridden explicitly by the user
|
||||
* via the exposed config methods of {@link MetadataBuilder}
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.jboss.jandex.IndexView;
|
|||
/**
|
||||
* Contract for contributing to Metadata (InFlightMetadataCollector).
|
||||
*
|
||||
* This hook occurs just after all processing of all {@link org.hibernate.boot.MetadataSources},
|
||||
* and just before {@link org.hibernate.boot.spi.AdditionalJaxbMappingProducer}.
|
||||
* This hook occurs just afterQuery all processing of all {@link org.hibernate.boot.MetadataSources},
|
||||
* and just beforeQuery {@link org.hibernate.boot.spi.AdditionalJaxbMappingProducer}.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
|
|
|
@ -11,9 +11,9 @@ import java.util.Set;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
import org.hibernate.internal.NamedQueryRepository;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
import org.hibernate.query.spi.NamedQueryRepository;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.boot.spi;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EntityMode;
|
||||
|
@ -79,6 +78,13 @@ public interface SessionFactoryOptions {
|
|||
*/
|
||||
Interceptor getInterceptor();
|
||||
|
||||
/**
|
||||
* Get the interceptor to use by default for all sessions opened from this factory.
|
||||
*
|
||||
* @return The interceptor to use factory wide. May be {@code null}
|
||||
*/
|
||||
Class<? extends Interceptor> getStatelessInterceptorImplementor();
|
||||
|
||||
StatementInspector getStatementInspector();
|
||||
|
||||
SessionFactoryObserver[] getSessionFactoryObservers();
|
||||
|
|
|
@ -38,7 +38,7 @@ public final class SortedFieldTracker implements DirtyTracker {
|
|||
insert = middle;
|
||||
}
|
||||
else if( compare < 0 ) {
|
||||
// top half: lower bound in (middle + 1) and insert position after middle
|
||||
// top half: lower bound in (middle + 1) and insert position afterQuery middle
|
||||
insert = low = middle + 1;
|
||||
}
|
||||
else {
|
||||
|
@ -62,7 +62,7 @@ public final class SortedFieldTracker implements DirtyTracker {
|
|||
high = middle - 1;
|
||||
}
|
||||
else if( compare < 0 ) {
|
||||
// top half: lower bound in (middle + 1) and insert position after middle
|
||||
// top half: lower bound in (middle + 1) and insert position afterQuery middle
|
||||
low = middle + 1;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.bytecode.enhance.spi;
|
|||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* Contract for controlling how lazy properties get initialized.
|
||||
|
@ -46,6 +46,6 @@ public interface LazyPropertyInitializer {
|
|||
*
|
||||
* @return ?
|
||||
*/
|
||||
Object initializeLazyProperty(String fieldName, Object entity, SessionImplementor session);
|
||||
Object initializeLazyProperty(String fieldName, Object entity, SharedSessionContractImplementor session);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,9 +10,8 @@ import java.util.Locale;
|
|||
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LazyInitializationException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.SessionFactoryRegistry;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -24,13 +23,13 @@ public class Helper {
|
|||
private static final Logger log = Logger.getLogger( Helper.class );
|
||||
|
||||
interface Consumer {
|
||||
SessionImplementor getLinkedSession();
|
||||
SharedSessionContractImplementor getLinkedSession();
|
||||
boolean allowLoadOutsideTransaction();
|
||||
String getSessionFactoryUuid();
|
||||
}
|
||||
|
||||
interface LazyInitializationWork<T> {
|
||||
T doWork(SessionImplementor session, boolean isTemporarySession);
|
||||
T doWork(SharedSessionContractImplementor session, boolean isTemporarySession);
|
||||
|
||||
// informational details
|
||||
String getEntityName();
|
||||
|
@ -45,7 +44,7 @@ public class Helper {
|
|||
}
|
||||
|
||||
public <T> T performWork(LazyInitializationWork<T> lazyInitializationWork) {
|
||||
SessionImplementor session = consumer.getLinkedSession();
|
||||
SharedSessionContractImplementor session = consumer.getLinkedSession();
|
||||
|
||||
boolean isTempSession = false;
|
||||
boolean isJta = false;
|
||||
|
@ -89,7 +88,7 @@ public class Helper {
|
|||
// be created even if a current session and transaction are
|
||||
// open (ex: session.clear() was used). We must prevent
|
||||
// multiple transactions.
|
||||
( (Session) session ).beginTransaction();
|
||||
session.beginTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +101,7 @@ public class Helper {
|
|||
try {
|
||||
// Commit the JDBC transaction is we started one.
|
||||
if ( !isJta ) {
|
||||
( (Session) session ).getTransaction().commit();
|
||||
session.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -114,7 +113,7 @@ public class Helper {
|
|||
|
||||
// Close the just opened temp Session
|
||||
try {
|
||||
( (Session) session ).close();
|
||||
session.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.warn( "Unable to close temporary session used to load lazy collection associated to no session" );
|
||||
|
@ -165,16 +164,16 @@ public class Helper {
|
|||
throw new LazyInitializationException( message );
|
||||
}
|
||||
|
||||
private SessionImplementor openTemporarySessionForLoading(LazyInitializationWork lazyInitializationWork) {
|
||||
private SharedSessionContractImplementor openTemporarySessionForLoading(LazyInitializationWork lazyInitializationWork) {
|
||||
if ( consumer.getSessionFactoryUuid() == null ) {
|
||||
throwLazyInitializationException( Cause.NO_SF_UUID, lazyInitializationWork );
|
||||
}
|
||||
|
||||
final SessionFactoryImplementor sf = (SessionFactoryImplementor)
|
||||
SessionFactoryRegistry.INSTANCE.getSessionFactory( consumer.getSessionFactoryUuid() );
|
||||
final SessionImplementor session = (SessionImplementor) sf.openSession();
|
||||
final SharedSessionContractImplementor session = (SharedSessionContractImplementor) sf.openSession();
|
||||
session.getPersistenceContext().setDefaultReadOnly( true );
|
||||
session.setFlushMode( FlushMode.MANUAL );
|
||||
session.setHibernateFlushMode( FlushMode.MANUAL );
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.hibernate.bytecode.enhance.spi.interceptor.Helper.Consumer;
|
|||
import org.hibernate.bytecode.enhance.spi.interceptor.Helper.LazyInitializationWork;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||
import org.hibernate.engine.spi.SelfDirtinessTracker;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
|
@ -42,14 +42,14 @@ public class LazyAttributeLoadingInterceptor
|
|||
|
||||
private Set<String> initializedLazyFields;
|
||||
|
||||
private transient SessionImplementor session;
|
||||
private transient SharedSessionContractImplementor session;
|
||||
private boolean allowLoadOutsideTransaction;
|
||||
private String sessionFactoryUuid;
|
||||
|
||||
public LazyAttributeLoadingInterceptor(
|
||||
String entityName,
|
||||
Set<String> lazyFields,
|
||||
SessionImplementor session) {
|
||||
SharedSessionContractImplementor session) {
|
||||
this.entityName = entityName;
|
||||
this.lazyFields = lazyFields;
|
||||
|
||||
|
@ -76,8 +76,8 @@ public class LazyAttributeLoadingInterceptor
|
|||
return new Helper( this ).performWork(
|
||||
new LazyInitializationWork() {
|
||||
@Override
|
||||
public Object doWork(SessionImplementor session, boolean isTemporarySession) {
|
||||
final EntityPersister persister = session.getFactory().getEntityPersister( getEntityName() );
|
||||
public Object doWork(SharedSessionContractImplementor session, boolean isTemporarySession) {
|
||||
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( getEntityName() );
|
||||
|
||||
if ( isTemporarySession ) {
|
||||
final Serializable id = persister.getIdentifier( target, null );
|
||||
|
@ -125,7 +125,7 @@ public class LazyAttributeLoadingInterceptor
|
|||
);
|
||||
}
|
||||
|
||||
public final void setSession(SessionImplementor session) {
|
||||
public final void setSession(SharedSessionContractImplementor session) {
|
||||
this.session = session;
|
||||
if ( session != null && !allowLoadOutsideTransaction ) {
|
||||
this.allowLoadOutsideTransaction = session.getFactory().getSessionFactoryOptions().isInitializeLazyStateOutsideTransactionsEnabled();
|
||||
|
@ -305,7 +305,7 @@ public class LazyAttributeLoadingInterceptor
|
|||
}
|
||||
|
||||
@Override
|
||||
public SessionImplementor getLinkedSession() {
|
||||
public SharedSessionContractImplementor getLinkedSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ByteCodeHelper {
|
|||
final byte[] temp = new byte[ classBytes.length + buffer.length ];
|
||||
// copy any previously read bytes into the temp array
|
||||
System.arraycopy( classBytes, 0, temp, 0, classBytes.length );
|
||||
// copy the just read bytes into the temp array (after the previously read)
|
||||
// copy the just read bytes into the temp array (afterQuery the previously read)
|
||||
System.arraycopy( buffer, 0, temp, classBytes.length, buffer.length );
|
||||
classBytes = temp;
|
||||
// read the next set of bytes into buffer
|
||||
|
@ -61,7 +61,7 @@ public class ByteCodeHelper {
|
|||
final byte[] temp = new byte[ classBytes.length + r ];
|
||||
// copy any previously read bytes into the temp array
|
||||
System.arraycopy( classBytes, 0, temp, 0, classBytes.length );
|
||||
// copy the just read bytes into the temp array (after the previously read)
|
||||
// copy the just read bytes into the temp array (afterQuery the previously read)
|
||||
System.arraycopy( buffer, 0, temp, classBytes.length, r );
|
||||
classBytes = temp;
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.bytecode.spi;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
|
||||
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributesMetadata;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* Encapsulates bytecode enhancement information about a particular entity.
|
||||
|
@ -47,7 +45,7 @@ public interface BytecodeEnhancementMetadata {
|
|||
*/
|
||||
LazyAttributeLoadingInterceptor injectInterceptor(
|
||||
Object entity,
|
||||
SessionImplementor session) throws NotInstrumentedException;
|
||||
SharedSessionContractImplementor session) throws NotInstrumentedException;
|
||||
|
||||
/**
|
||||
* Extract the field interceptor instance from the enhanced entity.
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.security.ProtectionDomain;
|
|||
* to the PersistenceUnitInfo.addTransformer method.
|
||||
* The supplied transformer instance will get called to transform
|
||||
* entity class files when they are loaded and redefined. The transformation
|
||||
* occurs before the class is defined by the JVM
|
||||
* occurs beforeQuery the class is defined by the JVM
|
||||
*
|
||||
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
|
||||
* @author Emmanuel Bernard
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.boot.Metadata;
|
|||
import org.hibernate.cache.spi.access.SoftLock;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
|
@ -82,11 +82,11 @@ public class CollectionCacheInvalidator
|
|||
}
|
||||
|
||||
private void integrate(SessionFactoryServiceRegistry serviceRegistry, SessionFactoryImplementor sessionFactory) {
|
||||
if ( !sessionFactory.getSettings().isAutoEvictCollectionCache() ) {
|
||||
if ( !sessionFactory.getSessionFactoryOptions().isAutoEvictCollectionCache() ) {
|
||||
// feature is disabled
|
||||
return;
|
||||
}
|
||||
if ( !sessionFactory.getSettings().isSecondLevelCacheEnabled() ) {
|
||||
if ( !sessionFactory.getSessionFactoryOptions().isSecondLevelCacheEnabled() ) {
|
||||
// Nothing to do, if caching is disabled
|
||||
return;
|
||||
}
|
||||
|
@ -100,12 +100,12 @@ public class CollectionCacheInvalidator
|
|||
try {
|
||||
SessionFactoryImplementor factory = persister.getFactory();
|
||||
|
||||
Set<String> collectionRoles = factory.getCollectionRolesByEntityParticipant( persister.getEntityName() );
|
||||
Set<String> collectionRoles = factory.getMetamodel().getCollectionRolesByEntityParticipant( persister.getEntityName() );
|
||||
if ( collectionRoles == null || collectionRoles.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
for ( String role : collectionRoles ) {
|
||||
final CollectionPersister collectionPersister = factory.getCollectionPersister( role );
|
||||
final CollectionPersister collectionPersister = factory.getMetamodel().collectionPersister( role );
|
||||
if ( !collectionPersister.hasCache() ) {
|
||||
// ignore collection if no caching is used
|
||||
continue;
|
||||
|
@ -137,11 +137,8 @@ public class CollectionCacheInvalidator
|
|||
else {
|
||||
LOG.debug( "Evict CollectionRegion " + role );
|
||||
final SoftLock softLock = collectionPersister.getCacheAccessStrategy().lockRegion();
|
||||
session.getActionQueue().registerProcess( new AfterTransactionCompletionProcess() {
|
||||
@Override
|
||||
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
|
||||
collectionPersister.getCacheAccessStrategy().unlockRegion( softLock );
|
||||
}
|
||||
session.getActionQueue().registerProcess( (success, session1) -> {
|
||||
collectionPersister.getCacheAccessStrategy().unlockRegion( softLock );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
@ -160,8 +157,7 @@ public class CollectionCacheInvalidator
|
|||
if ( obj != null ) {
|
||||
id = session.getContextEntityIdentifier( obj );
|
||||
if ( id == null ) {
|
||||
id = session.getSessionFactory().getClassMetadata( obj.getClass() )
|
||||
.getIdentifier( obj, session );
|
||||
id = session.getSessionFactory().getMetamodel().entityPersister( obj.getClass() ).getIdentifier( obj, session );
|
||||
}
|
||||
}
|
||||
return id;
|
||||
|
@ -186,7 +182,7 @@ public class CollectionCacheInvalidator
|
|||
CollectionPersister persister,
|
||||
PersistentCollection collection,
|
||||
Serializable key,
|
||||
SessionImplementor session) {
|
||||
SharedSessionContractImplementor session) {
|
||||
super( persister, collection, key, session );
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.cache.internal;
|
|||
import org.hibernate.cache.spi.CacheKeysFactory;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
|
@ -48,7 +49,7 @@ public class DefaultCacheKeysFactory {
|
|||
return new OldCacheKeyImplementation( id, persister.getIdentifierType(), persister.getRootEntityName(), tenantIdentifier, factory );
|
||||
}
|
||||
|
||||
public static Object createNaturalIdKey(Object[] naturalIdValues, EntityPersister persister, SessionImplementor session) {
|
||||
public static Object createNaturalIdKey(Object[] naturalIdValues, EntityPersister persister, SharedSessionContractImplementor session) {
|
||||
return new OldNaturalIdCacheKey( naturalIdValues, persister.getPropertyTypes(), persister.getNaturalIdentifierProperties(), persister.getRootEntityName(), session );
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,10 @@ public class NoCachingRegionFactory implements RegionFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
throws CacheException {
|
||||
public CollectionRegion buildCollectionRegion(
|
||||
String regionName,
|
||||
Properties properties,
|
||||
CacheDataDescription metadata) throws CacheException {
|
||||
throw new NoCacheRegionFactoryAvailableException();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.io.Serializable;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.internal.util.compare.EqualsHelper;
|
||||
import org.hibernate.type.EntityType;
|
||||
|
@ -48,7 +48,7 @@ public class OldNaturalIdCacheKey implements Serializable {
|
|||
public OldNaturalIdCacheKey(
|
||||
final Object[] naturalIdValues,
|
||||
Type[] propertyTypes, int[] naturalIdPropertyIndexes, final String entityName,
|
||||
final SessionImplementor session) {
|
||||
final SharedSessionContractImplementor session) {
|
||||
|
||||
this.entityName = entityName;
|
||||
this.tenantId = session.getTenantIdentifier();
|
||||
|
@ -84,13 +84,14 @@ public class OldNaturalIdCacheKey implements Serializable {
|
|||
}
|
||||
|
||||
private void initTransients() {
|
||||
this.toString = new ValueHolder<String>(
|
||||
this.toString = new ValueHolder<>(
|
||||
new ValueHolder.DeferredInitializer<String>() {
|
||||
@Override
|
||||
public String initialize() {
|
||||
//Complex toString is needed as naturalIds for entities are not simply based on a single value like primary keys
|
||||
//the only same way to differentiate the keys is to included the disassembled values in the string.
|
||||
final StringBuilder toStringBuilder = new StringBuilder().append( entityName ).append( "##NaturalId[" );
|
||||
final StringBuilder toStringBuilder = new StringBuilder().append( entityName ).append(
|
||||
"##NaturalId[" );
|
||||
for ( int i = 0; i < naturalIdValues.length; i++ ) {
|
||||
toStringBuilder.append( naturalIdValues[i] );
|
||||
if ( i + 1 < naturalIdValues.length ) {
|
||||
|
|
|
@ -22,13 +22,13 @@ import org.hibernate.cache.spi.QueryKey;
|
|||
import org.hibernate.cache.spi.QueryResultsRegion;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.cache.spi.UpdateTimestampsCache;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.CacheImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeHelper;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* The standard implementation of the Hibernate QueryCache interface. This
|
||||
* implementation is very good at recognizing stale query results and
|
||||
|
@ -39,16 +39,13 @@ import org.jboss.logging.Logger;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class StandardQueryCache implements QueryCache {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
||||
CoreMessageLogger.class,
|
||||
StandardQueryCache.class.getName()
|
||||
);
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( StandardQueryCache.class );
|
||||
|
||||
private static final boolean DEBUGGING = LOG.isDebugEnabled();
|
||||
private static final boolean TRACING = LOG.isTraceEnabled();
|
||||
|
||||
private QueryResultsRegion cacheRegion;
|
||||
private UpdateTimestampsCache updateTimestampsCache;
|
||||
private final QueryResultsRegion cacheRegion;
|
||||
private final UpdateTimestampsCache updateTimestampsCache;
|
||||
|
||||
/**
|
||||
* Constructs a StandardQueryCache instance
|
||||
|
@ -80,6 +77,12 @@ public class StandardQueryCache implements QueryCache {
|
|||
this.updateTimestampsCache = updateTimestampsCache;
|
||||
}
|
||||
|
||||
public StandardQueryCache(QueryResultsRegion cacheRegion, CacheImplementor cacheManager) {
|
||||
LOG.startingQueryCache( cacheRegion.getName() );
|
||||
this.cacheRegion = cacheRegion;
|
||||
this.updateTimestampsCache = cacheManager.getUpdateTimestampsCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultsRegion getRegion() {
|
||||
return cacheRegion;
|
||||
|
@ -107,7 +110,7 @@ public class StandardQueryCache implements QueryCache {
|
|||
final Type[] returnTypes,
|
||||
final List result,
|
||||
final boolean isNaturalKeyLookup,
|
||||
final SessionImplementor session) throws HibernateException {
|
||||
final SharedSessionContractImplementor session) throws HibernateException {
|
||||
if ( isNaturalKeyLookup && result.isEmpty() ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -150,7 +153,7 @@ public class StandardQueryCache implements QueryCache {
|
|||
final Type[] returnTypes,
|
||||
final boolean isNaturalKeyLookup,
|
||||
final Set<Serializable> spaces,
|
||||
final SessionImplementor session) throws HibernateException {
|
||||
final SharedSessionContractImplementor session) throws HibernateException {
|
||||
if ( DEBUGGING ) {
|
||||
LOG.debugf( "Checking cached query results in region: %s", cacheRegion.getName() );
|
||||
}
|
||||
|
@ -196,7 +199,7 @@ public class StandardQueryCache implements QueryCache {
|
|||
final boolean isNaturalKeyLookup,
|
||||
boolean singleResult,
|
||||
final Type[] returnTypes,
|
||||
final SessionImplementor session) throws HibernateException {
|
||||
final SharedSessionContractImplementor session) throws HibernateException {
|
||||
|
||||
try {
|
||||
final List result = new ArrayList( cacheable.size() - 1 );
|
||||
|
@ -235,7 +238,7 @@ public class StandardQueryCache implements QueryCache {
|
|||
}
|
||||
}
|
||||
|
||||
private List getCachedResults(QueryKey key, SessionImplementor session) {
|
||||
private List getCachedResults(QueryKey key, SharedSessionContractImplementor session) {
|
||||
List cacheable = null;
|
||||
try {
|
||||
session.getEventListenerManager().cacheGetStart();
|
||||
|
@ -248,7 +251,7 @@ public class StandardQueryCache implements QueryCache {
|
|||
}
|
||||
|
||||
|
||||
protected boolean isUpToDate(Set<Serializable> spaces, Long timestamp, SessionImplementor session) {
|
||||
protected boolean isUpToDate(Set<Serializable> spaces, Long timestamp, SharedSessionContractImplementor session) {
|
||||
if ( DEBUGGING ) {
|
||||
LOG.debugf( "Checking query spaces are up-to-date: %s", spaces );
|
||||
}
|
||||
|
|
|
@ -6,13 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.cache.internal;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cache.spi.QueryCache;
|
||||
import org.hibernate.cache.spi.QueryCacheFactory;
|
||||
import org.hibernate.cache.spi.UpdateTimestampsCache;
|
||||
import org.hibernate.cache.spi.QueryResultsRegion;
|
||||
import org.hibernate.engine.spi.CacheImplementor;
|
||||
|
||||
/**
|
||||
* Standard Hibernate implementation of the QueryCacheFactory interface. Returns instances of
|
||||
|
@ -25,11 +22,7 @@ public class StandardQueryCacheFactory implements QueryCacheFactory {
|
|||
public static final StandardQueryCacheFactory INSTANCE = new StandardQueryCacheFactory();
|
||||
|
||||
@Override
|
||||
public QueryCache getQueryCache(
|
||||
final String regionName,
|
||||
final UpdateTimestampsCache updateTimestampsCache,
|
||||
final SessionFactoryOptions settings,
|
||||
final Properties props) throws HibernateException {
|
||||
return new StandardQueryCache(settings, props, updateTimestampsCache, regionName);
|
||||
public QueryCache buildQueryCache(QueryResultsRegion region, CacheImplementor cacheManager) {
|
||||
return new StandardQueryCache( region, cacheManager );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,5 +26,5 @@ public interface EntityRegion extends TransactionalDataRegion {
|
|||
* for the requested type of access.
|
||||
* @throws org.hibernate.cache.CacheException Usually indicates mis-configuration.
|
||||
*/
|
||||
public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException;
|
||||
EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
package org.hibernate.cache.spi;
|
||||
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* Contract for general-purpose cache regions.
|
||||
|
@ -19,24 +19,25 @@ public interface GeneralDataRegion extends Region {
|
|||
/**
|
||||
* Get an item from the cache.
|
||||
*
|
||||
*
|
||||
* @param session
|
||||
* @param key The key of the item to be retrieved.
|
||||
*
|
||||
* @return the cached object or <tt>null</tt>
|
||||
*
|
||||
* @throws org.hibernate.cache.CacheException Indicates a problem accessing the item or region.
|
||||
*/
|
||||
public Object get(SessionImplementor session, Object key) throws CacheException;
|
||||
Object get(SharedSessionContractImplementor session, Object key) throws CacheException;
|
||||
|
||||
/**
|
||||
* Put an item into the cache.
|
||||
*
|
||||
*
|
||||
* @param session
|
||||
* @param key The key under which to cache the item.
|
||||
* @param value The item to cache.
|
||||
*
|
||||
* @throws CacheException Indicates a problem accessing the region.
|
||||
*/
|
||||
public void put(SessionImplementor session, Object key, Object value) throws CacheException;
|
||||
void put(SharedSessionContractImplementor session, Object key, Object value) throws CacheException;
|
||||
|
||||
/**
|
||||
* Evict an item from the cache immediately (without regard for transaction
|
||||
|
@ -45,7 +46,7 @@ public interface GeneralDataRegion extends Region {
|
|||
* @param key The key of the item to remove
|
||||
* @throws CacheException Indicates a problem accessing the item or region.
|
||||
*/
|
||||
public void evict(Object key) throws CacheException;
|
||||
void evict(Object key) throws CacheException;
|
||||
|
||||
/**
|
||||
* Evict all contents of this particular cache region (without regard for transaction
|
||||
|
@ -53,5 +54,5 @@ public interface GeneralDataRegion extends Region {
|
|||
*
|
||||
* @throws CacheException Indicates problem accessing the region.
|
||||
*/
|
||||
public void evictAll() throws CacheException;
|
||||
void evictAll() throws CacheException;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Set;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ public interface QueryCache {
|
|||
*
|
||||
* @throws CacheException Indicates a problem delegating to the underlying cache.
|
||||
*/
|
||||
public void clear() throws CacheException;
|
||||
void clear() throws CacheException;
|
||||
|
||||
/**
|
||||
* Put a result into the query cache.
|
||||
|
@ -44,7 +44,12 @@ public interface QueryCache {
|
|||
*
|
||||
* @throws HibernateException Indicates a problem delegating to the underlying cache.
|
||||
*/
|
||||
public boolean put(QueryKey key, Type[] returnTypes, List result, boolean isNaturalKeyLookup, SessionImplementor session) throws HibernateException;
|
||||
boolean put(
|
||||
QueryKey key,
|
||||
Type[] returnTypes,
|
||||
List result,
|
||||
boolean isNaturalKeyLookup,
|
||||
SharedSessionContractImplementor session) throws HibernateException;
|
||||
|
||||
/**
|
||||
* Get results from the cache.
|
||||
|
@ -59,18 +64,23 @@ public interface QueryCache {
|
|||
*
|
||||
* @throws HibernateException Indicates a problem delegating to the underlying cache.
|
||||
*/
|
||||
public List get(QueryKey key, Type[] returnTypes, boolean isNaturalKeyLookup, Set<Serializable> spaces, SessionImplementor session) throws HibernateException;
|
||||
List get(
|
||||
QueryKey key,
|
||||
Type[] returnTypes,
|
||||
boolean isNaturalKeyLookup,
|
||||
Set<Serializable> spaces,
|
||||
SharedSessionContractImplementor session) throws HibernateException;
|
||||
|
||||
/**
|
||||
* Destroy the cache.
|
||||
*/
|
||||
public void destroy();
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* The underlying cache factory region being used.
|
||||
*
|
||||
* @return The cache region.
|
||||
*/
|
||||
public QueryResultsRegion getRegion();
|
||||
QueryResultsRegion getRegion();
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.cache.spi;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.engine.spi.CacheImplementor;
|
||||
|
||||
/**
|
||||
* Defines a factory for query cache instances. These factories are responsible for
|
||||
|
@ -20,16 +18,10 @@ public interface QueryCacheFactory {
|
|||
/**
|
||||
* Builds a named query cache.
|
||||
*
|
||||
* @param regionName The cache region name
|
||||
* @param updateTimestampsCache The cache of timestamp values to use to perform up-to-date checks.
|
||||
* @param settings The Hibernate SessionFactory settings.
|
||||
* @param props Any properties.
|
||||
* @param region The cache region
|
||||
* @param cacheManager The CacheImplementor reference.
|
||||
*
|
||||
* @return The cache.
|
||||
*/
|
||||
public QueryCache getQueryCache(
|
||||
String regionName,
|
||||
UpdateTimestampsCache updateTimestampsCache,
|
||||
SessionFactoryOptions settings,
|
||||
Properties props);
|
||||
QueryCache buildQueryCache(QueryResultsRegion region, CacheImplementor cacheManager);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Set;
|
|||
|
||||
import org.hibernate.engine.spi.QueryParameters;
|
||||
import org.hibernate.engine.spi.RowSelection;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.TypedValue;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.internal.util.compare.EqualsHelper;
|
||||
|
@ -55,7 +55,7 @@ public class QueryKey implements Serializable {
|
|||
* @param queryParameters The query parameters
|
||||
* @param filterKeys The keys of any enabled filters.
|
||||
* @param session The current session.
|
||||
* @param customTransformer The result transformer; should be null if data is not transformed before being cached.
|
||||
* @param customTransformer The result transformer; should be null if data is not transformed beforeQuery being cached.
|
||||
*
|
||||
* @return The generate query cache key.
|
||||
*/
|
||||
|
@ -63,7 +63,7 @@ public class QueryKey implements Serializable {
|
|||
String queryString,
|
||||
QueryParameters queryParameters,
|
||||
Set filterKeys,
|
||||
SessionImplementor session,
|
||||
SharedSessionContractImplementor session,
|
||||
CacheableResultTransformer customTransformer) {
|
||||
// disassemble positional parameters
|
||||
final int positionalParameterCount = queryParameters.getPositionalParameterTypes().length;
|
||||
|
|
|
@ -22,7 +22,7 @@ public interface Region {
|
|||
*
|
||||
* @return The region name
|
||||
*/
|
||||
public String getName();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* The "end state" contract of the region's lifecycle. Called
|
||||
|
@ -31,7 +31,7 @@ public interface Region {
|
|||
*
|
||||
* @throws org.hibernate.cache.CacheException Indicates problem shutting down
|
||||
*/
|
||||
public void destroy() throws CacheException;
|
||||
void destroy() throws CacheException;
|
||||
|
||||
/**
|
||||
* Determine whether this region contains data for the given key.
|
||||
|
@ -45,7 +45,7 @@ public interface Region {
|
|||
* @return True if the underlying cache contains corresponding data; false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean contains(Object key);
|
||||
boolean contains(Object key);
|
||||
|
||||
/**
|
||||
* The number of bytes is this cache region currently consuming in memory.
|
||||
|
@ -53,21 +53,21 @@ public interface Region {
|
|||
* @return The number of bytes consumed by this region; -1 if unknown or
|
||||
* unsupported.
|
||||
*/
|
||||
public long getSizeInMemory();
|
||||
long getSizeInMemory();
|
||||
|
||||
/**
|
||||
* The count of entries currently contained in the regions in-memory store.
|
||||
*
|
||||
* @return The count of entries in memory; -1 if unknown or unsupported.
|
||||
*/
|
||||
public long getElementCountInMemory();
|
||||
long getElementCountInMemory();
|
||||
|
||||
/**
|
||||
* The count of entries currently contained in the regions disk store.
|
||||
*
|
||||
* @return The count of entries on disk; -1 if unknown or unsupported.
|
||||
*/
|
||||
public long getElementCountOnDisk();
|
||||
long getElementCountOnDisk();
|
||||
|
||||
/**
|
||||
* Get the contents of this region as a map.
|
||||
|
@ -77,7 +77,7 @@ public interface Region {
|
|||
*
|
||||
* @return The content map.
|
||||
*/
|
||||
public Map toMap();
|
||||
Map toMap();
|
||||
|
||||
/**
|
||||
* Get the next timestamp according to the underlying cache implementor.
|
||||
|
@ -86,7 +86,7 @@ public interface Region {
|
|||
*
|
||||
* @return The next timestamp
|
||||
*/
|
||||
public long nextTimestamp();
|
||||
long nextTimestamp();
|
||||
|
||||
/**
|
||||
* Get a timeout value.
|
||||
|
@ -95,5 +95,5 @@ public interface Region {
|
|||
*
|
||||
* @return The time out value
|
||||
*/
|
||||
public int getTimeout();
|
||||
int getTimeout();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.cache.spi;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
|
@ -38,15 +39,36 @@ public interface RegionFactory extends Service {
|
|||
* @throws org.hibernate.cache.CacheException Indicates problems starting the L2 cache impl;
|
||||
* considered as a sign to stop {@link org.hibernate.SessionFactory}
|
||||
* building.
|
||||
*
|
||||
* @deprecated (since 6.0) use the form accepting map instead.
|
||||
*/
|
||||
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException;
|
||||
@Deprecated
|
||||
void start(SessionFactoryOptions settings, Properties properties) throws CacheException;
|
||||
|
||||
/**
|
||||
* Lifecycle callback to perform any necessary initialization of the
|
||||
* underlying cache implementation(s). Called exactly once during the
|
||||
* construction of a {@link org.hibernate.internal.SessionFactoryImpl}.
|
||||
*
|
||||
* @param settings The settings in effect.
|
||||
* @param configValues The available config values
|
||||
*
|
||||
* @throws org.hibernate.cache.CacheException Indicates problems starting the L2 cache impl;
|
||||
* considered as a sign to stop {@link org.hibernate.SessionFactory}
|
||||
* building.
|
||||
*/
|
||||
default void start(SessionFactoryOptions settings, Map<String, Object> configValues) throws CacheException {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( configValues );
|
||||
start( settings, properties );
|
||||
}
|
||||
|
||||
/**
|
||||
* Lifecycle callback to perform any necessary cleanup of the underlying
|
||||
* cache implementation(s). Called exactly once during
|
||||
* {@link org.hibernate.SessionFactory#close}.
|
||||
*/
|
||||
public void stop();
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* By default should we perform "minimal puts" when using this second
|
||||
|
@ -55,7 +77,7 @@ public interface RegionFactory extends Service {
|
|||
* @return True if "minimal puts" should be performed by default; false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isMinimalPutsEnabledByDefault();
|
||||
boolean isMinimalPutsEnabledByDefault();
|
||||
|
||||
/**
|
||||
* Get the default access type for {@link EntityRegion entity} and
|
||||
|
@ -63,7 +85,7 @@ public interface RegionFactory extends Service {
|
|||
*
|
||||
* @return This factory's default access type.
|
||||
*/
|
||||
public AccessType getDefaultAccessType();
|
||||
AccessType getDefaultAccessType();
|
||||
|
||||
/**
|
||||
* Generate a timestamp.
|
||||
|
@ -73,7 +95,7 @@ public interface RegionFactory extends Service {
|
|||
*
|
||||
* @return The generated timestamp.
|
||||
*/
|
||||
public long nextTimestamp();
|
||||
long nextTimestamp();
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing entity data.
|
||||
|
@ -85,10 +107,31 @@ public interface RegionFactory extends Service {
|
|||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*
|
||||
* @deprecated (since 6.0) use the form taking Map instead
|
||||
*/
|
||||
public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
@Deprecated
|
||||
EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
throws CacheException;
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing entity data.
|
||||
*
|
||||
* @param regionName The name of the region.
|
||||
* @param configValues Available config values.
|
||||
* @param metadata Information regarding the type of data to be cached
|
||||
*
|
||||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*/
|
||||
default EntityRegion buildEntityRegion(String regionName, Map<String,Object> configValues, CacheDataDescription metadata)
|
||||
throws CacheException {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( configValues );
|
||||
return buildEntityRegion( regionName, properties, metadata );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing NaturalId to Primary Key mappings.
|
||||
*
|
||||
|
@ -99,10 +142,31 @@ public interface RegionFactory extends Service {
|
|||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*
|
||||
* @deprecated (since 6.0) use the form accepting a Map instead
|
||||
*/
|
||||
public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
@Deprecated
|
||||
NaturalIdRegion buildNaturalIdRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
throws CacheException;
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing NaturalId to Primary Key mappings.
|
||||
*
|
||||
* @param regionName The name of the region.
|
||||
* @param configValues Available config values.
|
||||
* @param metadata Information regarding the type of data to be cached
|
||||
*
|
||||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*/
|
||||
default NaturalIdRegion buildNaturalIdRegion(String regionName, Map<String,Object> configValues, CacheDataDescription metadata)
|
||||
throws CacheException {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( configValues );
|
||||
return buildNaturalIdRegion( regionName, properties, metadata );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing collection data.
|
||||
*
|
||||
|
@ -114,9 +178,27 @@ public interface RegionFactory extends Service {
|
|||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*/
|
||||
public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
throws CacheException;
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing collection data.
|
||||
*
|
||||
* @param regionName The name of the region.
|
||||
* @param configValues Available config values.
|
||||
* @param metadata Information regarding the type of data to be cached
|
||||
*
|
||||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*/
|
||||
default CollectionRegion buildCollectionRegion(String regionName, Map<String,Object> configValues, CacheDataDescription metadata)
|
||||
throws CacheException {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( configValues );
|
||||
return buildCollectionRegion( regionName, properties, metadata );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing query results.
|
||||
*
|
||||
|
@ -126,8 +208,27 @@ public interface RegionFactory extends Service {
|
|||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*
|
||||
* @deprecated (since 6.0) use the form taking Map instead
|
||||
*/
|
||||
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException;
|
||||
@Deprecated
|
||||
QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException;
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing query results.
|
||||
*
|
||||
* @param qualifyRegionName The qualified name of the region.
|
||||
* @param configValues Available config values.
|
||||
*
|
||||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*/
|
||||
default QueryResultsRegion buildQueryResultsRegion(String qualifyRegionName, Map<String,Object> configValues) {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( configValues );
|
||||
return buildQueryResultsRegion( qualifyRegionName, properties );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing update-timestamps data.
|
||||
|
@ -138,6 +239,26 @@ public interface RegionFactory extends Service {
|
|||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*
|
||||
* @deprecated (since 6.0) use the form taking Map
|
||||
*/
|
||||
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException;
|
||||
@Deprecated
|
||||
TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException;
|
||||
|
||||
/**
|
||||
* Build a cache region specialized for storing update-timestamps data.
|
||||
*
|
||||
* @param regionName The name of the region.
|
||||
* @param configValues The available config values.
|
||||
*
|
||||
* @return The built region
|
||||
*
|
||||
* @throws CacheException Indicates problems building the region.
|
||||
*/
|
||||
default TimestampsRegion buildTimestampsRegion(String regionName, Map<String,Object> configValues) throws CacheException {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( configValues );
|
||||
return buildTimestampsRegion( regionName, properties );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
package org.hibernate.cache.spi;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -31,41 +29,25 @@ import org.jboss.logging.Logger;
|
|||
public class UpdateTimestampsCache {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, UpdateTimestampsCache.class.getName() );
|
||||
private static final boolean DEBUG_ENABLED = LOG.isDebugEnabled();
|
||||
|
||||
/**
|
||||
* The region name of the update-timestamps cache.
|
||||
*/
|
||||
public static final String REGION_NAME = UpdateTimestampsCache.class.getName();
|
||||
|
||||
|
||||
private final SessionFactoryImplementor factory;
|
||||
private final TimestampsRegion region;
|
||||
|
||||
/**
|
||||
* Constructs an UpdateTimestampsCache.
|
||||
*
|
||||
* @param settings The SessionFactory settings
|
||||
* @param props Any properties
|
||||
* @param factory The SessionFactory
|
||||
* @param sessionFactory The SessionFactory
|
||||
* @param region The underlying second level cache region to use.
|
||||
*/
|
||||
public UpdateTimestampsCache(SessionFactoryOptions settings, Properties props, final SessionFactoryImplementor factory) {
|
||||
this.factory = factory;
|
||||
final String prefix = settings.getCacheRegionPrefix();
|
||||
final String regionName = prefix == null ? REGION_NAME : prefix + '.' + REGION_NAME;
|
||||
|
||||
LOG.startingUpdateTimestampsCache( regionName );
|
||||
|
||||
this.region = settings.getServiceRegistry().getService( RegionFactory.class ).buildTimestampsRegion( regionName, props );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an UpdateTimestampsCache.
|
||||
*
|
||||
* @param settings The SessionFactory settings
|
||||
* @param props Any properties
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public UpdateTimestampsCache(SessionFactoryOptions settings, Properties props) {
|
||||
this( settings, props, null );
|
||||
public UpdateTimestampsCache(SessionFactoryImplementor sessionFactory, TimestampsRegion region) {
|
||||
LOG.startingUpdateTimestampsCache( region.getName() );
|
||||
this.factory = sessionFactory;
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +59,7 @@ public class UpdateTimestampsCache {
|
|||
* @param session
|
||||
* @throws CacheException Indicated problem delegating to underlying region.
|
||||
*/
|
||||
public void preInvalidate(Serializable[] spaces, SessionImplementor session) throws CacheException {
|
||||
public void preInvalidate(Serializable[] spaces, SharedSessionContractImplementor session) throws CacheException {
|
||||
final boolean stats = factory != null && factory.getStatistics().isStatisticsEnabled();
|
||||
|
||||
final Long ts = region.nextTimestamp() + region.getTimeout();
|
||||
|
@ -99,7 +81,7 @@ public class UpdateTimestampsCache {
|
|||
}
|
||||
|
||||
if ( stats ) {
|
||||
factory.getStatisticsImplementor().updateTimestampsCachePut();
|
||||
factory.getStatistics().updateTimestampsCachePut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +95,7 @@ public class UpdateTimestampsCache {
|
|||
* @param session
|
||||
* @throws CacheException Indicated problem delegating to underlying region.
|
||||
*/
|
||||
public void invalidate(Serializable[] spaces, SessionImplementor session) throws CacheException {
|
||||
public void invalidate(Serializable[] spaces, SharedSessionContractImplementor session) throws CacheException {
|
||||
final boolean stats = factory != null && factory.getStatistics().isStatisticsEnabled();
|
||||
|
||||
final Long ts = region.nextTimestamp();
|
||||
|
@ -135,7 +117,7 @@ public class UpdateTimestampsCache {
|
|||
}
|
||||
|
||||
if ( stats ) {
|
||||
factory.getStatisticsImplementor().updateTimestampsCachePut();
|
||||
factory.getStatistics().updateTimestampsCachePut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,14 +134,14 @@ public class UpdateTimestampsCache {
|
|||
*
|
||||
* @throws CacheException Indicated problem delegating to underlying region.
|
||||
*/
|
||||
public boolean isUpToDate(Set<Serializable> spaces, Long timestamp, SessionImplementor session) throws CacheException {
|
||||
public boolean isUpToDate(Set<Serializable> spaces, Long timestamp, SharedSessionContractImplementor session) throws CacheException {
|
||||
final boolean stats = factory != null && factory.getStatistics().isStatisticsEnabled();
|
||||
|
||||
for ( Serializable space : spaces ) {
|
||||
final Long lastUpdate = getLastUpdateTimestampForSpace( space, session );
|
||||
if ( lastUpdate == null ) {
|
||||
if ( stats ) {
|
||||
factory.getStatisticsImplementor().updateTimestampsCacheMiss();
|
||||
factory.getStatistics().updateTimestampsCacheMiss();
|
||||
}
|
||||
//the last update timestamp was lost from the cache
|
||||
//(or there were no updates since startup!)
|
||||
|
@ -175,7 +157,7 @@ public class UpdateTimestampsCache {
|
|||
);
|
||||
}
|
||||
if ( stats ) {
|
||||
factory.getStatisticsImplementor().updateTimestampsCacheHit();
|
||||
factory.getStatistics().updateTimestampsCacheHit();
|
||||
}
|
||||
if ( lastUpdate >= timestamp ) {
|
||||
return false;
|
||||
|
@ -185,7 +167,7 @@ public class UpdateTimestampsCache {
|
|||
return true;
|
||||
}
|
||||
|
||||
private Long getLastUpdateTimestampForSpace(Serializable space, SessionImplementor session) {
|
||||
private Long getLastUpdateTimestampForSpace(Serializable space, SharedSessionContractImplementor session) {
|
||||
Long ts = null;
|
||||
try {
|
||||
session.getEventListenerManager().cacheGetStart();
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.persister.collection.CollectionPersister;
|
|||
* {@link #lockItem} -> {@link #remove} -> {@link #unlockItem}
|
||||
* <p/>
|
||||
* There is another usage pattern that is used to invalidate entries
|
||||
* after performing "bulk" HQL/SQL operations:
|
||||
* afterQuery performing "bulk" HQL/SQL operations:
|
||||
* {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion}
|
||||
*
|
||||
* @author Gavin King
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.cache.spi.access;
|
|||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.cache.spi.EntityRegion;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
* </ul>
|
||||
* <p/>
|
||||
* There is another usage pattern that is used to invalidate entries
|
||||
* after performing "bulk" HQL/SQL operations:
|
||||
* afterQuery performing "bulk" HQL/SQL operations:
|
||||
* {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion}
|
||||
*
|
||||
* @author Gavin King
|
||||
|
@ -39,7 +39,11 @@ public interface EntityRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @param tenantIdentifier the tenant id, or null if multi-tenancy is not being used.
|
||||
* @return a key which can be used to identify this entity on this same region
|
||||
*/
|
||||
public Object generateCacheKey(Object id, EntityPersister persister, SessionFactoryImplementor factory, String tenantIdentifier);
|
||||
Object generateCacheKey(
|
||||
Object id,
|
||||
EntityPersister persister,
|
||||
SessionFactoryImplementor factory,
|
||||
String tenantIdentifier);
|
||||
|
||||
/**
|
||||
* Performs reverse operation to {@link #generateCacheKey(Object, EntityPersister, SessionFactoryImplementor, String)}
|
||||
|
@ -47,17 +51,17 @@ public interface EntityRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @param cacheKey key previously returned from {@link #generateCacheKey(Object, EntityPersister, SessionFactoryImplementor, String)}
|
||||
* @return original id passed to {@link #generateCacheKey(Object, EntityPersister, SessionFactoryImplementor, String)}
|
||||
*/
|
||||
public Object getCacheKeyId(Object cacheKey);
|
||||
Object getCacheKeyId(Object cacheKey);
|
||||
|
||||
/**
|
||||
* Get the wrapped entity cache region
|
||||
*
|
||||
* @return The underlying region
|
||||
*/
|
||||
public EntityRegion getRegion();
|
||||
EntityRegion getRegion();
|
||||
|
||||
/**
|
||||
* Called after an item has been inserted (before the transaction completes),
|
||||
* Called afterQuery an item has been inserted (beforeQuery the transaction completes),
|
||||
* instead of calling evict().
|
||||
* This method is used by "synchronous" concurrency strategies.
|
||||
*
|
||||
|
@ -68,10 +72,10 @@ public interface EntityRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean insert(SessionImplementor session, Object key, Object value, Object version) throws CacheException;
|
||||
boolean insert(SharedSessionContractImplementor session, Object key, Object value, Object version) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after an item has been inserted (after the transaction completes),
|
||||
* Called afterQuery an item has been inserted (afterQuery the transaction completes),
|
||||
* instead of calling release().
|
||||
* This method is used by "asynchronous" concurrency strategies.
|
||||
*
|
||||
|
@ -82,10 +86,10 @@ public interface EntityRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean afterInsert(SessionImplementor session, Object key, Object value, Object version) throws CacheException;
|
||||
boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value, Object version) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after an item has been updated (before the transaction completes),
|
||||
* Called afterQuery an item has been updated (beforeQuery the transaction completes),
|
||||
* instead of calling evict(). This method is used by "synchronous" concurrency
|
||||
* strategies.
|
||||
*
|
||||
|
@ -98,10 +102,10 @@ public interface EntityRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean update(SessionImplementor session, Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException;
|
||||
boolean update(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after an item has been updated (after the transaction completes),
|
||||
* Called afterQuery an item has been updated (afterQuery the transaction completes),
|
||||
* instead of calling release(). This method is used by "asynchronous"
|
||||
* concurrency strategies.
|
||||
*
|
||||
|
@ -114,5 +118,11 @@ public interface EntityRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean afterUpdate(SessionImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException;
|
||||
boolean afterUpdate(
|
||||
SharedSessionContractImplementor session,
|
||||
Object key,
|
||||
Object value,
|
||||
Object currentVersion,
|
||||
Object previousVersion,
|
||||
SoftLock lock) throws CacheException;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.cache.spi.access;
|
|||
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.cache.spi.NaturalIdRegion;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
/**
|
||||
|
@ -23,13 +23,13 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
* old entry as well as
|
||||
* <p/>
|
||||
* There is another usage pattern that is used to invalidate entries
|
||||
* after performing "bulk" HQL/SQL operations:
|
||||
* afterQuery performing "bulk" HQL/SQL operations:
|
||||
* {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion}
|
||||
* <p/>
|
||||
* IMPORTANT : NaturalIds are not versioned so {@code null} will always be passed to the version parameter to:<ul>
|
||||
* <li>{@link RegionAccessStrategy#putFromLoad(SessionImplementor, Object, Object, long, Object)}</li>
|
||||
* <li>{@link RegionAccessStrategy#putFromLoad(SessionImplementor, Object, Object, long, Object, boolean)}</li>
|
||||
* <li>{@link RegionAccessStrategy#lockItem(SessionImplementor, Object, Object)}</li>
|
||||
* <li>{@link RegionAccessStrategy#putFromLoad(SharedSessionContractImplementor, Object, Object, long, Object)}</li>
|
||||
* <li>{@link RegionAccessStrategy#putFromLoad(SharedSessionContractImplementor, Object, Object, long, Object, boolean)}</li>
|
||||
* <li>{@link RegionAccessStrategy#lockItem(SharedSessionContractImplementor, Object, Object)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Gavin King
|
||||
|
@ -46,25 +46,28 @@ public interface NaturalIdRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @param session
|
||||
* @return a key which can be used to identify this an element unequivocally on this same region
|
||||
*/
|
||||
public Object generateCacheKey(Object[] naturalIdValues, EntityPersister persister, SessionImplementor session);
|
||||
Object generateCacheKey(
|
||||
Object[] naturalIdValues,
|
||||
EntityPersister persister,
|
||||
SharedSessionContractImplementor session);
|
||||
|
||||
/**
|
||||
* Performs reverse operation to {@link #generateCacheKey(Object[], EntityPersister, SessionImplementor)}, returning
|
||||
* Performs reverse operation to {@link #generateCacheKey(Object[], EntityPersister, SharedSessionContractImplementor)}, returning
|
||||
* the original naturalIdValues.
|
||||
* @param cacheKey key returned from {@link #generateCacheKey(Object[], EntityPersister, SessionImplementor)}
|
||||
* @param cacheKey key returned from {@link #generateCacheKey(Object[], EntityPersister, SharedSessionContractImplementor)}
|
||||
* @return the sequence of values which unequivocally identifies a cached element on this region
|
||||
*/
|
||||
public Object[] getNaturalIdValues(Object cacheKey);
|
||||
Object[] getNaturalIdValues(Object cacheKey);
|
||||
|
||||
/**
|
||||
* Get the wrapped naturalId cache region
|
||||
*
|
||||
* @return The underlying region
|
||||
*/
|
||||
public NaturalIdRegion getRegion();
|
||||
NaturalIdRegion getRegion();
|
||||
|
||||
/**
|
||||
* Called after an item has been inserted (before the transaction completes),
|
||||
* Called afterQuery an item has been inserted (beforeQuery the transaction completes),
|
||||
* instead of calling evict().
|
||||
* This method is used by "synchronous" concurrency strategies.
|
||||
*
|
||||
|
@ -74,10 +77,10 @@ public interface NaturalIdRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean insert(SessionImplementor session, Object key, Object value) throws CacheException;
|
||||
boolean insert(SharedSessionContractImplementor session, Object key, Object value) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after an item has been inserted (after the transaction completes),
|
||||
* Called afterQuery an item has been inserted (afterQuery the transaction completes),
|
||||
* instead of calling release().
|
||||
* This method is used by "asynchronous" concurrency strategies.
|
||||
*
|
||||
|
@ -87,10 +90,10 @@ public interface NaturalIdRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean afterInsert(SessionImplementor session, Object key, Object value) throws CacheException;
|
||||
boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after an item has been updated (before the transaction completes),
|
||||
* Called afterQuery an item has been updated (beforeQuery the transaction completes),
|
||||
* instead of calling evict(). This method is used by "synchronous" concurrency
|
||||
* strategies.
|
||||
*
|
||||
|
@ -100,10 +103,10 @@ public interface NaturalIdRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propagated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean update(SessionImplementor session, Object key, Object value) throws CacheException;
|
||||
boolean update(SharedSessionContractImplementor session, Object key, Object value) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after an item has been updated (after the transaction completes),
|
||||
* Called afterQuery an item has been updated (afterQuery the transaction completes),
|
||||
* instead of calling release(). This method is used by "asynchronous"
|
||||
* concurrency strategies.
|
||||
*
|
||||
|
@ -114,5 +117,5 @@ public interface NaturalIdRegionAccessStrategy extends RegionAccessStrategy {
|
|||
* @return Were the contents of the cache actual changed by this operation?
|
||||
* @throws CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
public boolean afterUpdate(SessionImplementor session, Object key, Object value, SoftLock lock) throws CacheException;
|
||||
boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock) throws CacheException;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.cache.spi.access;
|
|||
|
||||
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* Base access strategy for all regions.
|
||||
|
@ -27,10 +27,10 @@ public interface RegionAccessStrategy {
|
|||
* @return the cached object or <tt>null</tt>
|
||||
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
Object get(SessionImplementor session, Object key, long txTimestamp) throws CacheException;
|
||||
Object get(SharedSessionContractImplementor session, Object key, long txTimestamp) throws CacheException;
|
||||
|
||||
/**
|
||||
* Attempt to cache an object, after loading from the database.
|
||||
* Attempt to cache an object, afterQuery loading from the database.
|
||||
*
|
||||
* @param session Current session.
|
||||
* @param key The item key
|
||||
|
@ -41,14 +41,14 @@ public interface RegionAccessStrategy {
|
|||
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
boolean putFromLoad(
|
||||
SessionImplementor session,
|
||||
SharedSessionContractImplementor session,
|
||||
Object key,
|
||||
Object value,
|
||||
long txTimestamp,
|
||||
Object version) throws CacheException;
|
||||
|
||||
/**
|
||||
* Attempt to cache an object, after loading from the database, explicitly
|
||||
* Attempt to cache an object, afterQuery loading from the database, explicitly
|
||||
* specifying the minimalPut behavior.
|
||||
*
|
||||
* @param session Current session.
|
||||
|
@ -61,7 +61,7 @@ public interface RegionAccessStrategy {
|
|||
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
boolean putFromLoad(
|
||||
SessionImplementor session,
|
||||
SharedSessionContractImplementor session,
|
||||
Object key,
|
||||
Object value,
|
||||
long txTimestamp,
|
||||
|
@ -82,7 +82,7 @@ public interface RegionAccessStrategy {
|
|||
* @return A representation of our lock on the item; or null.
|
||||
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
SoftLock lockItem(SessionImplementor session, Object key, Object version) throws CacheException;
|
||||
SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException;
|
||||
|
||||
/**
|
||||
* Lock the entire region
|
||||
|
@ -94,7 +94,7 @@ public interface RegionAccessStrategy {
|
|||
|
||||
/**
|
||||
* Called when we have finished the attempted update/delete (which may or
|
||||
* may not have been successful), after transaction completion. This method
|
||||
* may not have been successful), afterQuery transaction completion. This method
|
||||
* is used by "asynchronous" concurrency strategies.
|
||||
*
|
||||
* @param session Current session.
|
||||
|
@ -102,10 +102,10 @@ public interface RegionAccessStrategy {
|
|||
* @param lock The lock previously obtained from {@link #lockItem}
|
||||
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
void unlockItem(SessionImplementor session, Object key, SoftLock lock) throws CacheException;
|
||||
void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after we have finished the attempted invalidation of the entire
|
||||
* Called afterQuery we have finished the attempted invalidation of the entire
|
||||
* region
|
||||
*
|
||||
* @param lock The lock previously obtained from {@link #lockRegion}
|
||||
|
@ -114,14 +114,14 @@ public interface RegionAccessStrategy {
|
|||
void unlockRegion(SoftLock lock) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called after an item has become stale (before the transaction completes).
|
||||
* Called afterQuery an item has become stale (beforeQuery the transaction completes).
|
||||
* This method is used by "synchronous" concurrency strategies.
|
||||
*
|
||||
* @param session
|
||||
* @param key The key of the item to remove
|
||||
* @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region}
|
||||
*/
|
||||
void remove(SessionImplementor session, Object key) throws CacheException;
|
||||
void remove(SharedSessionContractImplementor session, Object key) throws CacheException;
|
||||
|
||||
/**
|
||||
* Called to evict data from the entire region
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
package org.hibernate.cache.spi.entry;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
|
@ -20,7 +19,6 @@ import org.hibernate.event.spi.EventType;
|
|||
import org.hibernate.event.spi.PreLoadEvent;
|
||||
import org.hibernate.event.spi.PreLoadEventListener;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.TypeHelper;
|
||||
|
||||
|
@ -49,7 +47,7 @@ public class StandardCacheEntryImpl implements CacheEntry {
|
|||
final Object[] state,
|
||||
final EntityPersister persister,
|
||||
final Object version,
|
||||
final SessionImplementor session,
|
||||
final SharedSessionContractImplementor session,
|
||||
final Object owner) throws HibernateException {
|
||||
// disassembled state gets put in a new array (we write to cache by value!)
|
||||
this.disassembledState = TypeHelper.disassemble(
|
||||
|
@ -140,7 +138,7 @@ public class StandardCacheEntryImpl implements CacheEntry {
|
|||
session, instance
|
||||
);
|
||||
|
||||
//persister.setIdentifier(instance, id); //before calling interceptor, for consistency with normal load
|
||||
//persister.setIdentifier(instance, id); //beforeQuery calling interceptor, for consistency with normal load
|
||||
|
||||
//TODO: reuse the PreLoadEvent
|
||||
final PreLoadEvent preLoadEvent = new PreLoadEvent( session )
|
||||
|
|
|
@ -474,7 +474,7 @@ public final class AnnotationBinder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Bind a class having JSR175 annotations. Subclasses <b>have to</b> be bound after its parent class.
|
||||
* Bind a class having JSR175 annotations. Subclasses <b>have to</b> be bound afterQuery its parent class.
|
||||
*
|
||||
* @param clazzToProcess entity to bind as {@code XClass} instance
|
||||
* @param inheritanceStatePerClass Meta data about the inheritance relationships for all mapped classes
|
||||
|
@ -1263,7 +1263,7 @@ public final class AnnotationBinder {
|
|||
//check if superclass is not a potential persistent class
|
||||
if ( inheritanceState.hasParents() ) {
|
||||
throw new AssertionFailure(
|
||||
"Subclass has to be binded after it's mother class: "
|
||||
"Subclass has to be binded afterQuery it's mother class: "
|
||||
+ superEntityState.getClazz().getName()
|
||||
);
|
||||
}
|
||||
|
@ -1520,7 +1520,7 @@ public final class AnnotationBinder {
|
|||
|
||||
/*
|
||||
* put element annotated by @Id in front
|
||||
* since it has to be parsed before any association by Hibernate
|
||||
* since it has to be parsed beforeQuery any association by Hibernate
|
||||
*/
|
||||
final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
|
||||
if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
|
||||
|
@ -2271,7 +2271,7 @@ public final class AnnotationBinder {
|
|||
}
|
||||
}
|
||||
//init index
|
||||
//process indexes after everything: in second pass, many to one has to be done before indexes
|
||||
//process indexes afterQuery everything: in second pass, many to one has to be done beforeQuery indexes
|
||||
Index index = property.getAnnotation( Index.class );
|
||||
if ( index != null ) {
|
||||
if ( joinColumns != null ) {
|
||||
|
|
|
@ -7,12 +7,174 @@
|
|||
package org.hibernate.cfg;
|
||||
|
||||
import org.hibernate.boot.MetadataBuilder;
|
||||
import org.hibernate.query.internal.ParameterMetadataImpl;
|
||||
import org.hibernate.tool.schema.SourceType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
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 JPA_PERSISTENCE_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 JPA_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 JPA_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 JPA_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 #JPA_JDBC_URL}, {@link #JPA_JDBC_USER} and {@link #JPA_JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JPA_JTA_DATASOURCE} or {@link #JPA_NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
String JPA_JDBC_DRIVER = "javax.persistence.jdbc.driver";
|
||||
|
||||
/**
|
||||
* The JDBC connection url to use to connect to the database.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JPA_JDBC_DRIVER}, {@link #JPA_JDBC_USER} and {@link #JPA_JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JPA_JTA_DATASOURCE} or {@link #JPA_NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
String JPA_JDBC_URL = "javax.persistence.jdbc.url";
|
||||
|
||||
/**
|
||||
* The JDBC connection user name.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JPA_JDBC_DRIVER}, {@link #JPA_JDBC_URL} and {@link #JPA_JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JPA_JTA_DATASOURCE} or {@link #JPA_NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
String JPA_JDBC_USER = "javax.persistence.jdbc.user";
|
||||
|
||||
/**
|
||||
* The JDBC connection password.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JPA_JDBC_DRIVER}, {@link #JPA_JDBC_URL} and {@link #JPA_JDBC_USER}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JPA_JTA_DATASOURCE} or {@link #JPA_NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
String JPA_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 JPA_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 JPA_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 JPA_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 JPA_VALIDATION_MODE = "javax.persistence.validation.mode";
|
||||
|
||||
/**
|
||||
* Used to pass along any discovered validator factory.
|
||||
*/
|
||||
String JPA_VALIDATION_FACTORY = "javax.persistence.validation.factory";
|
||||
|
||||
/**
|
||||
* Used to coordinate with bean validators
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
String JPA_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 JPA_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 JPA_REMOVE_VALIDATION_GROUP = "javax.persistence.validation.group.pre-remove";
|
||||
|
||||
/**
|
||||
* Used to request (hint) a pessimistic lock scope.
|
||||
* <p/>
|
||||
* See JPA 2 sections 8.2.1.9 and 3.4.4.3
|
||||
*/
|
||||
String JPA_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 JPA_LOCK_TIMEOUT = "javax.persistence.lock.timeout";
|
||||
|
||||
/**
|
||||
* Used to pass along the CDI BeanManager, if any, to be used.
|
||||
*/
|
||||
String CDI_BEAN_MANAGER = "javax.persistence.bean.manager";
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// BootstrapServiceRegistry level settings
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -60,6 +222,30 @@ public interface AvailableSettings {
|
|||
@Deprecated
|
||||
String ENVIRONMENT_CLASSLOADER = "hibernate.classLoader.environment";
|
||||
|
||||
/**
|
||||
* @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";
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// StandardServiceRegistry level settings
|
||||
|
@ -637,7 +823,7 @@ public interface AvailableSettings {
|
|||
String C3P0_ACQUIRE_INCREMENT = "hibernate.c3p0.acquire_increment";
|
||||
|
||||
/**
|
||||
* Idle time before a C3P0 pooled connection is validated
|
||||
* Idle time beforeQuery a C3P0 pooled connection is validated
|
||||
*/
|
||||
String C3P0_IDLE_TEST_PERIOD = "hibernate.c3p0.idle_test_period";
|
||||
|
||||
|
@ -821,7 +1007,7 @@ public interface AvailableSettings {
|
|||
String QUERY_PLAN_CACHE_MAX_SIZE = "hibernate.query.plan_cache_max_size";
|
||||
|
||||
/**
|
||||
* The maximum number of {@link org.hibernate.engine.query.spi.ParameterMetadata} maintained
|
||||
* The maximum number of {@link ParameterMetadataImpl} maintained
|
||||
* by {@link org.hibernate.engine.query.spi.QueryPlanCache}. Default is 128.
|
||||
*/
|
||||
String QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE = "hibernate.query.plan_parameter_metadata_max_size";
|
||||
|
@ -997,7 +1183,7 @@ public interface AvailableSettings {
|
|||
/**
|
||||
* Comma-separated names of the optional files containing SQL DML statements executed
|
||||
* during the SessionFactory creation.
|
||||
* File order matters, the statements of a give file are executed before the statements of the
|
||||
* File order matters, the statements of a give file are executed beforeQuery the statements of the
|
||||
* following files.
|
||||
* <p/>
|
||||
* These statements are only executed if the schema is created ie if <tt>hibernate.hbm2ddl.auto</tt>
|
||||
|
@ -1112,7 +1298,13 @@ public interface AvailableSettings {
|
|||
String MULTI_TENANT_IDENTIFIER_RESOLVER = "hibernate.tenant_identifier_resolver";
|
||||
|
||||
/**
|
||||
* Names a {@link org.hibernate.Interceptor} implementation to be applied to the {@link org.hibernate.SessionFactory}
|
||||
* Names a {@link org.hibernate.Interceptor} implementation to be applied to the
|
||||
* {@link org.hibernate.SessionFactory} and propagated to each Session created from the SessionFactory.
|
||||
* This setting identifies an Interceptor which is effectively a singleton across all the Sessions
|
||||
* opened from the SessionFactory to which it is applied; the same instance will be passed to each Session.
|
||||
* <p/>
|
||||
* See {@link #SESSION_SCOPED_INTERCEPTOR} for an approach to create unique Interceptor instances for each Session
|
||||
* <p/>
|
||||
* Can reference<ul>
|
||||
* <li>Interceptor instance</li>
|
||||
* <li>Interceptor implementation {@link Class} reference</li>
|
||||
|
@ -1123,6 +1315,23 @@ public interface AvailableSettings {
|
|||
*/
|
||||
String INTERCEPTOR = "hibernate.session_factory.interceptor";
|
||||
|
||||
/**
|
||||
* Names a {@link org.hibernate.Interceptor} implementation to be applied to the
|
||||
* {@link org.hibernate.SessionFactory} and propagated to each Session created from the SessionFactory.
|
||||
* This setting identifies an Interceptor implementation that is to be applied to every Session opened
|
||||
* from the SessionFactory, but unlike {@link #INTERCEPTOR} a unique instance of the Interceptor is
|
||||
* used for each Session.
|
||||
* <p/>
|
||||
* Can reference<ul>
|
||||
* <li>Interceptor implementation {@link Class} reference</li>
|
||||
* <li>Interceptor implementation class name</li>
|
||||
* </ul>
|
||||
* Note specifically that this setting cannot name an Interceptor instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
String SESSION_SCOPED_INTERCEPTOR = "hibernate.session_factory.session_scoped_interceptor";
|
||||
|
||||
/**
|
||||
* Names a {@link org.hibernate.resource.jdbc.spi.StatementInspector} implementation to be applied to
|
||||
* the {@link org.hibernate.SessionFactory}. Can reference<ul>
|
||||
|
|
|
@ -183,7 +183,7 @@ class ColumnsBuilder {
|
|||
}
|
||||
|
||||
Ejb3JoinColumn[] buildExplicitJoinColumns(XProperty property, PropertyData inferredData) {
|
||||
//process @JoinColumn(s) before @Column(s) to handle collection of entities properly
|
||||
//process @JoinColumn(s) beforeQuery @Column(s) to handle collection of entities properly
|
||||
Ejb3JoinColumn[] joinColumns = null;
|
||||
{
|
||||
JoinColumn[] anns = null;
|
||||
|
|
|
@ -6,6 +6,19 @@
|
|||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
|
||||
import org.hibernate.EmptyInterceptor;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Interceptor;
|
||||
|
@ -29,7 +42,6 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
|||
import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
|
||||
import org.hibernate.cfg.annotations.NamedProcedureCallDefinition;
|
||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.engine.ResultSetMappingDefinition;
|
||||
import org.hibernate.engine.spi.NamedQueryDefinition;
|
||||
|
@ -47,19 +59,6 @@ import org.hibernate.type.SerializationException;
|
|||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Represents one approach for bootstrapping Hibernate. In fact, historically this was
|
||||
* <b>the</b> way to bootstrap Hibernate.
|
||||
|
@ -640,7 +639,7 @@ public class Configuration {
|
|||
|
||||
/**
|
||||
* Create a {@link SessionFactory} using the properties and mappings in this configuration. The
|
||||
* SessionFactory will be immutable, so changes made to this Configuration after building the
|
||||
* SessionFactory will be immutable, so changes made to this Configuration afterQuery building the
|
||||
* SessionFactory will not affect it.
|
||||
*
|
||||
* @param serviceRegistry The registry of services to be used in creating this session factory.
|
||||
|
@ -711,7 +710,7 @@ public class Configuration {
|
|||
|
||||
/**
|
||||
* 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
|
||||
* {@link SessionFactory} will be immutable, so changes made to {@code this} {@link Configuration} afterQuery
|
||||
* building the {@link SessionFactory} will not affect it.
|
||||
*
|
||||
* @return The build {@link SessionFactory}
|
||||
|
|
|
@ -630,7 +630,7 @@ public class Ejb3Column {
|
|||
}
|
||||
}
|
||||
|
||||
//must only be called after all setters are defined and before bind
|
||||
//must only be called afterQuery all setters are defined and beforeQuery bind
|
||||
private void extractDataFromPropertyData(PropertyData inferredData) {
|
||||
if ( inferredData != null ) {
|
||||
XProperty property = inferredData.getProperty();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue