HHH-2907 Changing ValueGenerator contract in order to allow implementations performing work using the JDBC connection

This commit is contained in:
Gunnar Morling 2013-11-01 16:43:46 +01:00 committed by Steve Ebersole
parent 9938937fe7
commit a860e6559d
2 changed files with 5 additions and 4 deletions

View File

@ -47,6 +47,7 @@ import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
import org.hibernate.Session;
import org.hibernate.StaleObjectStateException;
import org.hibernate.StaleStateException;
import org.hibernate.bytecode.instrumentation.spi.FieldInterceptor;
@ -3456,7 +3457,7 @@ public abstract class AbstractEntityPersister
final InMemoryValueGenerationStrategy[] strategies = getEntityMetamodel().getInMemoryValueGenerationStrategies();
for ( int i = 0; i < strategies.length; i++ ) {
if ( strategies[i] != null && strategies[i].getGenerationTiming().includesUpdate() ) {
fields[i] = strategies[i].getValueGenerator().generateValue( session, object );
fields[i] = strategies[i].getValueGenerator().generateValue( (Session) session, object );
setPropertyValue( object, i, fields[i] );
// todo : probably best to add to dirtyFields if not-null
}
@ -3566,7 +3567,7 @@ public abstract class AbstractEntityPersister
final InMemoryValueGenerationStrategy[] strategies = getEntityMetamodel().getInMemoryValueGenerationStrategies();
for ( int i = 0; i < strategies.length; i++ ) {
if ( strategies[i] != null && strategies[i].getGenerationTiming().includesInsert() ) {
fields[i] = strategies[i].getValueGenerator().generateValue( session, object );
fields[i] = strategies[i].getValueGenerator().generateValue( (Session) session, object );
setPropertyValue( object, i, fields[i] );
}
}

View File

@ -23,7 +23,7 @@
*/
package org.hibernate.tuple;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.Session;
/**
* Defines a generator for in-VM generation of (non-identifier) attribute values.
@ -39,5 +39,5 @@ public interface ValueGenerator<T> {
*
* @return The generated value
*/
public T generateValue(SessionImplementor session, Object owner);
public T generateValue(Session session, Object owner);
}