version reset should not be affected by the id being assigned or generated
improve javadoc for this stuff Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
b948fde3b3
commit
00f6115b42
|
@ -131,6 +131,11 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
|
|||
|
||||
BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder();
|
||||
|
||||
/**
|
||||
* Should generated identifiers be reset after entity removal?
|
||||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_IDENTIFIER_ROLLBACK
|
||||
*/
|
||||
boolean isIdentifierRollbackEnabled();
|
||||
|
||||
boolean isCheckNullability();
|
||||
|
|
|
@ -170,6 +170,7 @@ public interface AvailableSettings
|
|||
/**
|
||||
* When enabled, specifies that the generated identifier of an entity is unset
|
||||
* when the entity is {@linkplain org.hibernate.Session#remove(Object) deleted}.
|
||||
* If the entity is versioned, the version is also reset to its default value.
|
||||
*
|
||||
* @settingDefault {@code false} - generated identifiers are not unset
|
||||
*
|
||||
|
|
|
@ -80,8 +80,8 @@ public class VersionValue implements UnsavedValueStrategy {
|
|||
if ( version == null ) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if ( version instanceof Number ) {
|
||||
return ((Number) version).longValue() < 0L;
|
||||
if ( version instanceof Number number ) {
|
||||
return number.longValue() < 0L;
|
||||
}
|
||||
throw new MappingException( "unsaved-value NEGATIVE may only be used with short, int and long types" );
|
||||
}
|
||||
|
|
|
@ -4359,14 +4359,11 @@ public abstract class AbstractEntityPersister
|
|||
Object currentId,
|
||||
Object currentVersion,
|
||||
SharedSessionContractImplementor session) {
|
||||
if ( entityMetamodel.getIdentifierProperty().getGenerator().allowAssignedIdentifiers() ) {
|
||||
return;
|
||||
if ( !getGenerator().allowAssignedIdentifiers() ) {
|
||||
// reset the identifier
|
||||
final Object defaultIdentifier = identifierMapping.getUnsavedStrategy().getDefaultValue( currentId );
|
||||
setIdentifier( entity, defaultIdentifier, session );
|
||||
}
|
||||
|
||||
// reset the identifier
|
||||
final Object defaultIdentifier = identifierMapping.getUnsavedStrategy().getDefaultValue( currentId );
|
||||
setIdentifier( entity, defaultIdentifier, session );
|
||||
|
||||
// reset the version
|
||||
if ( versionMapping != null ) {
|
||||
final Object defaultVersion = versionMapping.getUnsavedStrategy().getDefaultValue( currentVersion );
|
||||
|
|
|
@ -1195,6 +1195,9 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget
|
|||
/**
|
||||
* Set the identifier and version of the given instance back to its "unsaved"
|
||||
* value, that is, the value it had before it was made persistent.
|
||||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#USE_IDENTIFIER_ROLLBACK
|
||||
* @see org.hibernate.boot.spi.SessionFactoryOptions#isIdentifierRollbackEnabled
|
||||
*/
|
||||
void resetIdentifier(Object entity, Object currentId, Object currentVersion, SharedSessionContractImplementor session);
|
||||
|
||||
|
|
Loading…
Reference in New Issue