mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-13823 Changes for Hibernate RX
Mostly just expose some operations and constructors that were previously inaccessible.
This commit is contained in:
parent
da019405b6
commit
f59f0ce406
@ -69,6 +69,30 @@ public EntityDeleteAction(
|
||||
);
|
||||
}
|
||||
|
||||
public Object getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public boolean isCascadeDeleteEnabled() {
|
||||
return isCascadeDeleteEnabled;
|
||||
}
|
||||
|
||||
public Object[] getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
protected Object[] getNaturalIdValues() {
|
||||
return naturalIdValues;
|
||||
}
|
||||
|
||||
protected SoftLock getLock() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
protected void setLock(SoftLock lock) {
|
||||
this.lock = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws HibernateException {
|
||||
final Serializable id = getId();
|
||||
@ -128,7 +152,7 @@ public void execute() throws HibernateException {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean preDelete() {
|
||||
protected boolean preDelete() {
|
||||
boolean veto = false;
|
||||
final EventListenerGroup<PreDeleteEventListener> listenerGroup = listenerGroup( EventType.PRE_DELETE );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
@ -141,7 +165,7 @@ private boolean preDelete() {
|
||||
return veto;
|
||||
}
|
||||
|
||||
private void postDelete() {
|
||||
protected void postDelete() {
|
||||
final EventListenerGroup<PostDeleteEventListener> listenerGroup = listenerGroup( EventType.POST_DELETE );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
return;
|
||||
@ -158,7 +182,7 @@ private void postDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
private void postCommitDelete(boolean success) {
|
||||
protected void postCommitDelete(boolean success) {
|
||||
final EventListenerGroup<PostDeleteEventListener> listenerGroup = listenerGroup( EventType.POST_COMMIT_DELETE );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
return;
|
||||
|
@ -29,7 +29,7 @@
|
||||
*
|
||||
* @see EntityInsertAction
|
||||
*/
|
||||
public final class EntityIdentityInsertAction extends AbstractEntityInsertAction {
|
||||
public class EntityIdentityInsertAction extends AbstractEntityInsertAction {
|
||||
|
||||
private final boolean isDelayed;
|
||||
private final EntityKey delayedEntityKey;
|
||||
@ -141,7 +141,7 @@ public void doAfterTransactionCompletion(boolean success, SharedSessionContractI
|
||||
postCommitInsert( success );
|
||||
}
|
||||
|
||||
private void postInsert() {
|
||||
protected void postInsert() {
|
||||
final EventSource eventSource = eventSource();
|
||||
if ( isDelayed ) {
|
||||
eventSource.getPersistenceContextInternal().replaceDelayedEntityIdentityInsertKeys( delayedEntityKey, generatedId );
|
||||
@ -163,7 +163,7 @@ private void postInsert() {
|
||||
}
|
||||
}
|
||||
|
||||
private void postCommitInsert(boolean success) {
|
||||
protected void postCommitInsert(boolean success) {
|
||||
final EventListenerGroup<PostInsertEventListener> listenerGroup = listenerGroup( EventType.POST_COMMIT_INSERT );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
return;
|
||||
@ -191,7 +191,7 @@ private void postCommitInsert(boolean success) {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean preInsert() {
|
||||
protected boolean preInsert() {
|
||||
final EventListenerGroup<PreInsertEventListener> listenerGroup = listenerGroup( EventType.PRE_INSERT );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
// NO_VETO
|
||||
@ -241,7 +241,7 @@ private static DelayedPostInsertIdentifier generateDelayedPostInsertIdentifier()
|
||||
return new DelayedPostInsertIdentifier();
|
||||
}
|
||||
|
||||
private EntityKey generateDelayedEntityKey() {
|
||||
protected EntityKey generateDelayedEntityKey() {
|
||||
if ( !isDelayed ) {
|
||||
throw new AssertionFailure( "cannot request delayed entity-key for early-insert post-insert-id generation" );
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
*
|
||||
* @see EntityIdentityInsertAction
|
||||
*/
|
||||
public final class EntityInsertAction extends AbstractEntityInsertAction {
|
||||
public class EntityInsertAction extends AbstractEntityInsertAction {
|
||||
private Object version;
|
||||
private Object cacheEntry;
|
||||
|
||||
@ -62,6 +62,22 @@ public EntityInsertAction(
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Object getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Object version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
protected Object getCacheEntry() {
|
||||
return cacheEntry;
|
||||
}
|
||||
|
||||
protected void setCacheEntry(Object cacheEntry) {
|
||||
this.cacheEntry = cacheEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEarlyInsert() {
|
||||
return false;
|
||||
@ -143,7 +159,7 @@ public void execute() throws HibernateException {
|
||||
markExecuted();
|
||||
}
|
||||
|
||||
private boolean cacheInsert(EntityPersister persister, Object ck) {
|
||||
protected boolean cacheInsert(EntityPersister persister, Object ck) {
|
||||
SharedSessionContractImplementor session = getSession();
|
||||
try {
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
@ -154,7 +170,7 @@ private boolean cacheInsert(EntityPersister persister, Object ck) {
|
||||
}
|
||||
}
|
||||
|
||||
private void postInsert() {
|
||||
protected void postInsert() {
|
||||
final EventListenerGroup<PostInsertEventListener> listenerGroup = listenerGroup( EventType.POST_INSERT );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
return;
|
||||
@ -171,7 +187,7 @@ private void postInsert() {
|
||||
}
|
||||
}
|
||||
|
||||
private void postCommitInsert(boolean success) {
|
||||
protected void postCommitInsert(boolean success) {
|
||||
final EventListenerGroup<PostInsertEventListener> listenerGroup = listenerGroup( EventType.POST_COMMIT_INSERT );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
return;
|
||||
@ -199,7 +215,7 @@ private void postCommitInsert(boolean success) {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean preInsert() {
|
||||
protected boolean preInsert() {
|
||||
boolean veto = false;
|
||||
|
||||
final EventListenerGroup<PreInsertEventListener> listenerGroup = listenerGroup( EventType.PRE_INSERT );
|
||||
@ -233,7 +249,7 @@ public void doAfterTransactionCompletion(boolean success, SharedSessionContractI
|
||||
postCommitInsert( success );
|
||||
}
|
||||
|
||||
private boolean cacheAfterInsert(EntityDataAccess cache, Object ck) {
|
||||
protected boolean cacheAfterInsert(EntityDataAccess cache, Object ck) {
|
||||
SharedSessionContractImplementor session = getSession();
|
||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
try {
|
||||
@ -256,8 +272,8 @@ protected boolean hasPostCommitEventListeners() {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isCachePutEnabled(EntityPersister persister, SharedSessionContractImplementor session) {
|
||||
|
||||
protected boolean isCachePutEnabled(EntityPersister persister, SharedSessionContractImplementor session) {
|
||||
return persister.canWriteToCache()
|
||||
&& !persister.isCacheInvalidationRequired()
|
||||
&& session.getCacheMode().isPutEnabled();
|
||||
|
@ -37,7 +37,7 @@
|
||||
/**
|
||||
* The action for performing entity updates.
|
||||
*/
|
||||
public final class EntityUpdateAction extends EntityAction {
|
||||
public class EntityUpdateAction extends EntityAction {
|
||||
private final Object[] state;
|
||||
private final Object[] previousState;
|
||||
private final Object previousVersion;
|
||||
@ -112,6 +112,58 @@ private Object[] determinePreviousNaturalIdValues(
|
||||
return persistenceContext.getNaturalIdSnapshot( id, persister );
|
||||
}
|
||||
|
||||
public Object[] getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Object[] getPreviousState() {
|
||||
return previousState;
|
||||
}
|
||||
|
||||
public Object getPreviousVersion() {
|
||||
return previousVersion;
|
||||
}
|
||||
|
||||
public Object getNextVersion() {
|
||||
return nextVersion;
|
||||
}
|
||||
|
||||
public void setNextVersion(Object nextVersion) {
|
||||
this.nextVersion = nextVersion;
|
||||
}
|
||||
|
||||
public int[] getDirtyFields() {
|
||||
return dirtyFields;
|
||||
}
|
||||
|
||||
public boolean hasDirtyCollection() {
|
||||
return hasDirtyCollection;
|
||||
}
|
||||
|
||||
public Object getRowId() {
|
||||
return rowId;
|
||||
}
|
||||
|
||||
public Object[] getPreviousNaturalIdValues() {
|
||||
return previousNaturalIdValues;
|
||||
}
|
||||
|
||||
protected Object getCacheEntry() {
|
||||
return cacheEntry;
|
||||
}
|
||||
|
||||
protected void setCacheEntry(Object cacheEntry) {
|
||||
this.cacheEntry = cacheEntry;
|
||||
}
|
||||
|
||||
protected SoftLock getLock() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
protected void setLock(SoftLock lock) {
|
||||
this.lock = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws HibernateException {
|
||||
final Serializable id = getId();
|
||||
@ -223,7 +275,7 @@ else if ( session.getCacheMode().isPutEnabled() ) {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cacheUpdate(EntityPersister persister, Object previousVersion, Object ck) {
|
||||
protected boolean cacheUpdate(EntityPersister persister, Object previousVersion, Object ck) {
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
try {
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
@ -234,7 +286,7 @@ private boolean cacheUpdate(EntityPersister persister, Object previousVersion, O
|
||||
}
|
||||
}
|
||||
|
||||
private boolean preUpdate() {
|
||||
protected boolean preUpdate() {
|
||||
boolean veto = false;
|
||||
final EventListenerGroup<PreUpdateEventListener> listenerGroup = listenerGroup( EventType.PRE_UPDATE );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
@ -254,7 +306,7 @@ private boolean preUpdate() {
|
||||
return veto;
|
||||
}
|
||||
|
||||
private void postUpdate() {
|
||||
protected void postUpdate() {
|
||||
final EventListenerGroup<PostUpdateEventListener> listenerGroup = listenerGroup( EventType.POST_UPDATE );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
return;
|
||||
@ -273,7 +325,7 @@ private void postUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
private void postCommitUpdate(boolean success) {
|
||||
protected void postCommitUpdate(boolean success) {
|
||||
final EventListenerGroup<PostUpdateEventListener> listenerGroup = listenerGroup( EventType.POST_COMMIT_UPDATE );
|
||||
if ( listenerGroup.isEmpty() ) {
|
||||
return;
|
||||
@ -350,7 +402,7 @@ public void doAfterTransactionCompletion(boolean success, SharedSessionContractI
|
||||
postCommitUpdate( success );
|
||||
}
|
||||
|
||||
private boolean cacheAfterUpdate(EntityDataAccess cache, Object ck) {
|
||||
protected boolean cacheAfterUpdate(EntityDataAccess cache, Object ck) {
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
try {
|
||||
|
@ -17,7 +17,6 @@
|
||||
import org.hibernate.classic.Lifecycle;
|
||||
import org.hibernate.engine.internal.Cascade;
|
||||
import org.hibernate.engine.internal.CascadePoint;
|
||||
import org.hibernate.engine.internal.ForeignKeys;
|
||||
import org.hibernate.engine.internal.Versioning;
|
||||
import org.hibernate.engine.spi.CascadingAction;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
@ -49,10 +48,6 @@ public abstract class AbstractSaveEventListener
|
||||
implements CallbackRegistryConsumer {
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractSaveEventListener.class );
|
||||
|
||||
public enum EntityState {
|
||||
PERSISTENT, TRANSIENT, DETACHED, DELETED
|
||||
}
|
||||
|
||||
private CallbackRegistry callbackRegistry;
|
||||
|
||||
public void injectCallbackRegistry(CallbackRegistry callbackRegistry) {
|
||||
@ -477,60 +472,4 @@ protected void cascadeAfterSave(
|
||||
|
||||
protected abstract CascadingAction getCascadeAction();
|
||||
|
||||
/**
|
||||
* Determine whether the entity is persistent, detached, or transient
|
||||
*
|
||||
* @param entity The entity to check
|
||||
* @param entityName The name of the entity
|
||||
* @param entry The entity's entry in the persistence context
|
||||
* @param source The originating session.
|
||||
*
|
||||
* @return The state.
|
||||
*/
|
||||
protected EntityState getEntityState(
|
||||
Object entity,
|
||||
String entityName,
|
||||
EntityEntry entry, //pass this as an argument only to avoid double looking
|
||||
SessionImplementor source) {
|
||||
|
||||
if ( entry != null ) { // the object is persistent
|
||||
|
||||
//the entity is associated with the session, so check its status
|
||||
if ( entry.getStatus() != Status.DELETED ) {
|
||||
// do nothing for persistent instances
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Persistent instance of: {0}", getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return EntityState.PERSISTENT;
|
||||
}
|
||||
// ie. e.status==DELETED
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Deleted instance of: {0}", getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return EntityState.DELETED;
|
||||
}
|
||||
// the object is transient or detached
|
||||
|
||||
// the entity is not associated with the session, so
|
||||
// try interceptor and unsaved-value
|
||||
|
||||
if ( ForeignKeys.isTransient( entityName, entity, getAssumedUnsaved(), source ) ) {
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Transient instance of: {0}", getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return EntityState.TRANSIENT;
|
||||
}
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Detached instance of: {0}", getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return EntityState.DETACHED;
|
||||
}
|
||||
|
||||
protected String getLoggableName(String entityName, Object entity) {
|
||||
return entityName == null ? entity.getClass().getName() : entityName;
|
||||
}
|
||||
|
||||
protected Boolean getAssumedUnsaved() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ else if ( type.isComponentType() ) {
|
||||
* @param persister
|
||||
* @throws HibernateException
|
||||
*/
|
||||
void process(Object object, EntityPersister persister)
|
||||
public void process(Object object, EntityPersister persister)
|
||||
throws HibernateException {
|
||||
processEntityPropertyValues(
|
||||
persister.getPropertyValues( object ),
|
||||
|
@ -145,13 +145,7 @@ public void onDelete(DeleteEvent event, Set transientEntities) throws HibernateE
|
||||
version = entityEntry.getVersion();
|
||||
}
|
||||
|
||||
/*if ( !persister.isMutable() ) {
|
||||
throw new HibernateException(
|
||||
"attempted to delete an object of immutable class: " +
|
||||
MessageHelper.infoString(persister)
|
||||
);
|
||||
}*/
|
||||
|
||||
callbackRegistry.preRemove( entity );
|
||||
if ( invokeDeleteLifecycle( source, entity, persister ) ) {
|
||||
return;
|
||||
}
|
||||
@ -338,8 +332,6 @@ private Object[] createDeletedState(EntityPersister persister, Object[] currentS
|
||||
}
|
||||
|
||||
protected boolean invokeDeleteLifecycle(EventSource session, Object entity, EntityPersister persister) {
|
||||
callbackRegistry.preRemove( entity );
|
||||
|
||||
if ( persister.implementsLifecycle() ) {
|
||||
LOG.debug( "Calling onDelete()" );
|
||||
if ( ( (Lifecycle) entity ).onDelete( session ) ) {
|
||||
|
@ -164,7 +164,7 @@ else if ( original instanceof PersistentAttributeInterceptable ) {
|
||||
}
|
||||
|
||||
if ( entityState == null ) {
|
||||
entityState = getEntityState( entity, event.getEntityName(), entry, source );
|
||||
entityState = EntityState.getEntityState( entity, event.getEntityName(), entry, source, false );
|
||||
}
|
||||
|
||||
switch ( entityState ) {
|
||||
@ -181,7 +181,7 @@ else if ( original instanceof PersistentAttributeInterceptable ) {
|
||||
throw new ObjectDeletedException(
|
||||
"deleted instance passed to merge",
|
||||
null,
|
||||
getLoggableName( event.getEntityName(), entity )
|
||||
EventUtil.getLoggableName( event.getEntityName(), entity )
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -536,11 +536,6 @@ protected CascadingAction getCascadeAction() {
|
||||
return CascadingActions.MERGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getAssumedUnsaved() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cascade behavior is redefined by this subclass, disable superclass behavior
|
||||
*/
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
package org.hibernate.event.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -24,7 +23,6 @@
|
||||
import org.hibernate.id.ForeignGenerator;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.jpa.event.spi.CallbackRegistry;
|
||||
import org.hibernate.jpa.event.spi.CallbackRegistryConsumer;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.pretty.MessageHelper;
|
||||
@ -47,11 +45,6 @@ protected CascadingAction getCascadeAction() {
|
||||
return CascadingActions.PERSIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getAssumedUnsaved() {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the given create event.
|
||||
*
|
||||
@ -99,7 +92,7 @@ public void onPersist(PersistEvent event, Map createCache) throws HibernateExcep
|
||||
}
|
||||
|
||||
final EntityEntry entityEntry = source.getPersistenceContextInternal().getEntry( entity );
|
||||
EntityState entityState = getEntityState( entity, entityName, entityEntry, source );
|
||||
EntityState entityState = EntityState.getEntityState( entity, entityName, entityEntry, source, true );
|
||||
if ( entityState == EntityState.DETACHED ) {
|
||||
// JPA 2, in its version of a "foreign generated", allows the id attribute value
|
||||
// to be manually set by the user, even though this manual value is irrelevant.
|
||||
@ -116,7 +109,7 @@ public void onPersist(PersistEvent event, Map createCache) throws HibernateExcep
|
||||
LOG.debug( "Resetting entity id attribute to null for foreign generator" );
|
||||
}
|
||||
persister.setIdentifier( entity, null, source );
|
||||
entityState = getEntityState( entity, entityName, entityEntry, source );
|
||||
entityState = EntityState.getEntityState( entity, entityName, entityEntry, source, true );
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +117,7 @@ public void onPersist(PersistEvent event, Map createCache) throws HibernateExcep
|
||||
case DETACHED: {
|
||||
throw new PersistentObjectException(
|
||||
"detached entity passed to persist: " +
|
||||
getLoggableName( event.getEntityName(), entity )
|
||||
EventUtil.getLoggableName( event.getEntityName(), entity )
|
||||
);
|
||||
}
|
||||
case PERSISTENT: {
|
||||
@ -146,7 +139,7 @@ public void onPersist(PersistEvent event, Map createCache) throws HibernateExcep
|
||||
throw new ObjectDeletedException(
|
||||
"deleted entity passed to persist",
|
||||
null,
|
||||
getLoggableName( event.getEntityName(), entity )
|
||||
EventUtil.getLoggableName( event.getEntityName(), entity )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -67,10 +67,14 @@ else if ( LockMode.OPTIMISTIC.equals( lockMode ) ) {
|
||||
session.getActionQueue().registerProcess( verifyVersion );
|
||||
}
|
||||
|
||||
invokeLoadLifecycle(event, session);
|
||||
|
||||
}
|
||||
|
||||
protected void invokeLoadLifecycle(PostLoadEvent event, EventSource session) {
|
||||
if ( event.getPersister().implementsLifecycle() ) {
|
||||
//log.debug( "calling onLoad()" );
|
||||
( (Lifecycle) event.getEntity() ).onLoad( session, event.getId() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -82,11 +82,12 @@ protected boolean reassociateIfUninitializedProxy(Object object, SessionImplemen
|
||||
}
|
||||
|
||||
protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event) {
|
||||
EntityState entityState = getEntityState(
|
||||
EntityState entityState = EntityState.getEntityState(
|
||||
event.getEntity(),
|
||||
event.getEntityName(),
|
||||
event.getEntry(),
|
||||
event.getSession()
|
||||
event.getSession(),
|
||||
null
|
||||
);
|
||||
|
||||
switch ( entityState ) {
|
||||
|
@ -25,12 +25,12 @@ public class DirtyCollectionSearchVisitor extends AbstractVisitor {
|
||||
private boolean dirty;
|
||||
private boolean[] propertyVersionability;
|
||||
|
||||
DirtyCollectionSearchVisitor(EventSource session, boolean[] propertyVersionability) {
|
||||
public DirtyCollectionSearchVisitor(EventSource session, boolean[] propertyVersionability) {
|
||||
super( session );
|
||||
this.propertyVersionability = propertyVersionability;
|
||||
}
|
||||
|
||||
boolean wasDirtyCollectionFound() {
|
||||
public boolean wasDirtyCollectionFound() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.internal;
|
||||
|
||||
import org.hibernate.engine.internal.ForeignKeys;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
|
||||
public enum EntityState {
|
||||
PERSISTENT, TRANSIENT, DETACHED, DELETED;
|
||||
|
||||
static final CoreMessageLogger LOG = CoreLogging.messageLogger( EntityState.class );
|
||||
|
||||
/**
|
||||
* Determine whether the entity is persistent, detached, or transient
|
||||
*
|
||||
* @param entity The entity to check
|
||||
* @param entityName The name of the entity
|
||||
* @param entry The entity's entry in the persistence context
|
||||
* @param source The originating session.
|
||||
*
|
||||
* @return The state.
|
||||
*/
|
||||
public static EntityState getEntityState(
|
||||
Object entity,
|
||||
String entityName,
|
||||
EntityEntry entry, //pass this as an argument only to avoid double looking
|
||||
SessionImplementor source,
|
||||
Boolean assumedUnsaved) {
|
||||
|
||||
if ( entry != null ) { // the object is persistent
|
||||
|
||||
//the entity is associated with the session, so check its status
|
||||
if ( entry.getStatus() != Status.DELETED ) {
|
||||
// do nothing for persistent instances
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Persistent instance of: {0}", EventUtil.getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return PERSISTENT;
|
||||
}
|
||||
// ie. e.status==DELETED
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Deleted instance of: {0}", EventUtil.getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return DELETED;
|
||||
}
|
||||
// the object is transient or detached
|
||||
|
||||
// the entity is not associated with the session, so
|
||||
// try interceptor and unsaved-value
|
||||
|
||||
if ( ForeignKeys.isTransient( entityName, entity, assumedUnsaved, source ) ) {
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Transient instance of: {0}", EventUtil.getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return TRANSIENT;
|
||||
}
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Detached instance of: {0}", EventUtil.getLoggableName( entityName, entity ) );
|
||||
}
|
||||
return DETACHED;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.internal;
|
||||
|
||||
public class EventUtil {
|
||||
public static String getLoggableName(String entityName, Object entity) {
|
||||
return entityName == null ? entity.getClass().getName() : entityName;
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ public class EvictVisitor extends AbstractVisitor {
|
||||
|
||||
private Object owner;
|
||||
|
||||
EvictVisitor(EventSource session, Object owner) {
|
||||
public EvictVisitor(EventSource session, Object owner) {
|
||||
super(session);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
public class FlushVisitor extends AbstractVisitor {
|
||||
private Object owner;
|
||||
|
||||
FlushVisitor(EventSource session, Object owner) {
|
||||
public FlushVisitor(EventSource session, Object owner) {
|
||||
super(session);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class OnReplicateVisitor extends ReattachVisitor {
|
||||
|
||||
private boolean isUpdate;
|
||||
|
||||
OnReplicateVisitor(EventSource session, Serializable key, Object owner, boolean isUpdate) {
|
||||
public OnReplicateVisitor(EventSource session, Serializable key, Object owner, boolean isUpdate) {
|
||||
super( session, key, owner );
|
||||
this.isUpdate = isUpdate;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
*/
|
||||
public class OnUpdateVisitor extends ReattachVisitor {
|
||||
|
||||
OnUpdateVisitor(EventSource session, Serializable key, Object owner) {
|
||||
public OnUpdateVisitor(EventSource session, Serializable key, Object owner) {
|
||||
super( session, key, owner );
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
public abstract class ProxyVisitor extends AbstractVisitor {
|
||||
|
||||
|
||||
public ProxyVisitor(EventSource session) {
|
||||
super(session);
|
||||
}
|
||||
|
@ -42,11 +42,11 @@ public WrapVisitor(Object entity, Serializable id, EventSource session) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
boolean isSubstitutionRequired() {
|
||||
public boolean isSubstitutionRequired() {
|
||||
return substitute;
|
||||
}
|
||||
|
||||
WrapVisitor(EventSource session) {
|
||||
public WrapVisitor(EventSource session) {
|
||||
super( session );
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ Object processComponent(Object component, CompositeType componentType) throws Hi
|
||||
}
|
||||
|
||||
@Override
|
||||
void process(Object object, EntityPersister persister) throws HibernateException {
|
||||
public void process(Object object, EntityPersister persister) throws HibernateException {
|
||||
final Object[] values = persister.getPropertyValues( object );
|
||||
final Type[] types = persister.getPropertyTypes();
|
||||
processEntityPropertyValues( values, types );
|
||||
|
@ -152,7 +152,7 @@
|
||||
* @author Steve Ebersole
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||
public class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( SessionFactoryImpl.class );
|
||||
|
||||
private final String name;
|
||||
@ -1121,7 +1121,7 @@ else if ( statelessInterceptorImplementorSupplier != null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class SessionBuilderImpl<T extends SessionBuilder> implements SessionBuilderImplementor<T>, SessionCreationOptions {
|
||||
public static class SessionBuilderImpl<T extends SessionBuilder> implements SessionBuilderImplementor<T>, SessionCreationOptions {
|
||||
private static final Logger log = CoreLogging.logger( SessionBuilderImpl.class );
|
||||
|
||||
private final SessionFactoryImpl sessionFactory;
|
||||
@ -1145,7 +1145,7 @@ static class SessionBuilderImpl<T extends SessionBuilder> implements SessionBuil
|
||||
//todo : expose setting
|
||||
private SessionOwnerBehavior sessionOwnerBehavior = SessionOwnerBehavior.LEGACY_NATIVE;
|
||||
|
||||
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
|
||||
public SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
|
||||
// set up default builder values...
|
||||
|
@ -194,7 +194,7 @@
|
||||
* @author Chris Cranford
|
||||
* @author Sanne Grinovero
|
||||
*/
|
||||
public final class SessionImpl
|
||||
public class SessionImpl
|
||||
extends AbstractSessionImpl
|
||||
implements EventSource, SessionImplementor, HibernateEntityManagerImplementor {
|
||||
private static final EntityManagerMessageLogger log = HEMLogging.messageLogger( SessionImpl.class );
|
||||
|
@ -338,15 +338,15 @@ protected boolean isClassOrSuperclassJoin(int j) {
|
||||
|
||||
public abstract int getSubclassTableSpan();
|
||||
|
||||
protected abstract int getTableSpan();
|
||||
public abstract int getTableSpan();
|
||||
|
||||
protected abstract boolean isTableCascadeDeleteEnabled(int j);
|
||||
public abstract boolean isTableCascadeDeleteEnabled(int j);
|
||||
|
||||
protected abstract String getTableName(int j);
|
||||
public abstract String getTableName(int j);
|
||||
|
||||
protected abstract String[] getKeyColumns(int j);
|
||||
public abstract String[] getKeyColumns(int j);
|
||||
|
||||
protected abstract boolean isPropertyOfTable(int property, int j);
|
||||
public abstract boolean isPropertyOfTable(int property, int j);
|
||||
|
||||
protected abstract int[] getPropertyTableNumbersInSelect();
|
||||
|
||||
@ -377,19 +377,19 @@ public String getDiscriminatorColumnReaderTemplate() {
|
||||
}
|
||||
}
|
||||
|
||||
protected String getDiscriminatorAlias() {
|
||||
public String getDiscriminatorAlias() {
|
||||
return DISCRIMINATOR_ALIAS;
|
||||
}
|
||||
|
||||
protected String getDiscriminatorFormulaTemplate() {
|
||||
public String getDiscriminatorFormulaTemplate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean isInverseTable(int j) {
|
||||
public boolean isInverseTable(int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isNullableTable(int j) {
|
||||
public boolean isNullableTable(int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ public String[] getRootTableKeyColumnNames() {
|
||||
return rootTableKeyColumnNames;
|
||||
}
|
||||
|
||||
protected String[] getSQLUpdateByRowIdStrings() {
|
||||
public String[] getSQLUpdateByRowIdStrings() {
|
||||
if ( sqlUpdateByRowIdString == null ) {
|
||||
throw new AssertionFailure( "no update by row id" );
|
||||
}
|
||||
@ -423,7 +423,7 @@ protected String[] getSQLUpdateByRowIdStrings() {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String[] getSQLLazyUpdateByRowIdStrings() {
|
||||
public String[] getSQLLazyUpdateByRowIdStrings() {
|
||||
if ( sqlLazyUpdateByRowIdString == null ) {
|
||||
throw new AssertionFailure( "no update by row id" );
|
||||
}
|
||||
@ -433,52 +433,64 @@ protected String[] getSQLLazyUpdateByRowIdStrings() {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String getSQLSnapshotSelectString() {
|
||||
public String getSQLSnapshotSelectString() {
|
||||
return sqlSnapshotSelectString;
|
||||
}
|
||||
|
||||
protected String getSQLLazySelectString(String fetchGroup) {
|
||||
public String getSQLLazySelectString(String fetchGroup) {
|
||||
return sqlLazySelectStringsByFetchGroup.get( fetchGroup );
|
||||
}
|
||||
|
||||
protected String[] getSQLDeleteStrings() {
|
||||
public String[] getSQLDeleteStrings() {
|
||||
return sqlDeleteStrings;
|
||||
}
|
||||
|
||||
protected String[] getSQLInsertStrings() {
|
||||
public String[] getSQLInsertStrings() {
|
||||
return sqlInsertStrings;
|
||||
}
|
||||
|
||||
protected String[] getSQLUpdateStrings() {
|
||||
public String[] getSQLUpdateStrings() {
|
||||
return sqlUpdateStrings;
|
||||
}
|
||||
|
||||
protected String[] getSQLLazyUpdateStrings() {
|
||||
public String[] getSQLLazyUpdateStrings() {
|
||||
return sqlLazyUpdateStrings;
|
||||
}
|
||||
|
||||
public ExecuteUpdateResultCheckStyle[] getInsertResultCheckStyles() {
|
||||
return insertResultCheckStyles;
|
||||
}
|
||||
|
||||
public ExecuteUpdateResultCheckStyle[] getUpdateResultCheckStyles() {
|
||||
return updateResultCheckStyles;
|
||||
}
|
||||
|
||||
public ExecuteUpdateResultCheckStyle[] getDeleteResultCheckStyles() {
|
||||
return deleteResultCheckStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* The query that inserts a row, letting the database generate an id
|
||||
*
|
||||
* @return The IDENTITY-based insertion query.
|
||||
*/
|
||||
protected String getSQLIdentityInsertString() {
|
||||
public String getSQLIdentityInsertString() {
|
||||
return sqlIdentityInsertString;
|
||||
}
|
||||
|
||||
protected String getVersionSelectString() {
|
||||
public String getVersionSelectString() {
|
||||
return sqlVersionSelectString;
|
||||
}
|
||||
|
||||
protected boolean isInsertCallable(int j) {
|
||||
public boolean isInsertCallable(int j) {
|
||||
return insertCallable[j];
|
||||
}
|
||||
|
||||
protected boolean isUpdateCallable(int j) {
|
||||
public boolean isUpdateCallable(int j) {
|
||||
return updateCallable[j];
|
||||
}
|
||||
|
||||
protected boolean isDeleteCallable(int j) {
|
||||
public boolean isDeleteCallable(int j) {
|
||||
return deleteCallable[j];
|
||||
}
|
||||
|
||||
@ -505,7 +517,7 @@ public boolean hasSequentialSelect() {
|
||||
*
|
||||
* @return Array of booleans indicating which table require updating.
|
||||
*/
|
||||
protected boolean[] getTableUpdateNeeded(final int[] dirtyProperties, boolean hasDirtyCollection) {
|
||||
public boolean[] getTableUpdateNeeded(final int[] dirtyProperties, boolean hasDirtyCollection) {
|
||||
|
||||
if ( dirtyProperties == null ) {
|
||||
return getTableHasColumns(); // for objects that came in via update()
|
||||
@ -539,15 +551,15 @@ public boolean hasRowId() {
|
||||
return rowIdName != null;
|
||||
}
|
||||
|
||||
protected boolean[][] getPropertyColumnUpdateable() {
|
||||
public boolean[][] getPropertyColumnUpdateable() {
|
||||
return propertyColumnUpdateable;
|
||||
}
|
||||
|
||||
protected boolean[][] getPropertyColumnInsertable() {
|
||||
public boolean[][] getPropertyColumnInsertable() {
|
||||
return propertyColumnInsertable;
|
||||
}
|
||||
|
||||
protected boolean[] getPropertySelectable() {
|
||||
public boolean[] getPropertySelectable() {
|
||||
return propertySelectable;
|
||||
}
|
||||
|
||||
@ -1381,11 +1393,11 @@ public String[] getIdentifierColumnReaderTemplates() {
|
||||
return rootTableKeyColumnReaderTemplates;
|
||||
}
|
||||
|
||||
protected int getIdentifierColumnSpan() {
|
||||
public int getIdentifierColumnSpan() {
|
||||
return identifierColumnSpan;
|
||||
}
|
||||
|
||||
protected String[] getIdentifierAliases() {
|
||||
public String[] getIdentifierAliases() {
|
||||
return identifierAliases;
|
||||
}
|
||||
|
||||
@ -1393,7 +1405,7 @@ public String getVersionColumnName() {
|
||||
return versionColumnName;
|
||||
}
|
||||
|
||||
protected String getVersionedTableName() {
|
||||
public String getVersionedTableName() {
|
||||
return getTableName( 0 );
|
||||
}
|
||||
|
||||
@ -1624,7 +1636,7 @@ public Serializable getIdByUniqueKey(Serializable key, String uniquePropertyName
|
||||
|
||||
}
|
||||
|
||||
protected String generateIdByUniqueKeySelectString(String uniquePropertyName) {
|
||||
public String generateIdByUniqueKeySelectString(String uniquePropertyName) {
|
||||
Select select = new Select( getFactory().getDialect() );
|
||||
|
||||
if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) {
|
||||
@ -1681,7 +1693,7 @@ protected String generateIdByUniqueKeySelectString(String uniquePropertyName) {
|
||||
/**
|
||||
* Generate the SQL that selects the version number by id
|
||||
*/
|
||||
protected String generateSelectVersionString() {
|
||||
public String generateSelectVersionString() {
|
||||
SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
|
||||
.setTableName( getVersionedTableName() );
|
||||
if ( isVersioned() ) {
|
||||
@ -1700,11 +1712,11 @@ public boolean[] getPropertyUniqueness() {
|
||||
return propertyUniqueness;
|
||||
}
|
||||
|
||||
protected String generateInsertGeneratedValuesSelectString() {
|
||||
public String generateInsertGeneratedValuesSelectString() {
|
||||
return generateGeneratedValuesSelectString( GenerationTiming.INSERT );
|
||||
}
|
||||
|
||||
protected String generateUpdateGeneratedValuesSelectString() {
|
||||
public String generateUpdateGeneratedValuesSelectString() {
|
||||
return generateGeneratedValuesSelectString( GenerationTiming.ALWAYS );
|
||||
}
|
||||
|
||||
@ -1786,7 +1798,7 @@ protected String concretePropertySelectFragment(String alias, InclusionChecker i
|
||||
return frag.toFragmentString();
|
||||
}
|
||||
|
||||
protected String generateSnapshotSelectString() {
|
||||
public String generateSnapshotSelectString() {
|
||||
|
||||
//TODO: should we use SELECT .. FOR UPDATE?
|
||||
|
||||
@ -2162,11 +2174,11 @@ public String[] getPropertyColumnWriters(int i) {
|
||||
return propertyColumnWriters[i];
|
||||
}
|
||||
|
||||
protected int getPropertyColumnSpan(int i) {
|
||||
public int getPropertyColumnSpan(int i) {
|
||||
return propertyColumnSpans[i];
|
||||
}
|
||||
|
||||
protected boolean hasFormulaProperties() {
|
||||
public boolean hasFormulaProperties() {
|
||||
return hasFormulaProperties;
|
||||
}
|
||||
|
||||
@ -2587,14 +2599,14 @@ protected boolean check(
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String generateUpdateString(boolean[] includeProperty, int j, boolean useRowId) {
|
||||
public String generateUpdateString(boolean[] includeProperty, int j, boolean useRowId) {
|
||||
return generateUpdateString( includeProperty, j, null, useRowId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the SQL that updates a row by id (and version)
|
||||
*/
|
||||
protected String generateUpdateString(
|
||||
public String generateUpdateString(
|
||||
final boolean[] includeProperty,
|
||||
final int j,
|
||||
final Object[] oldFields,
|
||||
@ -2688,23 +2700,23 @@ else if ( isAllOrDirtyOptLocking() && oldFields != null ) {
|
||||
return hasColumns ? update.toStatementString() : null;
|
||||
}
|
||||
|
||||
protected final boolean checkVersion(final boolean[] includeProperty) {
|
||||
public final boolean checkVersion(final boolean[] includeProperty) {
|
||||
return includeProperty[getVersionProperty()]
|
||||
|| entityMetamodel.isVersionGenerated();
|
||||
}
|
||||
|
||||
protected String generateInsertString(boolean[] includeProperty, int j) {
|
||||
public String generateInsertString(boolean[] includeProperty, int j) {
|
||||
return generateInsertString( false, includeProperty, j );
|
||||
}
|
||||
|
||||
protected String generateInsertString(boolean identityInsert, boolean[] includeProperty) {
|
||||
public String generateInsertString(boolean identityInsert, boolean[] includeProperty) {
|
||||
return generateInsertString( identityInsert, includeProperty, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the SQL that inserts a row
|
||||
*/
|
||||
protected String generateInsertString(boolean identityInsert, boolean[] includeProperty, int j) {
|
||||
public String generateInsertString(boolean identityInsert, boolean[] includeProperty, int j) {
|
||||
|
||||
// todo : remove the identityInsert param and variations;
|
||||
// identity-insert strings are now generated from generateIdentityInsertString()
|
||||
@ -2803,7 +2815,7 @@ else if ( includeProperty[i] ) {
|
||||
*
|
||||
* @return The insert SQL statement string
|
||||
*/
|
||||
protected String generateIdentityInsertString(boolean[] includeProperty) {
|
||||
public String generateIdentityInsertString(boolean[] includeProperty) {
|
||||
Insert insert = identityDelegate.prepareIdentifierGeneratingInsert();
|
||||
insert.setTableName( getTableName( 0 ) );
|
||||
|
||||
@ -2870,7 +2882,7 @@ else if ( generationStrategy != null &&
|
||||
/**
|
||||
* Generate the SQL that deletes a row by id (and version)
|
||||
*/
|
||||
protected String generateDeleteString(int j) {
|
||||
public String generateDeleteString(int j) {
|
||||
final Delete delete = new Delete()
|
||||
.setTableName( getTableName( j ) )
|
||||
.addPrimaryKeyColumns( getKeyColumns( j ) );
|
||||
@ -2883,7 +2895,7 @@ protected String generateDeleteString(int j) {
|
||||
return delete.toStatementString();
|
||||
}
|
||||
|
||||
protected int dehydrate(
|
||||
public int dehydrate(
|
||||
Serializable id,
|
||||
Object[] fields,
|
||||
boolean[] includeProperty,
|
||||
@ -2898,7 +2910,7 @@ protected int dehydrate(
|
||||
/**
|
||||
* Marshall the fields of a persistent instance to a prepared statement
|
||||
*/
|
||||
protected int dehydrate(
|
||||
public int dehydrate(
|
||||
final Serializable id,
|
||||
final Object[] fields,
|
||||
final Object rowId,
|
||||
@ -3079,11 +3091,11 @@ else if ( allProperties || !laziness[i] ) {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean useInsertSelectIdentity() {
|
||||
public boolean useInsertSelectIdentity() {
|
||||
return !useGetGeneratedKeys() && getFactory().getDialect().getIdentityColumnSupport().supportsInsertSelectIdentity();
|
||||
}
|
||||
|
||||
protected boolean useGetGeneratedKeys() {
|
||||
public boolean useGetGeneratedKeys() {
|
||||
return getFactory().getSessionFactoryOptions().isGetGeneratedKeysEnabled();
|
||||
}
|
||||
|
||||
@ -3097,7 +3109,7 @@ protected String getSequentialSelect(String entityName) {
|
||||
* This form is used for PostInsertIdentifierGenerator-style ids (IDENTITY,
|
||||
* select, etc).
|
||||
*/
|
||||
protected Serializable insert(
|
||||
public Serializable insert(
|
||||
final Object[] fields,
|
||||
final boolean[] notNull,
|
||||
String sql,
|
||||
@ -3150,7 +3162,7 @@ public String getSelectByUniqueKeyString(String propertyName) {
|
||||
* This for is used for all non-root tables as well as the root table
|
||||
* in cases where the identifier value is known before the insert occurs.
|
||||
*/
|
||||
protected void insert(
|
||||
public void insert(
|
||||
final Serializable id,
|
||||
final Object[] fields,
|
||||
final boolean[] notNull,
|
||||
@ -3253,7 +3265,7 @@ protected void insert(
|
||||
/**
|
||||
* Perform an SQL UPDATE or SQL INSERT
|
||||
*/
|
||||
protected void updateOrInsert(
|
||||
public void updateOrInsert(
|
||||
final Serializable id,
|
||||
final Object[] fields,
|
||||
final Object[] oldFields,
|
||||
@ -3307,7 +3319,7 @@ else if ( isNullableTable( j ) && isAllNull( fields, j ) ) {
|
||||
|
||||
private BasicBatchKey updateBatchKey;
|
||||
|
||||
protected boolean update(
|
||||
public boolean update(
|
||||
final Serializable id,
|
||||
final Object[] fields,
|
||||
final Object[] oldFields,
|
||||
@ -3455,7 +3467,7 @@ else if ( isAllOrDirtyOptLocking() && oldFields != null ) {
|
||||
/**
|
||||
* Perform an SQL DELETE
|
||||
*/
|
||||
protected void delete(
|
||||
public void delete(
|
||||
final Serializable id,
|
||||
final Object version,
|
||||
final int j,
|
||||
@ -4511,7 +4523,7 @@ else if ( lockOptions.getTimeOut() != LockOptions.WAIT_FOREVER ) {
|
||||
}
|
||||
}
|
||||
|
||||
protected final boolean isAllNull(Object[] array, int tableNumber) {
|
||||
public final boolean isAllNull(Object[] array, int tableNumber) {
|
||||
for ( int i = 0; i < array.length; i++ ) {
|
||||
if ( isPropertyOfTable( i, tableNumber ) && array[i] != null ) {
|
||||
return false;
|
||||
@ -4528,7 +4540,7 @@ public boolean isSubclassPropertyNullable(int i) {
|
||||
* Transform the array of property indexes to an array of booleans,
|
||||
* true when the property is dirty
|
||||
*/
|
||||
protected final boolean[] getPropertiesToUpdate(final int[] dirtyProperties, final boolean hasDirtyCollection) {
|
||||
public final boolean[] getPropertiesToUpdate(final int[] dirtyProperties, final boolean hasDirtyCollection) {
|
||||
final boolean[] propsToUpdate = new boolean[entityMetamodel.getPropertySpan()];
|
||||
final boolean[] updateability = getPropertyUpdateability(); //no need to check laziness, dirty checking handles that
|
||||
for ( int j = 0; j < dirtyProperties.length; j++ ) {
|
||||
@ -4552,7 +4564,7 @@ protected final boolean[] getPropertiesToUpdate(final int[] dirtyProperties, fin
|
||||
* Transform the array of property indexes to an array of booleans,
|
||||
* true when the property is insertable and non-null
|
||||
*/
|
||||
protected boolean[] getPropertiesToInsert(Object[] fields) {
|
||||
public boolean[] getPropertiesToInsert(Object[] fields) {
|
||||
boolean[] notNull = new boolean[fields.length];
|
||||
boolean[] insertable = getPropertyInsertability();
|
||||
for ( int i = 0; i < fields.length; i++ ) {
|
||||
@ -4626,7 +4638,7 @@ public int[] findModified(Object[] old, Object[] current, Object entity, SharedS
|
||||
* Which properties appear in the SQL update?
|
||||
* (Initialized, updateable ones!)
|
||||
*/
|
||||
protected boolean[] getPropertyUpdateability(Object entity) {
|
||||
public boolean[] getPropertyUpdateability(Object entity) {
|
||||
return hasUninitializedLazyProperties( entity )
|
||||
? getNonLazyPropertyUpdateability()
|
||||
: getPropertyUpdateability();
|
||||
@ -4863,7 +4875,7 @@ public boolean isMutable() {
|
||||
return entityMetamodel.isMutable();
|
||||
}
|
||||
|
||||
protected final boolean isModifiableEntity(EntityEntry entry) {
|
||||
public final boolean isModifiableEntity(EntityEntry entry) {
|
||||
return ( entry == null ? isMutable() : entry.isModifiableEntity() );
|
||||
}
|
||||
|
||||
@ -4908,7 +4920,7 @@ protected boolean useDynamicInsert() {
|
||||
return entityMetamodel.isDynamicInsert();
|
||||
}
|
||||
|
||||
protected boolean hasEmbeddedCompositeIdentifier() {
|
||||
public boolean hasEmbeddedCompositeIdentifier() {
|
||||
return entityMetamodel.getIdentifierProperty().isEmbedded();
|
||||
}
|
||||
|
||||
@ -5170,7 +5182,7 @@ public boolean isMultiTable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getPropertySpan() {
|
||||
public int getPropertySpan() {
|
||||
return entityMetamodel.getPropertySpan();
|
||||
}
|
||||
|
||||
@ -5526,7 +5538,7 @@ private String determinePkByNaturalIdQuery(boolean[] valueNullness) {
|
||||
return generateEntityIdByNaturalIdSql( valueNullness );
|
||||
}
|
||||
|
||||
protected boolean isNaturalIdNonNullable() {
|
||||
public boolean isNaturalIdNonNullable() {
|
||||
if ( naturalIdIsNonNullable == null ) {
|
||||
naturalIdIsNonNullable = determineNaturalIdNullability();
|
||||
}
|
||||
|
@ -736,12 +736,12 @@ private void associateSubclassNamesToSubclassTableIndex(
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNullableTable(int j) {
|
||||
public boolean isNullableTable(int j) {
|
||||
return isNullableTable[j];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInverseTable(int j) {
|
||||
public boolean isInverseTable(int j) {
|
||||
return isInverseTable[j];
|
||||
}
|
||||
|
||||
@ -799,7 +799,7 @@ public String getDiscriminatorColumnReaderTemplate() {
|
||||
return getDiscriminatorColumnName();
|
||||
}
|
||||
|
||||
protected String getDiscriminatorAlias() {
|
||||
public String getDiscriminatorAlias() {
|
||||
return discriminatorAlias;
|
||||
}
|
||||
|
||||
@ -819,19 +819,19 @@ public Serializable[] getPropertySpaces() {
|
||||
}
|
||||
|
||||
|
||||
protected String getTableName(int j) {
|
||||
public String getTableName(int j) {
|
||||
return naturalOrderTableNames[j];
|
||||
}
|
||||
|
||||
protected String[] getKeyColumns(int j) {
|
||||
public String[] getKeyColumns(int j) {
|
||||
return naturalOrderTableKeyColumns[j];
|
||||
}
|
||||
|
||||
protected boolean isTableCascadeDeleteEnabled(int j) {
|
||||
public boolean isTableCascadeDeleteEnabled(int j) {
|
||||
return naturalOrderCascadeDeleteEnabled[j];
|
||||
}
|
||||
|
||||
protected boolean isPropertyOfTable(int property, int j) {
|
||||
public boolean isPropertyOfTable(int property, int j) {
|
||||
return naturalOrderPropertyTableNumbers[property] == j;
|
||||
}
|
||||
|
||||
@ -928,14 +928,14 @@ private CaseFragment discriminatorFragment(String alias) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterFragment(String alias) {
|
||||
protected String filterFragment(String alias) {
|
||||
return hasWhere()
|
||||
? " and " + getSQLWhereString( generateFilterConditionAlias( alias ) )
|
||||
: "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterFragment(String alias, Set<String> treatAsDeclarations) {
|
||||
protected String filterFragment(String alias, Set<String> treatAsDeclarations) {
|
||||
return filterFragment( alias );
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ private void addSubclassByDiscriminatorValue(Object discriminatorValue, String e
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isInverseTable(int j) {
|
||||
public boolean isInverseTable(int j) {
|
||||
return isInverseTable[j];
|
||||
}
|
||||
|
||||
@ -470,11 +470,11 @@ public String getDiscriminatorColumnReaderTemplate() {
|
||||
return discriminatorColumnReaderTemplate;
|
||||
}
|
||||
|
||||
protected String getDiscriminatorAlias() {
|
||||
public String getDiscriminatorAlias() {
|
||||
return discriminatorAlias;
|
||||
}
|
||||
|
||||
protected String getDiscriminatorFormulaTemplate() {
|
||||
public String getDiscriminatorFormulaTemplate() {
|
||||
return discriminatorFormulaTemplate;
|
||||
}
|
||||
|
||||
@ -525,19 +525,19 @@ protected String getDiscriminatorFormula() {
|
||||
return discriminatorFormula;
|
||||
}
|
||||
|
||||
protected String getTableName(int j) {
|
||||
public String getTableName(int j) {
|
||||
return qualifiedTableNames[j];
|
||||
}
|
||||
|
||||
protected String[] getKeyColumns(int j) {
|
||||
public String[] getKeyColumns(int j) {
|
||||
return keyColumnNames[j];
|
||||
}
|
||||
|
||||
protected boolean isTableCascadeDeleteEnabled(int j) {
|
||||
public boolean isTableCascadeDeleteEnabled(int j) {
|
||||
return cascadeDeleteEnabled[j];
|
||||
}
|
||||
|
||||
protected boolean isPropertyOfTable(int property, int j) {
|
||||
public boolean isPropertyOfTable(int property, int j) {
|
||||
return propertyTableNumbers[property] == j;
|
||||
}
|
||||
|
||||
@ -552,7 +552,7 @@ public String fromTableFragment(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterFragment(String alias) throws MappingException {
|
||||
protected String filterFragment(String alias) throws MappingException {
|
||||
String result = discriminatorFilterFragment( alias );
|
||||
if ( hasWhere() ) {
|
||||
result += " and " + getSQLWhereString( alias );
|
||||
@ -578,7 +578,7 @@ public String oneToManyFilterFragment(String alias, Set<String> treatAsDeclarati
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterFragment(String alias, Set<String> treatAsDeclarations) {
|
||||
protected String filterFragment(String alias, Set<String> treatAsDeclarations) {
|
||||
String result = discriminatorFilterFragment( alias, treatAsDeclarations );
|
||||
if ( hasWhere() ) {
|
||||
result += " and " + getSQLWhereString( alias );
|
||||
@ -810,7 +810,7 @@ protected boolean isSubclassTableLazy(int j) {
|
||||
return subclassTableIsLazyClosure[j];
|
||||
}
|
||||
|
||||
protected boolean isNullableTable(int j) {
|
||||
public boolean isNullableTable(int j) {
|
||||
return isNullableTable[j];
|
||||
}
|
||||
|
||||
|
@ -287,19 +287,19 @@ protected String getDiscriminatorFormula() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getTableName(int j) {
|
||||
public String getTableName(int j) {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
protected String[] getKeyColumns(int j) {
|
||||
public String[] getKeyColumns(int j) {
|
||||
return getIdentifierColumnNames();
|
||||
}
|
||||
|
||||
protected boolean isTableCascadeDeleteEnabled(int j) {
|
||||
public boolean isTableCascadeDeleteEnabled(int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isPropertyOfTable(int property, int j) {
|
||||
public boolean isPropertyOfTable(int property, int j) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ public String fromTableFragment(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterFragment(String name) {
|
||||
protected String filterFragment(String name) {
|
||||
return hasWhere()
|
||||
? " and " + getSQLWhereString( name )
|
||||
: "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user