Hibernate SVN: r10863 - branches/Branch_3_2/Hibernate3/src/org/hibernate/impl
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-22 07:53:53 -0500 (Wed, 22 Nov 2006)
New Revision: 10863
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
Log:
HHH-2259 : jta current session + auto-flush
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-11-22 00:11:35 UTC (rev 10862)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-11-22 12:53:53 UTC (rev 10863)
@@ -990,6 +990,9 @@
return null;
}
else if ( "jta".equals( impl ) ) {
+ if ( settings.getTransactionFactory().areCallbacksLocalToHibernateTransactions() ) {
+ log.warn( "JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()" );
+ }
return new JTASessionContext( this );
}
else if ( "thread".equals( impl ) ) {
17 years, 9 months
Hibernate SVN: r10862 - trunk/Hibernate3/src/org/hibernate/impl
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 19:11:35 -0500 (Tue, 21 Nov 2006)
New Revision: 10862
Modified:
trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java
Log:
HHH-2238 : SQLQuery.executeUpdate() + flush-modes
Modified: trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java 2006-11-22 00:11:25 UTC (rev 10861)
+++ trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java 2006-11-22 00:11:35 UTC (rev 10862)
@@ -329,7 +329,16 @@
public int executeUpdate() throws HibernateException {
Map namedParams = getNamedParams();
- return getSession().executeNativeUpdate(generateQuerySpecification( namedParams ), getQueryParameters( namedParams ));
+ before();
+ try {
+ return getSession().executeNativeUpdate(
+ generateQuerySpecification( namedParams ),
+ getQueryParameters( namedParams )
+ );
+ }
+ finally {
+ after();
+ }
}
}
17 years, 9 months
Hibernate SVN: r10861 - branches/Branch_3_2/Hibernate3/src/org/hibernate/impl
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 19:11:25 -0500 (Tue, 21 Nov 2006)
New Revision: 10861
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java
Log:
HHH-2238 : SQLQuery.executeUpdate() + flush-modes
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java 2006-11-22 00:02:55 UTC (rev 10860)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java 2006-11-22 00:11:25 UTC (rev 10861)
@@ -329,7 +329,16 @@
public int executeUpdate() throws HibernateException {
Map namedParams = getNamedParams();
- return getSession().executeNativeUpdate(generateQuerySpecification( namedParams ), getQueryParameters( namedParams ));
+ before();
+ try {
+ return getSession().executeNativeUpdate(
+ generateQuerySpecification( namedParams ),
+ getQueryParameters( namedParams )
+ );
+ }
+ finally {
+ after();
+ }
}
}
17 years, 9 months
Hibernate SVN: r10860 - in trunk/Hibernate3/src/org/hibernate: jmx util
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 19:02:55 -0500 (Tue, 21 Nov 2006)
New Revision: 10860
Modified:
trunk/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java
trunk/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java
Log:
HHH-2246 : mbean + cache-provider-config setting
Modified: trunk/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java 2006-11-22 00:02:40 UTC (rev 10859)
+++ trunk/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java 2006-11-22 00:02:55 UTC (rev 10860)
@@ -224,6 +224,16 @@
*/
public void setCacheProviderClass(String providerClassName);
/**
+ * For cache providers which support this setting, get the
+ * provider's specific configuration resource.
+ */
+ public String getCacheProviderConfig();
+ /**
+ * For cache providers which support this setting, specify the
+ * provider's specific configuration resource.
+ */
+ public void setCacheProviderConfig(String cacheProviderConfig);
+ /**
* Is the query cache enabled?
*/
public String getQueryCacheEnabled();
Modified: trunk/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java 2006-11-22 00:02:40 UTC (rev 10859)
+++ trunk/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java 2006-11-22 00:02:55 UTC (rev 10860)
@@ -35,9 +35,10 @@
private String querySubstitutions;
private String showSqlEnabled;
private String commentsEnabled;
- private String secondLevelCacheEnabled;
private String cacheProviderClass;
+ private String cacheProviderConfig;
private String cacheRegionPrefix;
+ private String secondLevelCacheEnabled;
private String minimalPutsEnabled;
private String queryCacheEnabled;
@@ -198,6 +199,14 @@
this.cacheProviderClass = cacheProviderClass;
}
+ public String getCacheProviderConfig() {
+ return cacheProviderConfig;
+ }
+
+ public void setCacheProviderConfig(String cacheProviderConfig) {
+ this.cacheProviderConfig = cacheProviderConfig;
+ }
+
public final String getCacheRegionPrefix() {
return cacheRegionPrefix;
}
@@ -310,10 +319,11 @@
setUnlessNull( props, Environment.QUERY_SUBSTITUTIONS, querySubstitutions );
setUnlessNull( props, Environment.SHOW_SQL, showSqlEnabled );
setUnlessNull( props, Environment.USE_SQL_COMMENTS, commentsEnabled );
- setUnlessNull( props, Environment.USE_SECOND_LEVEL_CACHE, secondLevelCacheEnabled );
setUnlessNull( props, Environment.CACHE_PROVIDER, cacheProviderClass );
+ setUnlessNull( props, Environment.CACHE_PROVIDER_CONFIG, cacheProviderConfig );
setUnlessNull( props, Environment.CACHE_REGION_PREFIX, cacheRegionPrefix );
setUnlessNull( props, Environment.USE_MINIMAL_PUTS, minimalPutsEnabled );
+ setUnlessNull( props, Environment.USE_SECOND_LEVEL_CACHE, secondLevelCacheEnabled );
setUnlessNull( props, Environment.USE_QUERY_CACHE, queryCacheEnabled );
Map extraProperties = getExtraProperties();
17 years, 9 months
Hibernate SVN: r10859 - in branches/Branch_3_2/Hibernate3/src/org/hibernate: jmx util
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 19:02:40 -0500 (Tue, 21 Nov 2006)
New Revision: 10859
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java
Log:
HHH-2246 : mbean + cache-provider-config setting
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java 2006-11-21 23:28:29 UTC (rev 10858)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jmx/HibernateServiceMBean.java 2006-11-22 00:02:40 UTC (rev 10859)
@@ -224,6 +224,16 @@
*/
public void setCacheProviderClass(String providerClassName);
/**
+ * For cache providers which support this setting, get the
+ * provider's specific configuration resource.
+ */
+ public String getCacheProviderConfig();
+ /**
+ * For cache providers which support this setting, specify the
+ * provider's specific configuration resource.
+ */
+ public void setCacheProviderConfig(String cacheProviderConfig);
+ /**
* Is the query cache enabled?
*/
public String getQueryCacheEnabled();
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java 2006-11-21 23:28:29 UTC (rev 10858)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/util/ExternalSessionFactoryConfig.java 2006-11-22 00:02:40 UTC (rev 10859)
@@ -35,9 +35,10 @@
private String querySubstitutions;
private String showSqlEnabled;
private String commentsEnabled;
- private String secondLevelCacheEnabled;
private String cacheProviderClass;
+ private String cacheProviderConfig;
private String cacheRegionPrefix;
+ private String secondLevelCacheEnabled;
private String minimalPutsEnabled;
private String queryCacheEnabled;
@@ -198,6 +199,14 @@
this.cacheProviderClass = cacheProviderClass;
}
+ public String getCacheProviderConfig() {
+ return cacheProviderConfig;
+ }
+
+ public void setCacheProviderConfig(String cacheProviderConfig) {
+ this.cacheProviderConfig = cacheProviderConfig;
+ }
+
public final String getCacheRegionPrefix() {
return cacheRegionPrefix;
}
@@ -310,10 +319,11 @@
setUnlessNull( props, Environment.QUERY_SUBSTITUTIONS, querySubstitutions );
setUnlessNull( props, Environment.SHOW_SQL, showSqlEnabled );
setUnlessNull( props, Environment.USE_SQL_COMMENTS, commentsEnabled );
- setUnlessNull( props, Environment.USE_SECOND_LEVEL_CACHE, secondLevelCacheEnabled );
setUnlessNull( props, Environment.CACHE_PROVIDER, cacheProviderClass );
+ setUnlessNull( props, Environment.CACHE_PROVIDER_CONFIG, cacheProviderConfig );
setUnlessNull( props, Environment.CACHE_REGION_PREFIX, cacheRegionPrefix );
setUnlessNull( props, Environment.USE_MINIMAL_PUTS, minimalPutsEnabled );
+ setUnlessNull( props, Environment.USE_SECOND_LEVEL_CACHE, secondLevelCacheEnabled );
setUnlessNull( props, Environment.USE_QUERY_CACHE, queryCacheEnabled );
Map extraProperties = getExtraProperties();
17 years, 9 months
Hibernate SVN: r10858 - in branches/Branch_3_2/Hibernate3/src/org/hibernate: engine persister/entity tuple/entity
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 18:28:29 -0500 (Tue, 21 Nov 2006)
New Revision: 10858
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/Versioning.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java
Log:
HHH-2242 : optimisitc-locking=none on joined-subclass
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/Versioning.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/Versioning.java 2006-11-21 23:28:07 UTC (rev 10857)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/Versioning.java 2006-11-21 23:28:29 UTC (rev 10858)
@@ -4,39 +4,53 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.VersionType;
/**
- * Utility methods for managing versions and timestamps
+ * Utilities for dealing with optimisitic locking values.
+ *
* @author Gavin King
*/
public final class Versioning {
+ /**
+ * Apply no optimistic locking
+ */
+ public static final int OPTIMISTIC_LOCK_NONE = -1;
- private Versioning() {}
+ /**
+ * Apply optimisitc locking based on the defined version or timestamp
+ * property.
+ */
+ public static final int OPTIMISTIC_LOCK_VERSION = 0;
- private static final Log log = LogFactory.getLog(Versioning.class);
+ /**
+ * Apply optimisitc locking based on the a current vs. snapshot comparison
+ * of <b>all</b> properties.
+ */
+ public static final int OPTIMISTIC_LOCK_ALL = 2;
/**
- * Increment the given version number
+ * Apply optimisitc locking based on the a current vs. snapshot comparison
+ * of <b>dirty</b> properties.
*/
- public static Object increment(Object version, VersionType versionType, SessionImplementor session) {
- Object next = versionType.next( version, session );
- if ( log.isTraceEnabled() ) {
- log.trace(
- "Incrementing: " +
- versionType.toLoggableString( version, session.getFactory() ) +
- " to " +
- versionType.toLoggableString( next, session.getFactory() )
- );
- }
- return next;
- }
+ public static final int OPTIMISTIC_LOCK_DIRTY = 1;
+ private static final Log log = LogFactory.getLog( Versioning.class );
+
/**
- * Create an initial version number
+ * Private constructor disallowing instantiation.
*/
+ private Versioning() {}
+
+ /**
+ * Create an initial optimisitc locking value according the {@link VersionType}
+ * contract for the version property.
+ *
+ * @param versionType The version type.
+ * @param session The originating session
+ * @return The initial optimisitc locking value
+ */
private static Object seed(VersionType versionType, SessionImplementor session) {
Object seed = versionType.seed( session );
if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed);
@@ -44,7 +58,16 @@
}
/**
- * Seed the given instance state snapshot with an initial version number
+ * Create an initial optimisitc locking value according the {@link VersionType}
+ * contract for the version property <b>if required</b> and inject it into
+ * the snapshot state.
+ *
+ * @param fields The current snapshot state
+ * @param versionProperty The index of the version property
+ * @param versionType The version type
+ * @param session The orginating session
+ * @return True if we injected a new version value into the fields array; false
+ * otherwise.
*/
public static boolean seedVersion(
Object[] fields,
@@ -64,57 +87,86 @@
return true;
}
else {
- if ( log.isTraceEnabled() ) log.trace( "using initial version: " + initialVersion );
+ if ( log.isTraceEnabled() ) {
+ log.trace( "using initial version: " + initialVersion );
+ }
return false;
}
}
- private static Object getVersion(Object[] fields, int versionProperty) {
- return fields[versionProperty];
- }
- private static void setVersion(Object[] fields, Object version, int versionProperty) {
- fields[versionProperty] = version;
+ /**
+ * Generate the next increment in the optimisitc locking value according
+ * the {@link VersionType} contract for the version property.
+ *
+ * @param version The current version
+ * @param versionType The version type
+ * @param session The originating session
+ * @return The incremented optimistic locking value.
+ */
+ public static Object increment(Object version, VersionType versionType, SessionImplementor session) {
+ Object next = versionType.next( version, session );
+ if ( log.isTraceEnabled() ) {
+ log.trace(
+ "Incrementing: " +
+ versionType.toLoggableString( version, session.getFactory() ) +
+ " to " +
+ versionType.toLoggableString( next, session.getFactory() )
+ );
+ }
+ return next;
}
/**
- * Set the version number of the given instance state snapshot
+ * Inject the optimisitc locking value into the entity state snapshot.
+ *
+ * @param fields The state snapshot
+ * @param version The optimisitc locking value
+ * @param persister The entity persister
*/
public static void setVersion(Object[] fields, Object version, EntityPersister persister) {
- setVersion( fields, version, persister.getVersionProperty() );
+ if ( !persister.isVersioned() ) {
+ return;
+ }
+ fields[ persister.getVersionProperty() ] = version;
}
/**
- * Get the version number of the given instance state snapshot
+ * Extract the optimisitc locking value out of the entity state snapshot.
+ *
+ * @param fields The state snapshot
+ * @param persister The entity persister
+ * @return The extracted optimisitc locking value
*/
- public static Object getVersion(Object[] fields, EntityPersister persister) throws HibernateException {
- return persister.isVersioned() ? getVersion( fields, persister.getVersionProperty() ) : null;
+ public static Object getVersion(Object[] fields, EntityPersister persister) {
+ if ( !persister.isVersioned() ) {
+ return null;
+ }
+ return fields[ persister.getVersionProperty() ];
}
/**
* Do we need to increment the version number, given the dirty properties?
+ *
+ * @param dirtyProperties The array of property indexes which were deemed dirty
+ * @param hasDirtyCollections Were any collections found to be dirty (structurally changed)
+ * @param propertyVersionability An array indicating versionability of each property.
+ * @return True if a version increment is required; false otherwise.
*/
public static boolean isVersionIncrementRequired(
- final int[] dirtyProperties,
- final boolean hasDirtyCollections,
- final boolean[] propertyVersionability
- ) {
- if (hasDirtyCollections) return true;
- for ( int i=0; i<dirtyProperties.length; i++) {
- if ( propertyVersionability[ dirtyProperties[i] ] ) return true;
+ final int[] dirtyProperties,
+ final boolean hasDirtyCollections,
+ final boolean[] propertyVersionability) {
+ if ( hasDirtyCollections ) {
+ return true;
}
+ for ( int i = 0; i < dirtyProperties.length; i++ ) {
+ if ( propertyVersionability[ dirtyProperties[i] ] ) {
+ return true;
+ }
+ }
return false;
}
- public static final int OPTIMISTIC_LOCK_NONE = -1;
- public static final int OPTIMISTIC_LOCK_ALL = 2;
- public static final int OPTIMISTIC_LOCK_DIRTY = 1;
- public static final int OPTIMISTIC_LOCK_VERSION = 0;
}
-
-
-
-
-
-
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java 2006-11-21 23:28:07 UTC (rev 10857)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java 2006-11-21 23:28:29 UTC (rev 10858)
@@ -107,11 +107,8 @@
discriminatorSQLString = null;
}
- if ( optimisticLockMode()!=Versioning.OPTIMISTIC_LOCK_VERSION ) {
- throw new MappingException(
- "optimistic-lock attribute not supported for joined-subclass mappings: " +
- getEntityName()
- );
+ if ( optimisticLockMode() > Versioning.OPTIMISTIC_LOCK_VERSION ) {
+ throw new MappingException( "optimistic-lock=all|dirty not supported for joined-subclass mappings [" + getEntityName() + "]" );
}
//MULTITABLES
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java 2006-11-21 23:28:07 UTC (rev 10857)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java 2006-11-21 23:28:29 UTC (rev 10858)
@@ -260,10 +260,10 @@
optimisticLockMode = persistentClass.getOptimisticLockMode();
if ( optimisticLockMode > Versioning.OPTIMISTIC_LOCK_VERSION && !dynamicUpdate ) {
- throw new MappingException( "optimistic-lock setting requires dynamic-update=\"true\": " + name );
+ throw new MappingException( "optimistic-lock=all|dirty requires dynamic-update=\"true\": " + name );
}
if ( versionPropertyIndex != NO_VERSION_INDX && optimisticLockMode > Versioning.OPTIMISTIC_LOCK_VERSION ) {
- throw new MappingException( "version and optimistic-lock are not a valid combination : " + name );
+ throw new MappingException( "version and optimistic-lock=all|dirty are not a valid combination : " + name );
}
hasCollections = foundCollection;
17 years, 9 months
Hibernate SVN: r10857 - in trunk/Hibernate3/src/org/hibernate: engine persister/entity tuple/entity
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 18:28:07 -0500 (Tue, 21 Nov 2006)
New Revision: 10857
Modified:
trunk/Hibernate3/src/org/hibernate/engine/Versioning.java
trunk/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
trunk/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java
Log:
HHH-2242 : optimisitc-locking=none on joined-subclass
Modified: trunk/Hibernate3/src/org/hibernate/engine/Versioning.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/Versioning.java 2006-11-21 21:57:42 UTC (rev 10856)
+++ trunk/Hibernate3/src/org/hibernate/engine/Versioning.java 2006-11-21 23:28:07 UTC (rev 10857)
@@ -4,39 +4,53 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.VersionType;
/**
- * Utility methods for managing versions and timestamps
+ * Utilities for dealing with optimisitic locking values.
+ *
* @author Gavin King
*/
public final class Versioning {
+ /**
+ * Apply no optimistic locking
+ */
+ public static final int OPTIMISTIC_LOCK_NONE = -1;
- private Versioning() {}
+ /**
+ * Apply optimisitc locking based on the defined version or timestamp
+ * property.
+ */
+ public static final int OPTIMISTIC_LOCK_VERSION = 0;
- private static final Log log = LogFactory.getLog(Versioning.class);
+ /**
+ * Apply optimisitc locking based on the a current vs. snapshot comparison
+ * of <b>all</b> properties.
+ */
+ public static final int OPTIMISTIC_LOCK_ALL = 2;
/**
- * Increment the given version number
+ * Apply optimisitc locking based on the a current vs. snapshot comparison
+ * of <b>dirty</b> properties.
*/
- public static Object increment(Object version, VersionType versionType, SessionImplementor session) {
- Object next = versionType.next( version, session );
- if ( log.isTraceEnabled() ) {
- log.trace(
- "Incrementing: " +
- versionType.toLoggableString( version, session.getFactory() ) +
- " to " +
- versionType.toLoggableString( next, session.getFactory() )
- );
- }
- return next;
- }
+ public static final int OPTIMISTIC_LOCK_DIRTY = 1;
+ private static final Log log = LogFactory.getLog( Versioning.class );
+
/**
- * Create an initial version number
+ * Private constructor disallowing instantiation.
*/
+ private Versioning() {}
+
+ /**
+ * Create an initial optimisitc locking value according the {@link VersionType}
+ * contract for the version property.
+ *
+ * @param versionType The version type.
+ * @param session The originating session
+ * @return The initial optimisitc locking value
+ */
private static Object seed(VersionType versionType, SessionImplementor session) {
Object seed = versionType.seed( session );
if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed);
@@ -44,7 +58,16 @@
}
/**
- * Seed the given instance state snapshot with an initial version number
+ * Create an initial optimisitc locking value according the {@link VersionType}
+ * contract for the version property <b>if required</b> and inject it into
+ * the snapshot state.
+ *
+ * @param fields The current snapshot state
+ * @param versionProperty The index of the version property
+ * @param versionType The version type
+ * @param session The orginating session
+ * @return True if we injected a new version value into the fields array; false
+ * otherwise.
*/
public static boolean seedVersion(
Object[] fields,
@@ -64,57 +87,86 @@
return true;
}
else {
- if ( log.isTraceEnabled() ) log.trace( "using initial version: " + initialVersion );
+ if ( log.isTraceEnabled() ) {
+ log.trace( "using initial version: " + initialVersion );
+ }
return false;
}
}
- private static Object getVersion(Object[] fields, int versionProperty) {
- return fields[versionProperty];
- }
- private static void setVersion(Object[] fields, Object version, int versionProperty) {
- fields[versionProperty] = version;
+ /**
+ * Generate the next increment in the optimisitc locking value according
+ * the {@link VersionType} contract for the version property.
+ *
+ * @param version The current version
+ * @param versionType The version type
+ * @param session The originating session
+ * @return The incremented optimistic locking value.
+ */
+ public static Object increment(Object version, VersionType versionType, SessionImplementor session) {
+ Object next = versionType.next( version, session );
+ if ( log.isTraceEnabled() ) {
+ log.trace(
+ "Incrementing: " +
+ versionType.toLoggableString( version, session.getFactory() ) +
+ " to " +
+ versionType.toLoggableString( next, session.getFactory() )
+ );
+ }
+ return next;
}
/**
- * Set the version number of the given instance state snapshot
+ * Inject the optimisitc locking value into the entity state snapshot.
+ *
+ * @param fields The state snapshot
+ * @param version The optimisitc locking value
+ * @param persister The entity persister
*/
public static void setVersion(Object[] fields, Object version, EntityPersister persister) {
- setVersion( fields, version, persister.getVersionProperty() );
+ if ( !persister.isVersioned() ) {
+ return;
+ }
+ fields[ persister.getVersionProperty() ] = version;
}
/**
- * Get the version number of the given instance state snapshot
+ * Extract the optimisitc locking value out of the entity state snapshot.
+ *
+ * @param fields The state snapshot
+ * @param persister The entity persister
+ * @return The extracted optimisitc locking value
*/
- public static Object getVersion(Object[] fields, EntityPersister persister) throws HibernateException {
- return persister.isVersioned() ? getVersion( fields, persister.getVersionProperty() ) : null;
+ public static Object getVersion(Object[] fields, EntityPersister persister) {
+ if ( !persister.isVersioned() ) {
+ return null;
+ }
+ return fields[ persister.getVersionProperty() ];
}
/**
* Do we need to increment the version number, given the dirty properties?
+ *
+ * @param dirtyProperties The array of property indexes which were deemed dirty
+ * @param hasDirtyCollections Were any collections found to be dirty (structurally changed)
+ * @param propertyVersionability An array indicating versionability of each property.
+ * @return True if a version increment is required; false otherwise.
*/
public static boolean isVersionIncrementRequired(
- final int[] dirtyProperties,
- final boolean hasDirtyCollections,
- final boolean[] propertyVersionability
- ) {
- if (hasDirtyCollections) return true;
- for ( int i=0; i<dirtyProperties.length; i++) {
- if ( propertyVersionability[ dirtyProperties[i] ] ) return true;
+ final int[] dirtyProperties,
+ final boolean hasDirtyCollections,
+ final boolean[] propertyVersionability) {
+ if ( hasDirtyCollections ) {
+ return true;
}
+ for ( int i = 0; i < dirtyProperties.length; i++ ) {
+ if ( propertyVersionability[ dirtyProperties[i] ] ) {
+ return true;
+ }
+ }
return false;
}
- public static final int OPTIMISTIC_LOCK_NONE = -1;
- public static final int OPTIMISTIC_LOCK_ALL = 2;
- public static final int OPTIMISTIC_LOCK_DIRTY = 1;
- public static final int OPTIMISTIC_LOCK_VERSION = 0;
}
-
-
-
-
-
-
Modified: trunk/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java 2006-11-21 21:57:42 UTC (rev 10856)
+++ trunk/Hibernate3/src/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java 2006-11-21 23:28:07 UTC (rev 10857)
@@ -107,11 +107,8 @@
discriminatorSQLString = null;
}
- if ( optimisticLockMode()!=Versioning.OPTIMISTIC_LOCK_VERSION ) {
- throw new MappingException(
- "optimistic-lock attribute not supported for joined-subclass mappings: " +
- getEntityName()
- );
+ if ( optimisticLockMode() > Versioning.OPTIMISTIC_LOCK_VERSION ) {
+ throw new MappingException( "optimistic-lock=all|dirty not supported for joined-subclass mappings [" + getEntityName() + "]" );
}
//MULTITABLES
Modified: trunk/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java 2006-11-21 21:57:42 UTC (rev 10856)
+++ trunk/Hibernate3/src/org/hibernate/tuple/entity/EntityMetamodel.java 2006-11-21 23:28:07 UTC (rev 10857)
@@ -260,10 +260,10 @@
optimisticLockMode = persistentClass.getOptimisticLockMode();
if ( optimisticLockMode > Versioning.OPTIMISTIC_LOCK_VERSION && !dynamicUpdate ) {
- throw new MappingException( "optimistic-lock setting requires dynamic-update=\"true\": " + name );
+ throw new MappingException( "optimistic-lock=all|dirty requires dynamic-update=\"true\": " + name );
}
if ( versionPropertyIndex != NO_VERSION_INDX && optimisticLockMode > Versioning.OPTIMISTIC_LOCK_VERSION ) {
- throw new MappingException( "version and optimistic-lock are not a valid combination : " + name );
+ throw new MappingException( "version and optimistic-lock=all|dirty are not a valid combination : " + name );
}
hasCollections = foundCollection;
17 years, 9 months
Hibernate SVN: r10856 - trunk/Hibernate3/src/org/hibernate/impl
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 16:57:42 -0500 (Tue, 21 Nov 2006)
New Revision: 10856
Modified:
trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java
Log:
HHH-2250 : Query.setEntity() with null entity
Modified: trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java 2006-11-21 21:57:32 UTC (rev 10855)
+++ trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java 2006-11-21 21:57:42 UTC (rev 10856)
@@ -531,10 +531,17 @@
}
public Query setEntity(int position, Object val) {
- setParameter( position, val, Hibernate.entity( session.bestGuessEntityName(val) ) );
+ setParameter( position, val, Hibernate.entity( resolveEntityName( val ) ) );
return this;
}
+ private String resolveEntityName(Object val) {
+ if ( val == null ) {
+ throw new IllegalArgumentException( "entity for parameter binding cannot be null" );
+ }
+ return session.bestGuessEntityName( val );
+ }
+
public Query setLocale(int position, Locale locale) {
setParameter(position, locale, Hibernate.LOCALE);
return this;
@@ -588,7 +595,7 @@
}
public Query setEntity(String name, Object val) {
- setParameter( name, val, Hibernate.entity( session.bestGuessEntityName(val) ) );
+ setParameter( name, val, Hibernate.entity( resolveEntityName( val ) ) );
return this;
}
17 years, 9 months
Hibernate SVN: r10855 - branches/Branch_3_2/Hibernate3/src/org/hibernate/impl
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 16:57:32 -0500 (Tue, 21 Nov 2006)
New Revision: 10855
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java
Log:
HHH-2250 : Query.setEntity() with null entity
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java 2006-11-21 17:42:48 UTC (rev 10854)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java 2006-11-21 21:57:32 UTC (rev 10855)
@@ -531,10 +531,17 @@
}
public Query setEntity(int position, Object val) {
- setParameter( position, val, Hibernate.entity( session.bestGuessEntityName(val) ) );
+ setParameter( position, val, Hibernate.entity( resolveEntityName( val ) ) );
return this;
}
+ private String resolveEntityName(Object val) {
+ if ( val == null ) {
+ throw new IllegalArgumentException( "entity for parameter binding cannot be null" );
+ }
+ return session.bestGuessEntityName( val );
+ }
+
public Query setLocale(int position, Locale locale) {
setParameter(position, locale, Hibernate.LOCALE);
return this;
@@ -588,7 +595,7 @@
}
public Query setEntity(String name, Object val) {
- setParameter( name, val, Hibernate.entity( session.bestGuessEntityName(val) ) );
+ setParameter( name, val, Hibernate.entity( resolveEntityName( val ) ) );
return this;
}
17 years, 9 months
Hibernate SVN: r10854 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 12:42:48 -0500 (Tue, 21 Nov 2006)
New Revision: 10854
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
Log:
HHH-1851 : add tests to AllTests
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-11-21 17:42:38 UTC (rev 10853)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-11-21 17:42:48 UTC (rev 10854)
@@ -50,6 +50,7 @@
import org.hibernate.test.id.MultipleHiLoPerTableGeneratorTest;
import org.hibernate.test.idbag.IdBagTest;
import org.hibernate.test.idclass.IdClassTest;
+import org.hibernate.test.idprops.IdentifierPropertyReferencesTest;
import org.hibernate.test.immutable.ImmutableTest;
import org.hibernate.test.instrument.buildtime.InstrumentTest;
import org.hibernate.test.instrument.runtime.CGLIBInstrumentationTest;
@@ -292,6 +293,7 @@
suite.addTest( AnyTypeTest.suite() );
suite.addTest( SQLFunctionsInterSystemsTest.suite() );
suite.addTest( LobSuite.suite() );
+ suite.addTest( IdentifierPropertyReferencesTest.suite() );
return filter( suite );
//return suite;
17 years, 9 months