more simplifications to persister hierarchy (#8501)

- remove Lockable interface
- remove Queryable, QueryableCollection, and Loadable
- remove most of PropertyMapping stuff
- remove most of Joinable
This commit is contained in:
Gavin King 2024-06-02 22:19:09 +02:00 committed by Steve Ebersole
parent f3329fe4e5
commit ebc253a6f9
71 changed files with 625 additions and 1373 deletions

View File

@ -40,7 +40,7 @@ import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor; import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor; import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.sqm.IntervalType; import org.hibernate.query.sqm.IntervalType;
import org.hibernate.query.sqm.TemporalUnit; import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.SqlAstTranslator;
@ -317,7 +317,7 @@ public class CacheDialect extends Dialect {
} }
@Override @Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(EntityPersister lockable, LockMode lockMode) {
// InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax... // InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax...
// Set your transaction mode to READ_COMMITTED before using // Set your transaction mode to READ_COMMITTED before using
switch (lockMode) { switch (lockMode) {

View File

@ -51,7 +51,7 @@ import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.sqm.CastType; import org.hibernate.query.sqm.CastType;
import org.hibernate.query.sqm.IntervalType; import org.hibernate.query.sqm.IntervalType;
import org.hibernate.dialect.NullOrdering; import org.hibernate.dialect.NullOrdering;
@ -736,7 +736,7 @@ public class HSQLLegacyDialect extends Dialect {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(EntityPersister lockable, LockMode lockMode) {
switch (lockMode) { switch (lockMode) {
case PESSIMISTIC_FORCE_INCREMENT: case PESSIMISTIC_FORCE_INCREMENT:
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode); return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
@ -758,7 +758,7 @@ public class HSQLLegacyDialect extends Dialect {
} }
private static class ReadUncommittedLockingStrategy extends SelectLockingStrategy { private static class ReadUncommittedLockingStrategy extends SelectLockingStrategy {
private ReadUncommittedLockingStrategy(Lockable lockable, LockMode lockMode) { private ReadUncommittedLockingStrategy(EntityPersister lockable, LockMode lockMode) {
super( lockable, lockMode ); super( lockable, lockMode );
} }

View File

@ -31,7 +31,7 @@ import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.sqm.IntervalType; import org.hibernate.query.sqm.IntervalType;
import org.hibernate.query.sqm.TemporalUnit; import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.query.sqm.TrimSpec; import org.hibernate.query.sqm.TrimSpec;
@ -394,7 +394,7 @@ public class RDMSOS2200Dialect extends Dialect {
} }
@Override @Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(EntityPersister lockable, LockMode lockMode) {
// RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax... // RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
switch (lockMode) { switch (lockMode) {
case PESSIMISTIC_FORCE_INCREMENT: case PESSIMISTIC_FORCE_INCREMENT:

View File

@ -33,7 +33,7 @@ import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.sqm.IntervalType; import org.hibernate.query.sqm.IntervalType;
import org.hibernate.query.sqm.TemporalUnit; import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableInsertStrategy; import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableInsertStrategy;
@ -370,7 +370,7 @@ public class TimesTenDialect extends Dialect {
} }
@Override @Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(EntityPersister lockable, LockMode lockMode) {
// TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax... // TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax...
switch ( lockMode ) { switch ( lockMode ) {
case OPTIMISTIC: case OPTIMISTIC:

View File

@ -118,7 +118,7 @@ import org.hibernate.mapping.Table;
import org.hibernate.mapping.UserDefinedType; import org.hibernate.mapping.UserDefinedType;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.mutation.EntityMutationTarget; import org.hibernate.persister.entity.mutation.EntityMutationTarget;
import org.hibernate.procedure.internal.StandardCallableStatementSupport; import org.hibernate.procedure.internal.StandardCallableStatementSupport;
import org.hibernate.procedure.spi.CallableStatementSupport; import org.hibernate.procedure.spi.CallableStatementSupport;
@ -2035,7 +2035,7 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
* *
* @since 3.2 * @since 3.2
*/ */
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(EntityPersister lockable, LockMode lockMode) {
switch ( lockMode ) { switch ( lockMode ) {
case PESSIMISTIC_FORCE_INCREMENT: case PESSIMISTIC_FORCE_INCREMENT:
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode ); return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );

View File

@ -56,7 +56,7 @@ import org.hibernate.mapping.Table;
import org.hibernate.mapping.UserDefinedType; import org.hibernate.mapping.UserDefinedType;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.mutation.EntityMutationTarget; import org.hibernate.persister.entity.mutation.EntityMutationTarget;
import org.hibernate.procedure.spi.CallableStatementSupport; import org.hibernate.procedure.spi.CallableStatementSupport;
import org.hibernate.query.hql.HqlTranslator; import org.hibernate.query.hql.HqlTranslator;
@ -401,7 +401,7 @@ public class DialectDelegateWrapper extends Dialect {
} }
@Override @Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(EntityPersister lockable, LockMode lockMode) {
return wrapped.getLockingStrategy( lockable, lockMode ); return wrapped.getLockingStrategy( lockable, lockMode );
} }

View File

@ -34,7 +34,7 @@ import org.hibernate.mapping.Constraint;
import org.hibernate.mapping.ForeignKey; import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.UniqueKey; import org.hibernate.mapping.UniqueKey;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.IntervalType; import org.hibernate.query.sqm.IntervalType;
import org.hibernate.query.sqm.TemporalUnit; import org.hibernate.query.sqm.TemporalUnit;
@ -709,7 +709,7 @@ public class SpannerDialect extends Dialect {
} }
@Override @Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(EntityPersister lockable, LockMode lockMode) {
return LOCKING_STRATEGY; return LOCKING_STRATEGY;
} }

View File

@ -14,7 +14,7 @@ import org.hibernate.StaleObjectStateException;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.SimpleSelect; import org.hibernate.sql.SimpleSelect;
import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.stat.spi.StatisticsImplementor;
@ -33,17 +33,17 @@ import static org.hibernate.pretty.MessageHelper.infoString;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public abstract class AbstractSelectLockingStrategy implements LockingStrategy { public abstract class AbstractSelectLockingStrategy implements LockingStrategy {
private final Lockable lockable; private final EntityPersister lockable;
private final LockMode lockMode; private final LockMode lockMode;
private final String waitForeverSql; private final String waitForeverSql;
protected AbstractSelectLockingStrategy(Lockable lockable, LockMode lockMode) { protected AbstractSelectLockingStrategy(EntityPersister lockable, LockMode lockMode) {
this.lockable = lockable; this.lockable = lockable;
this.lockMode = lockMode; this.lockMode = lockMode;
this.waitForeverSql = generateLockString( LockOptions.WAIT_FOREVER ); this.waitForeverSql = generateLockString( LockOptions.WAIT_FOREVER );
} }
protected Lockable getLockable() { protected EntityPersister getLockable() {
return lockable; return lockable;
} }
@ -75,7 +75,7 @@ public abstract class AbstractSelectLockingStrategy implements LockingStrategy {
throws StaleObjectStateException, JDBCException { throws StaleObjectStateException, JDBCException {
final String sql = determineSql( timeout ); final String sql = determineSql( timeout );
final SessionFactoryImplementor factory = session.getFactory(); final SessionFactoryImplementor factory = session.getFactory();
final Lockable lockable = getLockable(); final EntityPersister lockable = getLockable();
try { try {
final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator(); final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator();
final PreparedStatement st = jdbcCoordinator.getStatementPreparer().prepareStatement( sql ); final PreparedStatement st = jdbcCoordinator.getStatementPreparer().prepareStatement( sql );

View File

@ -9,9 +9,8 @@ package org.hibernate.dialect.lock;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.action.internal.EntityIncrementVersionProcess; import org.hibernate.action.internal.EntityIncrementVersionProcess;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
/** /**
* An optimistic locking strategy that verifies that the version * An optimistic locking strategy that verifies that the version
@ -24,7 +23,7 @@ import org.hibernate.persister.entity.Lockable;
* @since 3.5 * @since 3.5
*/ */
public class OptimisticForceIncrementLockingStrategy implements LockingStrategy { public class OptimisticForceIncrementLockingStrategy implements LockingStrategy {
private final Lockable lockable; private final EntityPersister lockable;
private final LockMode lockMode; private final LockMode lockMode;
/** /**
@ -33,7 +32,7 @@ public class OptimisticForceIncrementLockingStrategy implements LockingStrategy
* @param lockable The metadata for the entity to be locked. * @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. * @param lockMode Indicates the type of lock to be acquired.
*/ */
public OptimisticForceIncrementLockingStrategy(Lockable lockable, LockMode lockMode) { public OptimisticForceIncrementLockingStrategy(EntityPersister lockable, LockMode lockMode) {
this.lockable = lockable; this.lockable = lockable;
this.lockMode = lockMode; this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.OPTIMISTIC_FORCE_INCREMENT ) ) { if ( lockMode.lessThan( LockMode.OPTIMISTIC_FORCE_INCREMENT ) ) {

View File

@ -10,7 +10,7 @@ import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.action.internal.EntityVerifyVersionProcess; import org.hibernate.action.internal.EntityVerifyVersionProcess;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
/** /**
* An optimistic locking strategy that simply verifies that the * An optimistic locking strategy that simply verifies that the
@ -22,7 +22,7 @@ import org.hibernate.persister.entity.Lockable;
* @since 3.5 * @since 3.5
*/ */
public class OptimisticLockingStrategy implements LockingStrategy { public class OptimisticLockingStrategy implements LockingStrategy {
private final Lockable lockable; private final EntityPersister lockable;
private final LockMode lockMode; private final LockMode lockMode;
/** /**
@ -31,7 +31,7 @@ public class OptimisticLockingStrategy implements LockingStrategy {
* @param lockable The metadata for the entity to be locked. * @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. * @param lockMode Indicates the type of lock to be acquired.
*/ */
public OptimisticLockingStrategy(Lockable lockable, LockMode lockMode) { public OptimisticLockingStrategy(EntityPersister lockable, LockMode lockMode) {
this.lockable = lockable; this.lockable = lockable;
this.lockMode = lockMode; this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.OPTIMISTIC ) ) { if ( lockMode.lessThan( LockMode.OPTIMISTIC ) ) {

View File

@ -11,7 +11,6 @@ import org.hibernate.LockMode;
import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Lockable;
/** /**
* A pessimistic locking strategy where a lock is obtained by incrementing * A pessimistic locking strategy where a lock is obtained by incrementing
@ -23,7 +22,7 @@ import org.hibernate.persister.entity.Lockable;
* @since 3.5 * @since 3.5
*/ */
public class PessimisticForceIncrementLockingStrategy implements LockingStrategy { public class PessimisticForceIncrementLockingStrategy implements LockingStrategy {
private final Lockable lockable; private final EntityPersister lockable;
private final LockMode lockMode; private final LockMode lockMode;
/** /**
@ -32,7 +31,7 @@ public class PessimisticForceIncrementLockingStrategy implements LockingStrategy
* @param lockable The metadata for the entity to be locked. * @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. * @param lockMode Indicates the type of lock to be acquired.
*/ */
public PessimisticForceIncrementLockingStrategy(Lockable lockable, LockMode lockMode) { public PessimisticForceIncrementLockingStrategy(EntityPersister lockable, LockMode lockMode) {
this.lockable = lockable; this.lockable = lockable;
this.lockMode = lockMode; this.lockMode = lockMode;
// ForceIncrement can be used for PESSIMISTIC_READ, PESSIMISTIC_WRITE or PESSIMISTIC_FORCE_INCREMENT // ForceIncrement can be used for PESSIMISTIC_READ, PESSIMISTIC_WRITE or PESSIMISTIC_FORCE_INCREMENT

View File

@ -10,7 +10,7 @@ import org.hibernate.HibernateException;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
/** /**
* A pessimistic locking strategy where {@link LockMode#PESSIMISTIC_READ} * A pessimistic locking strategy where {@link LockMode#PESSIMISTIC_READ}
@ -34,7 +34,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS
* @param lockable The metadata for the entity to be locked. * @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. * @param lockMode Indicates the type of lock to be acquired.
*/ */
public PessimisticReadSelectLockingStrategy(Lockable lockable, LockMode lockMode) { public PessimisticReadSelectLockingStrategy(EntityPersister lockable, LockMode lockMode) {
super( lockable, lockMode ); super( lockable, lockMode );
} }

View File

@ -17,7 +17,7 @@ import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.sql.Update; import org.hibernate.sql.Update;
import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.stat.spi.StatisticsImplementor;
@ -42,7 +42,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
PessimisticReadUpdateLockingStrategy.class.getName() PessimisticReadUpdateLockingStrategy.class.getName()
); );
private final Lockable lockable; private final EntityPersister lockable;
private final LockMode lockMode; private final LockMode lockMode;
private final String sql; private final String sql;
@ -53,7 +53,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
* @param lockMode Indicates the type of lock to be acquired. Note that * @param lockMode Indicates the type of lock to be acquired. Note that
* read-locks are not valid for this strategy. * read-locks are not valid for this strategy.
*/ */
public PessimisticReadUpdateLockingStrategy(Lockable lockable, LockMode lockMode) { public PessimisticReadUpdateLockingStrategy(EntityPersister lockable, LockMode lockMode) {
this.lockable = lockable; this.lockable = lockable;
this.lockMode = lockMode; this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) {

View File

@ -10,7 +10,7 @@ import org.hibernate.HibernateException;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
/** /**
* A pessimistic locking strategy where {@link LockMode#PESSIMISTIC_WRITE} * A pessimistic locking strategy where {@link LockMode#PESSIMISTIC_WRITE}
@ -33,7 +33,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking
* @param lockable The metadata for the entity to be locked. * @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. * @param lockMode Indicates the type of lock to be acquired.
*/ */
public PessimisticWriteSelectLockingStrategy(Lockable lockable, LockMode lockMode) { public PessimisticWriteSelectLockingStrategy(EntityPersister lockable, LockMode lockMode) {
super( lockable, lockMode ); super( lockable, lockMode );
} }

View File

@ -17,7 +17,7 @@ import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.sql.Update; import org.hibernate.sql.Update;
import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.stat.spi.StatisticsImplementor;
@ -42,7 +42,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy {
PessimisticWriteUpdateLockingStrategy.class.getName() PessimisticWriteUpdateLockingStrategy.class.getName()
); );
private final Lockable lockable; private final EntityPersister lockable;
private final LockMode lockMode; private final LockMode lockMode;
private final String sql; private final String sql;
@ -52,7 +52,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy {
* @param lockable The metadata for the entity to be locked. * @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. Note that read-locks are not valid for this strategy. * @param lockMode Indicates the type of lock to be acquired. Note that read-locks are not valid for this strategy.
*/ */
public PessimisticWriteUpdateLockingStrategy(Lockable lockable, LockMode lockMode) { public PessimisticWriteUpdateLockingStrategy(EntityPersister lockable, LockMode lockMode) {
this.lockable = lockable; this.lockable = lockable;
this.lockMode = lockMode; this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) {

View File

@ -10,7 +10,7 @@ import org.hibernate.HibernateException;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
/** /**
* A locking strategy where an optimistic lock is obtained via a select * A locking strategy where an optimistic lock is obtained via a select
@ -33,7 +33,7 @@ public class SelectLockingStrategy extends AbstractSelectLockingStrategy {
* @param lockable The metadata for the entity to be locked. * @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. * @param lockMode Indicates the type of lock to be acquired.
*/ */
public SelectLockingStrategy(Lockable lockable, LockMode lockMode) { public SelectLockingStrategy(EntityPersister lockable, LockMode lockMode) {
super( lockable, lockMode ); super( lockable, lockMode );
} }

View File

@ -17,7 +17,7 @@ import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.persister.entity.Lockable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.sql.Update; import org.hibernate.sql.Update;
import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.stat.spi.StatisticsImplementor;
@ -40,7 +40,7 @@ public class UpdateLockingStrategy implements LockingStrategy {
UpdateLockingStrategy.class.getName() UpdateLockingStrategy.class.getName()
); );
private final Lockable lockable; private final EntityPersister lockable;
private final LockMode lockMode; private final LockMode lockMode;
private final String sql; private final String sql;
@ -51,7 +51,7 @@ public class UpdateLockingStrategy implements LockingStrategy {
* @param lockMode Indicates the type of lock to be acquired. Note that * @param lockMode Indicates the type of lock to be acquired. Note that
* read-locks are not valid for this strategy. * read-locks are not valid for this strategy.
*/ */
public UpdateLockingStrategy(Lockable lockable, LockMode lockMode) { public UpdateLockingStrategy(EntityPersister lockable, LockMode lockMode) {
this.lockable = lockable; this.lockable = lockable;
this.lockMode = lockMode; this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.WRITE ) ) { if ( lockMode.lessThan( LockMode.WRITE ) ) {

View File

@ -12,7 +12,7 @@ import java.util.Map;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.persister.entity.Joinable; import org.hibernate.persister.entity.EntityPersister;
/** /**
* @author Rob Worsnop * @author Rob Worsnop
@ -76,8 +76,7 @@ public class FilterConfiguration {
if ( aliasEntityMap != null ) { if ( aliasEntityMap != null ) {
for ( Map.Entry<String, String> entry : aliasEntityMap.entrySet() ) { for ( Map.Entry<String, String> entry : aliasEntityMap.entrySet() ) {
final Joinable joinable = (Joinable) factory.getRuntimeMetamodels() final EntityPersister joinable = factory.getMappingMetamodel()
.getMappingMetamodel()
.getEntityDescriptor( entry.getValue() ); .getEntityDescriptor( entry.getValue() );
ret.put( entry.getKey(), joinable.getTableName() ); ret.put( entry.getKey(), joinable.getTableName() );
} }

View File

@ -26,8 +26,6 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.mutation.CollectionMutationTarget;
import org.hibernate.persister.entity.PropertyMapping;
import org.hibernate.spi.NavigablePath; import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.FromClauseAccess;
import org.hibernate.sql.ast.spi.SqlAliasBase; import org.hibernate.sql.ast.spi.SqlAliasBase;
@ -431,8 +429,7 @@ public abstract class AbstractEntityCollectionPart implements EntityCollectionPa
targetKeyPropertyNames.add( referencedPropertyName.substring( 0, dotIndex ) ); targetKeyPropertyNames.add( referencedPropertyName.substring( 0, dotIndex ) );
} }
// todo (PropertyMapping) : the problem here is timing. this needs to be delayed. // todo (PropertyMapping) : the problem here is timing. this needs to be delayed.
final Type propertyType = ( (PropertyMapping) elementTypeDescriptor.getEntityPersister() ) final Type propertyType = elementTypeDescriptor.getEntityPersister().getPropertyType( referencedPropertyName );
.toType( referencedPropertyName );
ToOneAttributeMapping.addPrefixedPropertyPaths( ToOneAttributeMapping.addPrefixedPropertyPaths(
targetKeyPropertyNames, targetKeyPropertyNames,
referencedPropertyName, referencedPropertyName,

View File

@ -78,11 +78,8 @@ import org.hibernate.metamodel.mapping.SelectablePath;
import org.hibernate.metamodel.mapping.VirtualModelPart; import org.hibernate.metamodel.mapping.VirtualModelPart;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.collection.AbstractCollectionPersister;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.property.access.internal.ChainedPropertyAccessImpl; import org.hibernate.property.access.internal.ChainedPropertyAccessImpl;
import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
@ -498,7 +495,7 @@ public class MappingModelCreationHelper {
final CollectionPersister collectionDescriptor = domainModel.findCollectionDescriptor( bootValueMapping.getRole() ); final CollectionPersister collectionDescriptor = domainModel.findCollectionDescriptor( bootValueMapping.getRole() );
assert collectionDescriptor != null; assert collectionDescriptor != null;
final String tableExpression = ( (Joinable) collectionDescriptor ).getTableName(); final String tableExpression = collectionDescriptor.getTableName();
final String sqlAliasStem = SqlAliasStemHelper.INSTANCE.generateStemFromAttributeName( bootProperty.getName() ); final String sqlAliasStem = SqlAliasStemHelper.INSTANCE.generateStemFromAttributeName( bootProperty.getName() );
@ -564,15 +561,14 @@ public class MappingModelCreationHelper {
indexDescriptor = null; indexDescriptor = null;
final QueryableCollection loadableCollection = (QueryableCollection) collectionDescriptor; final String identifierColumnName = collectionDescriptor.getIdentifierColumnName();
final String identifierColumnName = loadableCollection.getIdentifierColumnName();
assert identifierColumnName != null; assert identifierColumnName != null;
identifierDescriptor = new CollectionIdentifierDescriptorImpl( identifierDescriptor = new CollectionIdentifierDescriptorImpl(
collectionDescriptor, collectionDescriptor,
tableExpression, tableExpression,
identifierColumnName, identifierColumnName,
(BasicType) loadableCollection.getIdentifierType() (BasicType) collectionDescriptor.getIdentifierType()
); );
break; break;
@ -765,10 +761,10 @@ public class MappingModelCreationHelper {
final String lhsPropertyName = collectionDescriptor.getCollectionType().getLHSPropertyName(); final String lhsPropertyName = collectionDescriptor.getCollectionType().getLHSPropertyName();
final boolean isReferenceToPrimaryKey = lhsPropertyName == null; final boolean isReferenceToPrimaryKey = lhsPropertyName == null;
final ManagedMappingType keyDeclaringType; final ManagedMappingType keyDeclaringType;
final String collectionTableName = ((AbstractCollectionPersister) collectionDescriptor).getTableName(); final String collectionTableName = collectionDescriptor.getTableName();
if ( collectionDescriptor.getElementType().isEntityType() ) { if ( collectionDescriptor.getElementType().isEntityType() ) {
keyDeclaringType = ( (QueryableCollection) collectionDescriptor ).getElementPersister(); keyDeclaringType = collectionDescriptor.getElementPersister();
} }
else { else {
// This is not "really correct" but it is as good as it gets. // This is not "really correct" but it is as good as it gets.

View File

@ -45,7 +45,6 @@ import org.hibernate.metamodel.mapping.ordering.TranslationContext;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.mutation.CollectionMutationTarget; import org.hibernate.persister.collection.mutation.CollectionMutationTarget;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.spi.NavigablePath; import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.SqlAstJoinType;
@ -170,7 +169,7 @@ public class PluralAttributeMappingImpl
separateCollectionTable = null; separateCollectionTable = null;
} }
else { else {
separateCollectionTable = ( (Joinable) collectionDescriptor ).getTableName(); separateCollectionTable = collectionDescriptor.getTableName();
} }
final int baseIndex; final int baseIndex;
@ -955,7 +954,7 @@ public class PluralAttributeMappingImpl
this, this,
creationState.getSqlAliasBaseGenerator() creationState.getSqlAliasBaseGenerator()
); );
final String collectionTableName = ( (Joinable) collectionDescriptor ).getTableName(); final String collectionTableName = collectionDescriptor.getTableName();
final TableReference collectionTableReference = new NamedTableReference( final TableReference collectionTableReference = new NamedTableReference(
collectionTableName, collectionTableName,
sqlAliasBase.generateNewAlias(), sqlAliasBase.generateNewAlias(),

View File

@ -26,7 +26,7 @@ import org.hibernate.metamodel.model.domain.ManagedDomainType;
import org.hibernate.metamodel.model.domain.PersistentAttribute; import org.hibernate.metamodel.model.domain.PersistentAttribute;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.persister.entity.DiscriminatorMetadata; import org.hibernate.persister.entity.DiscriminatorMetadata;
import org.hibernate.persister.entity.Queryable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.PathException; import org.hibernate.query.PathException;
import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.query.sqm.tree.domain.SqmPath;
@ -71,19 +71,14 @@ public class EntityTypeImpl<J>
this.jpaEntityName = jpaEntityName; this.jpaEntityName = jpaEntityName;
this.metamodel = metamodel; this.metamodel = metamodel;
final Queryable entityDescriptor = (Queryable) final EntityPersister entityDescriptor =
metamodel.getMappingMetamodel() metamodel.getMappingMetamodel()
.getEntityDescriptor( getHibernateEntityName() ); .getEntityDescriptor( getHibernateEntityName() );
final DiscriminatorMetadata discriminatorMetadata = entityDescriptor.getTypeDiscriminatorMetadata(); final DiscriminatorMetadata discriminatorMetadata = entityDescriptor.getTypeDiscriminatorMetadata();
final DomainType discriminatorType; final DomainType discriminatorType =
if ( discriminatorMetadata != null ) { discriminatorMetadata != null
discriminatorType = (DomainType) discriminatorMetadata.getResolutionType(); ? (DomainType) discriminatorMetadata.getResolutionType()
} : metamodel.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.STRING );
else {
discriminatorType = metamodel.getTypeConfiguration()
.getBasicTypeRegistry()
.resolve( StandardBasicTypes.STRING );
}
this.discriminatorPathSource = discriminatorType == null ? null : new EntityDiscriminatorSqmPathSource( this.discriminatorPathSource = discriminatorType == null ? null : new EntityDiscriminatorSqmPathSource(
discriminatorType, discriminatorType,

View File

@ -59,7 +59,6 @@ import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.persister.spi.PersisterFactory; import org.hibernate.persister.spi.PersisterFactory;
import org.hibernate.query.BindableType; import org.hibernate.query.BindableType;
import org.hibernate.query.derived.AnonymousTupleSqmPathSource; import org.hibernate.query.derived.AnonymousTupleSqmPathSource;
@ -316,9 +315,9 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
modelCreationContext modelCreationContext
); );
collectionPersisterMap.put( model.getRole(), persister ); collectionPersisterMap.put( model.getRole(), persister );
Type indexType = persister.getIndexType(); final Type indexType = persister.getIndexType();
if ( indexType != null && indexType.isEntityType() && !indexType.isAnyType() ) { if ( indexType != null && indexType.isEntityType() && !indexType.isAnyType() ) {
String entityName = ( (org.hibernate.type.EntityType) indexType ).getAssociatedEntityName(); final String entityName = ( (org.hibernate.type.EntityType) indexType ).getAssociatedEntityName();
Set<String> roles = collectionRolesByEntityParticipant.get( entityName ); Set<String> roles = collectionRolesByEntityParticipant.get( entityName );
//noinspection Java8MapApi //noinspection Java8MapApi
if ( roles == null ) { if ( roles == null ) {
@ -327,9 +326,9 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
} }
roles.add( persister.getRole() ); roles.add( persister.getRole() );
} }
Type elementType = persister.getElementType(); final Type elementType = persister.getElementType();
if ( elementType.isEntityType() && !elementType.isAnyType() ) { if ( elementType.isEntityType() && !elementType.isAnyType() ) {
String entityName = ( (org.hibernate.type.EntityType) elementType ).getAssociatedEntityName(); final String entityName = ( (org.hibernate.type.EntityType) elementType ).getAssociatedEntityName();
Set<String> roles = collectionRolesByEntityParticipant.get( entityName ); Set<String> roles = collectionRolesByEntityParticipant.get( entityName );
//noinspection Java8MapApi //noinspection Java8MapApi
if ( roles == null ) { if ( roles == null ) {
@ -755,35 +754,33 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
} }
private String[] doGetImplementors(Class<?> clazz) throws MappingException { private String[] doGetImplementors(Class<?> clazz) throws MappingException {
ArrayList<String> results = new ArrayList<>(); final ArrayList<String> results = new ArrayList<>();
for ( EntityPersister checkPersister : entityPersisters().values() ) { for ( EntityPersister checkPersister : entityPersisters().values() ) {
if ( checkPersister instanceof Queryable ) { final String checkQueryableEntityName = ((EntityMappingType) checkPersister).getEntityName();
final String checkQueryableEntityName = ((EntityMappingType) checkPersister).getEntityName(); final boolean isMappedClass = clazz.getName().equals( checkQueryableEntityName );
final boolean isMappedClass = clazz.getName().equals( checkQueryableEntityName ); if ( checkPersister.isExplicitPolymorphism() ) {
if ( checkPersister.isExplicitPolymorphism() ) { if ( isMappedClass ) {
if ( isMappedClass ) { return new String[] { clazz.getName() }; // NOTE EARLY EXIT
return new String[] { clazz.getName() }; // NOTE EARLY EXIT }
} }
else {
if ( isMappedClass ) {
results.add( checkQueryableEntityName );
} }
else { else {
if ( isMappedClass ) { final Class<?> mappedClass = checkPersister.getMappedClass();
results.add( checkQueryableEntityName ); if ( mappedClass != null && clazz.isAssignableFrom( mappedClass ) ) {
} final boolean assignableSuperclass;
else { if ( checkPersister.isInherited() ) {
final Class<?> mappedClass = checkPersister.getMappedClass(); final String superTypeName = checkPersister.getSuperMappingType().getEntityName();
if ( mappedClass != null && clazz.isAssignableFrom( mappedClass ) ) { final Class<?> mappedSuperclass = getEntityDescriptor( superTypeName ).getMappedClass();
final boolean assignableSuperclass; assignableSuperclass = clazz.isAssignableFrom( mappedSuperclass );
if ( checkPersister.isInherited() ) { }
final String superTypeName = checkPersister.getSuperMappingType().getEntityName(); else {
Class<?> mappedSuperclass = getEntityDescriptor( superTypeName ).getMappedClass(); assignableSuperclass = false;
assignableSuperclass = clazz.isAssignableFrom( mappedSuperclass ); }
} if ( !assignableSuperclass ) {
else { results.add( checkQueryableEntityName );
assignableSuperclass = false;
}
if ( !assignableSuperclass ) {
results.add( checkQueryableEntityName );
}
} }
} }
} }

View File

@ -19,13 +19,11 @@ import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
import org.hibernate.Filter; import org.hibernate.Filter;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Internal; import org.hibernate.Internal;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.QueryException;
import org.hibernate.TransientObjectException; import org.hibernate.TransientObjectException;
import org.hibernate.annotations.CacheLayout; import org.hibernate.annotations.CacheLayout;
import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.MetadataImplementor;
@ -96,7 +94,6 @@ import org.hibernate.persister.collection.mutation.RowMutationOperations;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable; import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.PropertyMapping;
import org.hibernate.persister.internal.SqlFragmentPredicate; import org.hibernate.persister.internal.SqlFragmentPredicate;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.query.named.NamedQueryMemento; import org.hibernate.query.named.NamedQueryMemento;
@ -159,7 +156,7 @@ import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER
*/ */
@Internal @Internal
public abstract class AbstractCollectionPersister public abstract class AbstractCollectionPersister
implements CollectionPersister, CollectionMutationTarget, PluralAttributeMappingImpl.Aware, FetchProfileAffectee, DeprecatedCollectionStuff { implements CollectionPersister, CollectionMutationTarget, PluralAttributeMappingImpl.Aware, FetchProfileAffectee, Joinable {
private final NavigableRole navigableRole; private final NavigableRole navigableRole;
private final CollectionSemantics<?,?> collectionSemantics; private final CollectionSemantics<?,?> collectionSemantics;
@ -213,7 +210,6 @@ public abstract class AbstractCollectionPersister
private final boolean isMutable; private final boolean isMutable;
private final boolean isVersioned; private final boolean isVersioned;
protected final int batchSize; protected final int batchSize;
private final FetchMode fetchMode;
private final boolean hasOrphanDelete; private final boolean hasOrphanDelete;
private final boolean subselectLoadable; private final boolean subselectLoadable;
@ -225,7 +221,6 @@ public abstract class AbstractCollectionPersister
private final Dialect dialect; private final Dialect dialect;
protected final SqlExceptionHelper sqlExceptionHelper; protected final SqlExceptionHelper sqlExceptionHelper;
private final BeforeExecutionGenerator identifierGenerator; private final BeforeExecutionGenerator identifierGenerator;
private final PropertyMapping elementPropertyMapping;
private final EntityPersister elementPersister; private final EntityPersister elementPersister;
private final @Nullable CollectionDataAccess cacheAccessStrategy; private final @Nullable CollectionDataAccess cacheAccessStrategy;
@ -246,7 +241,6 @@ public abstract class AbstractCollectionPersister
private final Comparator<?> comparator; private final Comparator<?> comparator;
private CollectionLoader collectionLoader; private CollectionLoader collectionLoader;
// private volatile CollectionLoader standardCollectionLoader;
private CollectionElementLoaderByIndex collectionElementLoaderByIndex; private CollectionElementLoaderByIndex collectionElementLoaderByIndex;
private PluralAttributeMapping attributeMapping; private PluralAttributeMapping attributeMapping;
@ -288,7 +282,6 @@ public abstract class AbstractCollectionPersister
final Value elementBootDescriptor = collectionBootDescriptor.getElement(); final Value elementBootDescriptor = collectionBootDescriptor.getElement();
final Table table = collectionBootDescriptor.getCollectionTable(); final Table table = collectionBootDescriptor.getCollectionTable();
fetchMode = elementBootDescriptor.getFetchMode();
elementType = elementBootDescriptor.getType(); elementType = elementBootDescriptor.getType();
// isSet = collectionBinding.isSet(); // isSet = collectionBinding.isSet();
// isSorted = collectionBinding.isSorted(); // isSorted = collectionBinding.isSorted();
@ -543,29 +536,6 @@ public abstract class AbstractCollectionPersister
elementClass = null; // elementType.returnedClass(); elementClass = null; // elementType.returnedClass();
} }
if ( elementType.isComponentType() ) {
elementPropertyMapping = new CompositeElementPropertyMapping(
elementColumnNames,
elementColumnReaders,
elementColumnReaderTemplates,
elementFormulaTemplates,
(CompositeType) elementType,
creationContext.getMetadata()
);
}
else if ( !elementType.isEntityType() ) {
elementPropertyMapping = new ElementPropertyMapping( elementColumnNames, elementType );
}
else {
// not all entity-persisters implement PropertyMapping!
if ( elementPersister instanceof PropertyMapping ) {
elementPropertyMapping = (PropertyMapping) elementPersister;
}
else {
elementPropertyMapping = new ElementPropertyMapping( elementColumnNames, elementType );
}
}
hasOrder = collectionBootDescriptor.getOrderBy() != null; hasOrder = collectionBootDescriptor.getOrderBy() != null;
hasManyToManyOrder = collectionBootDescriptor.getManyToManyOrdering() != null; hasManyToManyOrder = collectionBootDescriptor.getManyToManyOrdering() != null;
@ -690,7 +660,7 @@ public abstract class AbstractCollectionPersister
.resolve( factory, bootModel, queryLoaderName ); .resolve( factory, bootModel, queryLoaderName );
if ( memento == null ) { if ( memento == null ) {
throw new IllegalArgumentException( "Could not resolve named query '" + queryLoaderName throw new IllegalArgumentException( "Could not resolve named query '" + queryLoaderName
+ "' for loading collection '" + getName() + "'" ); + "' for loading collection '" + getRole() + "'" );
} }
return memento; return memento;
} }
@ -860,11 +830,6 @@ public abstract class AbstractCollectionPersister
protected abstract RowMutationOperations getRowMutationOperations(); protected abstract RowMutationOperations getRowMutationOperations();
protected abstract RemoveCoordinator getRemoveCoordinator(); protected abstract RemoveCoordinator getRemoveCoordinator();
@Override
public FetchMode getFetchMode() {
return fetchMode;
}
@Override @Override
public boolean hasOrdering() { public boolean hasOrdering() {
return hasOrder; return hasOrder;
@ -875,11 +840,6 @@ public abstract class AbstractCollectionPersister
return isManyToMany() && hasManyToManyOrder; return isManyToMany() && hasManyToManyOrder;
} }
@Override
public boolean hasWhere() {
return hasWhere;
}
/** /**
* Return the element class of an array, or null otherwise. needed by arrays * Return the element class of an array, or null otherwise. needed by arrays
*/ */
@ -1053,46 +1013,14 @@ public abstract class AbstractCollectionPersister
.toStatementString(); .toStatementString();
} }
@Override
public String[] getIndexColumnNames() { public String[] getIndexColumnNames() {
return indexColumnNames; return indexColumnNames;
} }
@Override
public String[] getIndexFormulas() {
return indexFormulas;
}
@Override
public String[] getIndexColumnNames(String alias) {
return qualify( alias, indexColumnNames, indexFormulaTemplates );
}
@Override
public String[] getElementColumnNames(String alias) {
return qualify( alias, elementColumnNames, elementFormulaTemplates );
}
private static String[] qualify(String alias, String[] columnNames, String[] formulaTemplates) {
int span = columnNames.length;
String[] result = new String[span];
for ( int i = 0; i < span; i++ ) {
if ( columnNames[i] == null ) {
result[i] = StringHelper.replace( formulaTemplates[i], Template.TEMPLATE, alias );
}
else {
result[i] = StringHelper.qualify( alias, columnNames[i] );
}
}
return result;
}
@Override
public String[] getElementColumnNames() { public String[] getElementColumnNames() {
return elementColumnNames; // TODO: something with formulas... return elementColumnNames; // TODO: something with formulas...
} }
@Override
public String[] getKeyColumnNames() { public String[] getKeyColumnNames() {
return keyColumnNames; return keyColumnNames;
} }
@ -1116,7 +1044,6 @@ public abstract class AbstractCollectionPersister
return cascadeDeleteEnabled; return cascadeDeleteEnabled;
} }
@Override
public String getTableName() { public String getTableName() {
return qualifiedTableName; return qualifiedTableName;
} }
@ -1163,15 +1090,6 @@ public abstract class AbstractCollectionPersister
return hasOrphanDelete; return hasOrphanDelete;
} }
@Override
public Type toType(String propertyName) throws QueryException {
// todo (PropertyMapping) : simple delegation (aka, easy to remove)
if ( "index".equals( propertyName ) ) {
return indexType;
}
return elementPropertyMapping.toType( propertyName );
}
@Override @Override
public void applyBaseRestrictions( public void applyBaseRestrictions(
Consumer<Predicate> predicateConsumer, Consumer<Predicate> predicateConsumer,
@ -1206,7 +1124,7 @@ public abstract class AbstractCollectionPersister
@Override @Override
public boolean hasWhereRestrictions() { public boolean hasWhereRestrictions() {
return hasWhere() || manyToManyWhereTemplate != null; return hasWhere || manyToManyWhereTemplate != null;
} }
@Override @Override
@ -1215,12 +1133,12 @@ public abstract class AbstractCollectionPersister
TableGroup tableGroup, TableGroup tableGroup,
boolean useQualifier, boolean useQualifier,
SqlAstCreationState creationState) { SqlAstCreationState creationState) {
TableReference tableReference; final TableReference tableReference;
if ( isManyToMany() ) { if ( isManyToMany() ) {
tableReference = tableGroup.getPrimaryTableReference(); tableReference = tableGroup.getPrimaryTableReference();
} }
else if ( elementPersister instanceof Joinable ) { else if ( elementPersister != null ) {
tableReference = tableGroup.getTableReference( tableGroup.getNavigablePath(), ( (Joinable) elementPersister ).getTableName() ); tableReference = tableGroup.getTableReference( tableGroup.getNavigablePath(), elementPersister.getTableName() );
} }
else { else {
tableReference = tableGroup.getTableReference( tableGroup.getNavigablePath(), qualifiedTableName ); tableReference = tableGroup.getTableReference( tableGroup.getNavigablePath(), qualifiedTableName );
@ -1313,7 +1231,7 @@ public abstract class AbstractCollectionPersister
} }
if ( manyToManyWhereString != null ) { if ( manyToManyWhereString != null ) {
final TableReference tableReference = tableGroup.resolveTableReference( ( (Joinable) elementPersister ).getTableName() ); final TableReference tableReference = tableGroup.resolveTableReference( elementPersister.getTableName() );
final String alias; final String alias;
if ( tableReference == null ) { if ( tableReference == null ) {
@ -1339,43 +1257,17 @@ public abstract class AbstractCollectionPersister
} }
if ( manyToManyWhereString != null ) { if ( manyToManyWhereString != null ) {
if ( fragment.length() > 0 ) { if ( !fragment.isEmpty() ) {
fragment.append( " and " ); fragment.append( " and " );
} }
assert elementPersister instanceof Joinable; assert elementPersister != null;
final TableReference tableReference = tableGroup.resolveTableReference( ( (Joinable) elementPersister ).getTableName() ); final TableReference tableReference = tableGroup.resolveTableReference( elementPersister.getTableName() );
fragment.append( StringHelper.replace( manyToManyWhereTemplate, Template.TEMPLATE, tableReference.getIdentificationVariable() ) ); fragment.append( StringHelper.replace( manyToManyWhereTemplate, Template.TEMPLATE, tableReference.getIdentificationVariable() ) );
} }
return fragment.toString(); return fragment.toString();
} }
private String[] indexFragments;
@Override
public String[] toColumns(String propertyName) throws QueryException {
// todo (PropertyMapping) : simple delegation (aka, easy to remove)
if ( "index".equals( propertyName ) ) {
if ( indexFragments == null ) {
String[] tmp = new String[indexColumnNames.length];
for ( int i = 0; i < indexColumnNames.length; i++ ) {
tmp[i] = indexColumnNames[i] == null
? indexFormulas[i]
: indexColumnNames[i];
indexFragments = tmp;
}
}
return indexFragments;
}
return elementPropertyMapping.toColumns( propertyName );
}
@Override
public String getName() {
return getRole();
}
@Override @Override
public EntityPersister getElementPersister() { public EntityPersister getElementPersister() {
if ( elementPersister == null ) { if ( elementPersister == null ) {
@ -1388,11 +1280,6 @@ public abstract class AbstractCollectionPersister
return elementPersister; return elementPersister;
} }
@Override
public boolean isCollection() {
return true;
}
@Override @Override
public String[] getCollectionSpaces() { public String[] getCollectionSpaces() {
return spaces; return spaces;
@ -1870,8 +1757,6 @@ public abstract class AbstractCollectionPersister
final ForeignKeyDescriptor fkDescriptor = getAttributeMapping().getKeyDescriptor(); final ForeignKeyDescriptor fkDescriptor = getAttributeMapping().getKeyDescriptor();
assert fkDescriptor != null; assert fkDescriptor != null;
final int keyColumnCount = fkDescriptor.getJdbcTypeCount();
fkDescriptor.getKeyPart().forEachSelectable( parameterList ); fkDescriptor.getKeyPart().forEachSelectable( parameterList );
for ( ColumnValueParameter columnValueParameter : parameterList ) { for ( ColumnValueParameter columnValueParameter : parameterList ) {
final ColumnReference columnReference = columnValueParameter.getColumnReference(); final ColumnReference columnReference = columnValueParameter.getColumnReference();

View File

@ -457,4 +457,23 @@ public interface CollectionPersister extends Restrictable {
*/ */
@Deprecated( forRemoval = true ) @Deprecated( forRemoval = true )
Type getIdentifierType(); Type getIdentifierType();
String getIdentifierColumnName();
String getTableName();
/**
* Generate a list of collection index and element columns
*/
String selectFragment(String alias, String columnSuffix);
String[] getCollectionPropertyColumnAliases(String propertyName, String string);
/**
* Get the persister of the element class, if this is a
* collection of entities (optional operation). Note that
* for a one-to-many association, the returned persister
* must be {@code OuterJoinLoadable}.
*/
EntityPersister getElementPersister();
} }

View File

@ -1,50 +0,0 @@
/*
* 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.persister.collection;
import org.hibernate.MappingException;
import org.hibernate.Remove;
import org.hibernate.boot.Metadata;
import org.hibernate.persister.entity.AbstractPropertyMapping;
import org.hibernate.type.CompositeType;
import org.hibernate.type.Type;
/**
* @author Gavin King
*
* @deprecated Replaced by {@link org.hibernate.metamodel.mapping.internal.EmbeddedCollectionPart}
*/
@Deprecated(since = "6", forRemoval = true)
@Remove
public class CompositeElementPropertyMapping extends AbstractPropertyMapping {
private final CompositeType compositeType;
public CompositeElementPropertyMapping(
String[] elementColumns,
String[] elementColumnReaders,
String[] elementColumnReaderTemplates,
String[] elementFormulaTemplates,
CompositeType compositeType,
Metadata factory)
throws MappingException {
this.compositeType = compositeType;
initComponentPropertyPaths(null, compositeType, elementColumns, elementColumnReaders,
elementColumnReaderTemplates, elementFormulaTemplates, factory );
}
public Type getType() {
return compositeType;
}
protected String getEntityName() {
return compositeType.getName();
}
}

View File

@ -1,14 +0,0 @@
/*
* 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.persister.collection;
/**
* @deprecated Just used to singly extend all the deprecated collection persister roles
*/
@Deprecated
public interface DeprecatedCollectionStuff extends QueryableCollection {
}

View File

@ -1,51 +0,0 @@
/*
* 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.persister.collection;
import org.hibernate.QueryException;
import org.hibernate.Remove;
import org.hibernate.persister.entity.PropertyMapping;
import org.hibernate.type.Type;
/**
* @author Gavin King
*
* @deprecated Replaced by {@link org.hibernate.metamodel.mapping.CollectionPart}
*/
@Deprecated(since = "6", forRemoval = true)
@Remove
public class ElementPropertyMapping implements PropertyMapping {
private final String[] elementColumns;
private final Type type;
public ElementPropertyMapping(String[] elementColumns, Type type) {
this.elementColumns = elementColumns;
this.type = type;
}
public Type toType(String propertyName) throws QueryException {
if ( propertyName==null || "id".equals(propertyName) ) {
return type;
}
else {
throw new QueryException("Cannot dereference scalar collection element: " + propertyName);
}
}
/**
* Given a property path, return the corresponding column name(s).
*/
public String[] toColumns(String propertyName) {
throw new UnsupportedOperationException( "References to collections must define an SQL alias" );
}
public Type getType() {
return type;
}
}

View File

@ -55,7 +55,6 @@ import org.hibernate.persister.collection.mutation.UpdateRowsCoordinator;
import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorNoOp; import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorNoOp;
import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorOneToMany; import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorOneToMany;
import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorTablePerSubclass; import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorTablePerSubclass;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.UnionSubclassEntityPersister; import org.hibernate.persister.entity.UnionSubclassEntityPersister;
import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.SqlAstTranslator;
import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlAstCreationState;
@ -257,7 +256,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
@Override @Override
public String getTableName() { public String getTableName() {
return ( (Joinable) getElementPersister() ).getTableName(); return getElementPersister().getTableName();
} }
protected void applyWhereFragments( protected void applyWhereFragments(

View File

@ -1,76 +0,0 @@
/*
* 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.persister.collection;
import org.hibernate.FetchMode;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.PropertyMapping;
/**
* A collection role that may be queried or loaded by outer join.
*
* @author Gavin King
*
* @deprecated Given the mapping-model and SQM, this contract is no longer needed.
* Note however that {@link org.hibernate.query.sql.internal.SQLQueryParser} currently
* uses this along with other
*/
@Deprecated( since = "6", forRemoval = true )
public interface QueryableCollection extends PropertyMapping, Joinable, CollectionPersister {
/**
* Generate a list of collection index and element columns
*/
String selectFragment(String alias, String columnSuffix);
/**
* Get the names of the collection index columns if
* this is an indexed collection (optional operation)
*/
String[] getIndexColumnNames();
/**
* Get the index formulas if this is an indexed collection
* (optional operation)
*/
String[] getIndexFormulas();
/**
* Get the names of the collection index columns if
* this is an indexed collection (optional operation),
* aliased by the given table alias
*/
String[] getIndexColumnNames(String alias);
/**
* Get the names of the collection element columns (or the primary
* key columns in the case of a one-to-many association),
* aliased by the given table alias
*/
String[] getElementColumnNames(String alias);
/**
* Get the names of the collection element columns (or the primary
* key columns in the case of a one-to-many association)
*/
String[] getElementColumnNames();
String getIdentifierColumnName();
String[] getCollectionPropertyColumnAliases(String propertyName, String string);
/**
* Does this collection role have a where clause filter?
*/
boolean hasWhere();
/**
* Get the persister of the element class, if this is a
* collection of entities (optional operation). Note that
* for a one-to-many association, the returned persister
* must be {@code OuterJoinLoadable}.
*/
EntityPersister getElementPersister();
/**
* Should we load this collection role by outerjoining?
*/
FetchMode getFetchMode();
}

View File

@ -330,12 +330,13 @@ import static org.hibernate.sql.ast.spi.SqlExpressionResolver.createColumnRefere
@Internal @Internal
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class AbstractEntityPersister public abstract class AbstractEntityPersister
implements InFlightEntityMappingType, EntityMutationTarget, LazyPropertyInitializer, FetchProfileAffectee, DeprecatedEntityStuff { implements EntityPersister, InFlightEntityMappingType, EntityMutationTarget, LazyPropertyInitializer, FetchProfileAffectee, Joinable {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class );
public static final String ENTITY_CLASS = "class"; public static final String ENTITY_CLASS = "class";
public static final String VERSION_COLUMN_ALIAS = "version_"; public static final String VERSION_COLUMN_ALIAS = "version_";
public static final String ROWID_ALIAS = "rowid_";
private final NavigableRole navigableRole; private final NavigableRole navigableRole;
private final SessionFactoryImplementor factory; private final SessionFactoryImplementor factory;
@ -379,7 +380,6 @@ public abstract class AbstractEntityPersister
private final String[] lazyPropertyNames; private final String[] lazyPropertyNames;
private final int[] lazyPropertyNumbers; private final int[] lazyPropertyNumbers;
private final Type[] lazyPropertyTypes; private final Type[] lazyPropertyTypes;
private final String[][] lazyPropertyColumnAliases;
//information about all properties in class hierarchy //information about all properties in class hierarchy
private final String[] subclassPropertyNameClosure; private final String[] subclassPropertyNameClosure;
@ -466,7 +466,7 @@ public abstract class AbstractEntityPersister
* for the concrete EntityPersister (since the concrete EntityPersister * for the concrete EntityPersister (since the concrete EntityPersister
* cannot have duplicated property names). * cannot have duplicated property names).
*/ */
protected final BasicEntityPropertyMapping propertyMapping; private final EntityPropertyMapping propertyMapping;
private final boolean implementsLifecycle; private final boolean implementsLifecycle;
@ -540,7 +540,7 @@ public abstract class AbstractEntityPersister
hasPartitionedSelectionMapping = persistentClass.hasPartitionedSelectionMapping(); hasPartitionedSelectionMapping = persistentClass.hasPartitionedSelectionMapping();
hasCollectionNotReferencingPK = persistentClass.hasCollectionNotReferencingPK(); hasCollectionNotReferencingPK = persistentClass.hasCollectionNotReferencingPK();
propertyMapping = new BasicEntityPropertyMapping( this ); propertyMapping = new EntityPropertyMapping( this );
// IDENTIFIER // IDENTIFIER
@ -614,7 +614,6 @@ public abstract class AbstractEntityPersister
final ArrayList<String> lazyNames = new ArrayList<>(); final ArrayList<String> lazyNames = new ArrayList<>();
final ArrayList<Integer> lazyNumbers = new ArrayList<>(); final ArrayList<Integer> lazyNumbers = new ArrayList<>();
final ArrayList<Type> lazyTypes = new ArrayList<>(); final ArrayList<Type> lazyTypes = new ArrayList<>();
final ArrayList<String[]> lazyColAliases = new ArrayList<>();
final List<Property> propertyClosure = persistentClass.getPropertyClosure(); final List<Property> propertyClosure = persistentClass.getPropertyClosure();
boolean foundFormula = false; boolean foundFormula = false;
@ -666,14 +665,12 @@ public abstract class AbstractEntityPersister
lazyNames.add( prop.getName() ); lazyNames.add( prop.getName() );
lazyNumbers.add( i ); lazyNumbers.add( i );
lazyTypes.add( prop.getValue().getType() ); lazyTypes.add( prop.getValue().getType() );
lazyColAliases.add( colAliases );
} }
propertyColumnUpdateable[i] = prop.getValue().getColumnUpdateability(); propertyColumnUpdateable[i] = prop.getValue().getColumnUpdateability();
propertyColumnInsertable[i] = prop.getValue().getColumnInsertability(); propertyColumnInsertable[i] = prop.getValue().getColumnInsertability();
} }
hasFormulaProperties = foundFormula; hasFormulaProperties = foundFormula;
lazyPropertyColumnAliases = to2DStringArray( lazyColAliases );
lazyPropertyNames = toStringArray( lazyNames ); lazyPropertyNames = toStringArray( lazyNames );
lazyPropertyNumbers = toIntArray( lazyNumbers ); lazyPropertyNumbers = toIntArray( lazyNumbers );
lazyPropertyTypes = toTypeArray( lazyTypes ); lazyPropertyTypes = toTypeArray( lazyTypes );
@ -945,7 +942,6 @@ public abstract class AbstractEntityPersister
return queryCacheLayout == CacheLayout.SHALLOW_WITH_DISCRIMINATOR; return queryCacheLayout == CacheLayout.SHALLOW_WITH_DISCRIMINATOR;
} }
@Override
public abstract String getSubclassTableName(int j); public abstract String getSubclassTableName(int j);
protected abstract String[] getSubclassTableNames(); protected abstract String[] getSubclassTableNames();
@ -2142,11 +2138,6 @@ public abstract class AbstractEntityPersister
return getSubclassTableName( 0 ); return getSubclassTableName( 0 );
} }
@Override
public String getRootTableAlias(String drivingAlias) {
return drivingAlias;
}
@Override @Override
public String[] getRootTableIdentifierColumnNames() { public String[] getRootTableIdentifierColumnNames() {
return getRootTableKeyColumnNames(); return getRootTableKeyColumnNames();
@ -2167,22 +2158,6 @@ public abstract class AbstractEntityPersister
return propertyMapping.getColumnNames( propertyName ); return propertyMapping.getColumnNames( propertyName );
} }
/**
* {@inheritDoc}
*
* Warning:
* When there are duplicated property names in the subclasses
* then this method may return the wrong results.
* To ensure correct results, this method should only be used when
* {@literal this} is the concrete EntityPersister (since the
* concrete EntityPersister cannot have duplicated property names).
*/
@Override
public Type toType(String propertyName) throws QueryException {
// todo (PropertyMapping) : simple delegation (aka, easy to remove)
return propertyMapping.toType( propertyName );
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
@ -2206,7 +2181,6 @@ public abstract class AbstractEntityPersister
* SingleTableEntityPersister defines an overloaded form * SingleTableEntityPersister defines an overloaded form
* which takes the entity name. * which takes the entity name.
*/ */
@Override
public int getSubclassPropertyTableNumber(String propertyPath) { public int getSubclassPropertyTableNumber(String propertyPath) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
// String rootPropertyName = StringHelper.root( propertyPath ); // String rootPropertyName = StringHelper.root( propertyPath );
@ -2234,23 +2208,8 @@ public abstract class AbstractEntityPersister
// return index == -1 ? 0 : getSubclassPropertyTableNumber( index ); // return index == -1 ? 0 : getSubclassPropertyTableNumber( index );
} }
@Override
public Declarer getSubclassPropertyDeclarer(String propertyPath) {
int tableIndex = getSubclassPropertyTableNumber( propertyPath );
if ( tableIndex == 0 ) {
return Declarer.CLASS;
}
else if ( isClassOrSuperclassTable( tableIndex ) ) {
return Declarer.SUPERCLASS;
}
else {
return Declarer.SUBCLASS;
}
}
private DiscriminatorType<?> discriminatorType; private DiscriminatorType<?> discriminatorType;
protected DiscriminatorType<?> resolveDiscriminatorType() { protected DiscriminatorType<?> resolveDiscriminatorType() {
if ( discriminatorType == null ) { if ( discriminatorType == null ) {
discriminatorType = buildDiscriminatorType(); discriminatorType = buildDiscriminatorType();
@ -2308,7 +2267,6 @@ public abstract class AbstractEntityPersister
return ArrayHelper.indexOf( subclassPropertyNameClosure, propertyName ); return ArrayHelper.indexOf( subclassPropertyNameClosure, propertyName );
} }
@Override
public String[] getPropertyColumnNames(int i) { public String[] getPropertyColumnNames(int i) {
return propertyColumnNames[i]; return propertyColumnNames[i];
} }
@ -2335,7 +2293,6 @@ public abstract class AbstractEntityPersister
return subclassPropertyColumnNameClosure[i]; return subclassPropertyColumnNameClosure[i];
} }
@Override
public String[][] getSubclassPropertyFormulaTemplateClosure() { public String[][] getSubclassPropertyFormulaTemplateClosure() {
return subclassPropertyFormulaTemplateClosure; return subclassPropertyFormulaTemplateClosure;
} }
@ -2801,14 +2758,6 @@ public abstract class AbstractEntityPersister
return false; return false;
} }
/**
* Delete an object
*/
@Override
public void delete(Object id, Object version, Object object, SharedSessionContractImplementor session) {
deleteCoordinator.delete( object, id, version, session );
}
protected void logStaticSQL() { protected void logStaticSQL() {
if ( LOG.isDebugEnabled() ) { if ( LOG.isDebugEnabled() ) {
LOG.debugf( "Static SQL for entity: %s", getEntityName() ); LOG.debugf( "Static SQL for entity: %s", getEntityName() );
@ -2859,6 +2808,8 @@ public abstract class AbstractEntityPersister
public abstract Map<Object, String> getSubclassByDiscriminatorValue(); public abstract Map<Object, String> getSubclassByDiscriminatorValue();
public abstract String[] getConstraintOrderedTableNameClosure();
public abstract boolean needsDiscriminator(); public abstract boolean needsDiscriminator();
protected boolean isDiscriminatorFormula() { protected boolean isDiscriminatorFormula() {
@ -3212,11 +3163,6 @@ public abstract class AbstractEntityPersister
} }
} }
@Override
public String generateFilterConditionAlias(String rootAlias) {
return rootAlias;
}
protected boolean shouldInnerJoinSubclassTable(int subclassTableNumber, Set<String> treatAsDeclarations) { protected boolean shouldInnerJoinSubclassTable(int subclassTableNumber, Set<String> treatAsDeclarations) {
if ( isClassOrSuperclassJoin( subclassTableNumber ) ) { if ( isClassOrSuperclassJoin( subclassTableNumber ) ) {
// the table is either this persister's driving table or (one of) its superclass persister's driving // the table is either this persister's driving table or (one of) its superclass persister's driving
@ -3310,6 +3256,8 @@ public abstract class AbstractEntityPersister
return GeneratedValuesHelper.getGeneratedValuesDelegate( this, UPDATE ); return GeneratedValuesHelper.getGeneratedValuesDelegate( this, UPDATE );
} }
public abstract String[][] getContraintOrderedTableKeyColumnClosure();
private static class TableMappingBuilder { private static class TableMappingBuilder {
private final String tableName; private final String tableName;
private final int relativePosition; private final int relativePosition;
@ -4099,21 +4047,10 @@ public abstract class AbstractEntityPersister
return concreteTypeLoader.getConcreteType( id, session ); return concreteTypeLoader.getConcreteType( id, session );
} }
@Override
public String[] getKeyColumnNames() { public String[] getKeyColumnNames() {
return getIdentifierColumnNames(); return getIdentifierColumnNames();
} }
@Override
public String getName() {
return getEntityName();
}
@Override
public boolean isCollection() {
return false;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
@ -4173,11 +4110,6 @@ public abstract class AbstractEntityPersister
&& ( isVersionGeneratedOnExecution() || isVersionGeneratedBeforeExecution() ); && ( isVersionGeneratedOnExecution() || isVersionGeneratedBeforeExecution() );
} }
@Override
public boolean isVersionPropertyInsertable() {
return isVersioned() && getPropertyInsertability()[getVersionProperty()];
}
public boolean isVersionGeneratedOnExecution() { public boolean isVersionGeneratedOnExecution() {
final Generator strategy = getEntityMetamodel().getGenerators()[ getVersionProperty() ]; final Generator strategy = getEntityMetamodel().getGenerators()[ getVersionProperty() ];
return strategy != null && strategy.generatesSometimes() && strategy.generatedOnExecution(); return strategy != null && strategy.generatesSometimes() && strategy.generatedOnExecution();
@ -4486,12 +4418,7 @@ public abstract class AbstractEntityPersister
return this; return this;
} }
@Override @Deprecated(since = "6.0") public boolean hasMultipleTables() {
public boolean isMultiTable() {
return hasMultipleTables();
}
protected boolean hasMultipleTables() {
return false; return false;
} }
@ -4711,11 +4638,6 @@ public abstract class AbstractEntityPersister
return entityMetamodel.getBytecodeEnhancementMetadata(); return entityMetamodel.getBytecodeEnhancementMetadata();
} }
@Override
public String getTableAliasForColumn(String columnName, String rootAlias) {
return generateTableAlias( rootAlias, determineTableNumberForColumn( columnName ) );
}
public int determineTableNumberForColumn(String columnName) { public int determineTableNumberForColumn(String columnName) {
return 0; return 0;
} }
@ -6289,20 +6211,6 @@ public abstract class AbstractEntityPersister
} }
/**
* Called by Hibernate Reactive
*
* @deprecated Hibernate no longer uses aliases to read from result sets
*/
@Deprecated @SuppressWarnings("unused")
protected String[][] getLazyPropertyColumnAliases() {
return lazyPropertyColumnAliases;
}
/**
* @deprecated Hibernate no longer uses aliases to read from result sets
*/
@Deprecated
public String getDiscriminatorAlias() { public String getDiscriminatorAlias() {
return DISCRIMINATOR_ALIAS; return DISCRIMINATOR_ALIAS;
} }

View File

@ -1,43 +0,0 @@
/*
* 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.persister.entity;
import org.hibernate.Remove;
/**
* @author Gavin King
*
* @deprecated Replaced by {@link org.hibernate.metamodel.mapping.EntityMappingType}
*/
@Deprecated(since = "6", forRemoval = true)
@Remove
public class BasicEntityPropertyMapping extends AbstractPropertyMapping {
private final AbstractEntityPersister persister;
public BasicEntityPropertyMapping(AbstractEntityPersister persister) {
this.persister = persister;
}
public String[] getIdentifierColumnNames() {
return persister.getIdentifierColumnNames();
}
public String[] getIdentifierColumnReaders() {
return persister.getIdentifierColumnReaders();
}
public String[] getIdentifierColumnReaderTemplates() {
return persister.getIdentifierColumnReaderTemplates();
}
protected String getEntityName() {
return persister.getEntityName();
}
}

View File

@ -1,15 +0,0 @@
/*
* 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.persister.entity;
/**
* @deprecated Just used to singly extend all the deprecated entity persister roles
*/
@Deprecated
public interface DeprecatedEntityStuff extends Loadable, Lockable, Queryable {
}

View File

@ -44,12 +44,12 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
@Deprecated( since = "6.2", forRemoval = true ) @Deprecated( since = "6.2", forRemoval = true )
public class DiscriminatorType<T> extends AbstractType implements BasicType<T> { public class DiscriminatorType<T> extends AbstractType implements BasicType<T> {
private final BasicType<Object> underlyingType; private final BasicType<Object> underlyingType;
private final Loadable persister; private final EntityPersister persister;
private final DiscriminatorConverter converter; private final DiscriminatorConverter converter;
public DiscriminatorType( public DiscriminatorType(
BasicType<?> underlyingType, BasicType<?> underlyingType,
Loadable persister, EntityPersister persister,
DiscriminatorConverter converter) { DiscriminatorConverter converter) {
this.underlyingType = (BasicType<Object>) underlyingType; this.underlyingType = (BasicType<Object>) underlyingType;
this.persister = persister; this.persister = persister;

View File

@ -12,6 +12,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Incubating; import org.hibernate.Incubating;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -42,6 +43,7 @@ import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
import org.hibernate.loader.ast.spi.MultiNaturalIdLoader; import org.hibernate.loader.ast.spi.MultiNaturalIdLoader;
import org.hibernate.loader.ast.spi.NaturalIdLoader; import org.hibernate.loader.ast.spi.NaturalIdLoader;
import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.internal.InFlightEntityMappingType; import org.hibernate.metamodel.mapping.internal.InFlightEntityMappingType;
@ -1216,9 +1218,14 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget
FilterAliasGenerator getFilterAliasGenerator(final String rootAlias); FilterAliasGenerator getFilterAliasGenerator(final String rootAlias);
default FilterAliasGenerator getFilterAliasGenerator(TableGroup rootTableGroup) { default FilterAliasGenerator getFilterAliasGenerator(TableGroup rootTableGroup) {
return new TableGroupFilterAliasGenerator( ( (Joinable) this ).getTableName(), rootTableGroup ); return new TableGroupFilterAliasGenerator( getTableName(), rootTableGroup );
} }
/**
* The table to join to.
*/
String getTableName();
/** /**
* Converts an array of attribute names to a set of indexes, according to the entity metamodel * Converts an array of attribute names to a set of indexes, according to the entity metamodel
* *
@ -1311,5 +1318,101 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget
*/ */
String getIdentitySelectString(); String getIdentitySelectString();
/**
* Get the names of columns used to persist the identifier
*/
String[] getIdentifierColumnNames(); String[] getIdentifierColumnNames();
/**
* Get the result set aliases used for the identifier columns, given a suffix
*/
String[] getIdentifierAliases(String suffix);
/**
* Locks are always applied to the "root table".
*
* @return The root table name
*/
String getRootTableName();
/**
* Get the names of columns on the root table used to persist the identifier.
*
* @return The root table identifier column names.
*/
String[] getRootTableIdentifierColumnNames();
/**
* For versioned entities, get the name of the column (again, expected on the
* root table) used to store the version values.
*
* @return The version column name.
*/
String getVersionColumnName();
/**
* Get the result set aliases used for the property columns, given a suffix (properties of this class, only).
*/
String[] getPropertyAliases(String suffix, int i);
/**
* Get the result set aliases used for the identifier columns, given a suffix
*/
String getDiscriminatorAlias(String suffix);
/**
* @return the column name for the discriminator as specified in the mapping.
*
* @deprecated Use {@link EntityDiscriminatorMapping#getSelectionExpression()} instead
*/
@Deprecated
String getDiscriminatorColumnName();
/**
* Get the discriminator type
*/
Type getDiscriminatorType();
/**
* Does the result set contain rowids?
*/
boolean hasRowId();
/**
* Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).
*/
String[] getSubclassPropertyColumnAliases(String propertyName, String suffix);
/**
* May this (subclass closure) property be fetched using an SQL outer join?
*/
FetchMode getFetchMode(int i);
/**
* Get the type of the numbered property of the class or a subclass.
*/
Type getSubclassPropertyType(int i);
/**
* Get the column names for the given property path
*/
String[] getPropertyColumnNames(String propertyPath);
/**
* All columns to select, when loading.
*/
String selectFragment(String alias, String suffix);
/**
* Retrieve the information needed to properly deal with this entity's discriminator
* in a query.
*
* @return The entity discriminator metadata
*/
DiscriminatorMetadata getTypeDiscriminatorMetadata();
/**
* Given a property path, return the corresponding column name(s).
*/
String[] toColumns(String propertyName);
} }

View File

@ -23,7 +23,6 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.sql.Template;
import org.hibernate.type.AnyType; import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.type.CollectionType; import org.hibernate.type.CollectionType;
@ -35,41 +34,46 @@ import org.hibernate.type.SpecialOneToOneType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* Basic implementation of the {@link PropertyMapping} contract.
*
* @author Gavin King * @author Gavin King
* *
* @deprecated Replaced by {@link org.hibernate.metamodel.mapping.EntityMappingType} * @deprecated Replaced by {@link org.hibernate.metamodel.mapping.EntityMappingType}
*/ */
@Deprecated(since = "6", forRemoval = true) @Deprecated(since = "6", forRemoval = true)
@Remove @Remove
public abstract class AbstractPropertyMapping implements PropertyMapping { class EntityPropertyMapping {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractPropertyMapping.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( EntityPropertyMapping.class );
private final Map<String, Type> typesByPropertyPath = new HashMap<>(); private final Map<String, Type> typesByPropertyPath = new HashMap<>();
private final AbstractEntityPersister persister;
public EntityPropertyMapping(AbstractEntityPersister persister) {
this.persister = persister;
}
public String[] getIdentifierColumnNames() {
return persister.getIdentifierColumnNames();
}
public String[] getIdentifierColumnReaders() {
return persister.getIdentifierColumnReaders();
}
public String[] getIdentifierColumnReaderTemplates() {
return persister.getIdentifierColumnReaderTemplates();
}
protected String getEntityName() {
return persister.getEntityName();
}
//This field is only used during initialization, no need for threadsafety: //This field is only used during initialization, no need for threadsafety:
//FIXME get rid of the field, or at least clear it after boot? Not urgent as we typically won't initialize it at all. //FIXME get rid of the field, or at least clear it after boot?
// Not urgent as we typically won't initialize it at all.
private Set<String> duplicateIncompatiblePaths = null; private Set<String> duplicateIncompatiblePaths = null;
private final Map<String, String[]> columnsByPropertyPath = new HashMap<>(); private final Map<String, String[]> columnsByPropertyPath = new HashMap<>();
private final Map<String, String[]> columnReadersByPropertyPath = new HashMap<>(); private final Map<String, String[]> columnReadersByPropertyPath = new HashMap<>();
private final Map<String, String[]> columnReaderTemplatesByPropertyPath = new HashMap<>(); private final Map<String, String[]> columnReaderTemplatesByPropertyPath = new HashMap<>();
private final Map<String, String[]> formulaTemplatesByPropertyPath = new HashMap<>();
public String[] getIdentifierColumnNames() {
throw new UnsupportedOperationException( "one-to-one is not supported here" );
}
public String[] getIdentifierColumnReaderTemplates() {
throw new UnsupportedOperationException( "one-to-one is not supported here" );
}
public String[] getIdentifierColumnReaders() {
throw new UnsupportedOperationException( "one-to-one is not supported here" );
}
protected abstract String getEntityName();
public Type toType(String propertyName) throws QueryException { public Type toType(String propertyName) throws QueryException {
Type type = typesByPropertyPath.get( propertyName ); Type type = typesByPropertyPath.get( propertyName );
@ -91,25 +95,6 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
return cols; return cols;
} }
public String[] toColumns(String propertyName) throws QueryException {
String[] columns = columnsByPropertyPath.get( propertyName );
if ( columns == null ) {
throw propertyException( propertyName );
}
String[] formulaTemplates = formulaTemplatesByPropertyPath.get( propertyName );
String[] columnReaders = columnReadersByPropertyPath.get( propertyName );
String[] result = new String[columns.length];
for ( int i = 0; i < columns.length; i++ ) {
if ( columnReaders[i] == null ) {
result[i] = StringHelper.replace( formulaTemplates[i], Template.TEMPLATE, "" );
}
else {
result[i] = columnReaders[i];
}
}
return result;
}
private void logDuplicateRegistration(String path, Type existingType, Type type) { private void logDuplicateRegistration(String path, Type existingType, Type type) {
if ( LOG.isTraceEnabled() ) { if ( LOG.isTraceEnabled() ) {
LOG.tracev( LOG.tracev(
@ -139,7 +124,6 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
String[] columns, String[] columns,
String[] columnReaders, String[] columnReaders,
String[] columnReaderTemplates, String[] columnReaderTemplates,
String[] formulaTemplates,
Metadata factory) { Metadata factory) {
Type existingType = typesByPropertyPath.get( path ); Type existingType = typesByPropertyPath.get( path );
if ( existingType != null || ( duplicateIncompatiblePaths != null && duplicateIncompatiblePaths.contains( path ) ) ) { if ( existingType != null || ( duplicateIncompatiblePaths != null && duplicateIncompatiblePaths.contains( path ) ) ) {
@ -197,9 +181,6 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
columnsByPropertyPath.put( path, empty ); columnsByPropertyPath.put( path, empty );
columnReadersByPropertyPath.put( path, empty ); columnReadersByPropertyPath.put( path, empty );
columnReaderTemplatesByPropertyPath.put( path, empty ); columnReaderTemplatesByPropertyPath.put( path, empty );
if ( formulaTemplates != null ) {
formulaTemplatesByPropertyPath.put( path, empty );
}
} }
else { else {
typesByPropertyPath.put( path, commonType ); typesByPropertyPath.put( path, commonType );
@ -212,9 +193,6 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
columnsByPropertyPath.put( path, columns ); columnsByPropertyPath.put( path, columns );
columnReadersByPropertyPath.put( path, columnReaders ); columnReadersByPropertyPath.put( path, columnReaders );
columnReaderTemplatesByPropertyPath.put( path, columnReaderTemplates ); columnReaderTemplatesByPropertyPath.put( path, columnReaderTemplates );
if ( formulaTemplates != null ) {
formulaTemplatesByPropertyPath.put( path, formulaTemplates );
}
} }
} }
@ -253,17 +231,6 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
return clazz2; return clazz2;
} }
/*protected void initPropertyPaths(
final String path,
final Type type,
final String[] columns,
final String[] formulaTemplates,
final Mapping factory)
throws MappingException {
//addFormulaPropertyPath(path, type, formulaTemplates);
initPropertyPaths(path, type, columns, formulaTemplates, factory);
}*/
protected void initPropertyPaths( protected void initPropertyPaths(
final String path, final String path,
final Type type, final Type type,
@ -305,7 +272,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
} }
if ( path != null ) { if ( path != null ) {
addPropertyPath( path, type, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory ); addPropertyPath( path, type, columns, columnReaders, columnReaderTemplates, factory );
} }
if ( type.isComponentType() ) { if ( type.isComponentType() ) {
@ -344,16 +311,6 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
} }
} }
protected void initIdentifierPropertyPaths(
final String path,
final EntityType etype,
final String[] columns,
final String[] columnReaders,
final String[] columnReaderTemplates,
final Metadata factory) throws MappingException {
initIdentifierPropertyPaths(path, etype, columns, columnReaders, columnReaderTemplates, null, factory);
}
protected void initIdentifierPropertyPaths( protected void initIdentifierPropertyPaths(
final String path, final String path,
final EntityType etype, final EntityType etype,
@ -370,14 +327,14 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
if ( etype.isReferenceToPrimaryKey() ) { if ( etype.isReferenceToPrimaryKey() ) {
if ( !hasNonIdentifierPropertyNamedId ) { if ( !hasNonIdentifierPropertyNamedId ) {
String idpath1 = extendPath( path, EntityPersister.ENTITY_ID ); String idpath1 = extendPath( path, EntityPersister.ENTITY_ID );
addPropertyPath( idpath1, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory ); addPropertyPath( idpath1, idtype, columns, columnReaders, columnReaderTemplates, factory );
initPropertyPaths( idpath1, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory ); initPropertyPaths( idpath1, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
} }
} }
if ( !etype.isNullable() && idPropName != null ) { if ( !etype.isNullable() && idPropName != null ) {
String idpath2 = extendPath( path, idPropName ); String idpath2 = extendPath( path, idPropName );
addPropertyPath( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory ); addPropertyPath( idpath2, idtype, columns, columnReaders, columnReaderTemplates, factory );
initPropertyPaths( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory ); initPropertyPaths( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
} }
} }

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.persister.entity; package org.hibernate.persister.entity;
import org.hibernate.metamodel.mapping.Restrictable;
/** /**
* Anything that can be loaded by outer join - namely * Anything that can be loaded by outer join - namely
* persisters for classes or collections. * persisters for classes or collections.
@ -20,25 +18,5 @@ import org.hibernate.metamodel.mapping.Restrictable;
* depending on need * depending on need
*/ */
@Deprecated(since = "6", forRemoval = true) @Deprecated(since = "6", forRemoval = true)
public interface Joinable extends Restrictable { public interface Joinable {
//should this interface extend PropertyMapping?
/**
* An identifying name; a class name or collection role name.
*/
String getName();
/**
* The table to join to.
*/
String getTableName();
/**
* The columns to join on
*/
String[] getKeyColumnNames();
/**
* Is this instance actually a CollectionPersister?
*/
boolean isCollection();
} }

View File

@ -757,17 +757,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
return discriminatorAlias; return discriminatorAlias;
} }
@Override
public String getSubclassForDiscriminatorValue(Object value) {
if ( value == null ) {
return subclassesByDiscriminatorValue.get( NULL_DISCRIMINATOR );
}
else {
final String result = subclassesByDiscriminatorValue.get( value );
return result == null ? subclassesByDiscriminatorValue.get( NOT_NULL_DISCRIMINATOR ) : result;
}
}
@Override @Override
public void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) { public void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
if ( explicitDiscriminatorColumnName != null ) { if ( explicitDiscriminatorColumnName != null ) {
@ -865,11 +854,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
return tableNames[0]; return tableNames[0];
} }
@Override
public String generateFilterConditionAlias(String rootAlias) {
return generateTableAlias( rootAlias, tableSpan - 1 );
}
@Override @Override
public String[] getIdentifierColumnNames() { public String[] getIdentifierColumnNames() {
return tableKeyColumns[0]; return tableKeyColumns[0];
@ -896,7 +880,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
} }
@Override @Override
protected boolean hasMultipleTables() { public boolean hasMultipleTables() {
return true; return true;
} }
@ -980,20 +964,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
return constraintOrderedKeyColumnNames; return constraintOrderedKeyColumnNames;
} }
@Override
public String getRootTableAlias(String drivingAlias) {
return generateTableAlias( drivingAlias, getTableId( getRootTableName(), tableNames ) );
}
@Override
public Declarer getSubclassPropertyDeclarer(String propertyPath) {
if ( "class".equals( propertyPath ) ) {
// special case where we need to force include all subclass joins
return Declarer.SUBCLASS;
}
return super.getSubclassPropertyDeclarer( propertyPath );
}
@Override @Override
public int determineTableNumberForColumn(String columnName) { public int determineTableNumberForColumn(String columnName) {
// HHH-7630: In case the naturalOrder/identifier column is explicitly given in the ordering, check here. // HHH-7630: In case the naturalOrder/identifier column is explicitly given in the ordering, check here.

View File

@ -1,134 +0,0 @@
/*
* 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.persister.entity;
import org.hibernate.FetchMode;
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.type.Type;
/**
* Implemented by any {@link EntityPersister} that may be loaded
* using a {@link org.hibernate.loader.ast.spi.Loader}.
*
* @author Gavin King
*
* @deprecated Use {@link EntityMappingType}
*/
@Deprecated(since = "6", forRemoval = true)
public interface Loadable extends EntityPersister {
String ROWID_ALIAS = "rowid_";
/**
* Does this persistent class have subclasses?
*
* @deprecated See {@link EntityMappingType#hasSubclasses()}
*/
@Deprecated
boolean hasSubclasses();
/**
* Get the discriminator type
*/
Type getDiscriminatorType();
/**
* Get the discriminator value
*
* @deprecated Use {@link EntityMappingType#getDiscriminatorValue()} instead
*/
@Deprecated
Object getDiscriminatorValue();
/**
* Get the concrete subclass corresponding to the given discriminator
* value
*
* @deprecated Use {@link EntityDiscriminatorMapping#resolveDiscriminatorValue} instead
*/
@Deprecated
String getSubclassForDiscriminatorValue(Object value);
/**
* Get the names of columns used to persist the identifier
*/
String[] getIdentifierColumnNames();
/**
* Get the result set aliases used for the identifier columns, given a suffix
*/
String[] getIdentifierAliases(String suffix);
/**
* Get the result set aliases used for the property columns, given a suffix (properties of this class, only).
*/
String[] getPropertyAliases(String suffix, int i);
/**
* Get the result set column names mapped for this property (properties of this class, only).
*/
String[] getPropertyColumnNames(int i);
/**
* Get the result set aliases used for the identifier columns, given a suffix
*/
String getDiscriminatorAlias(String suffix);
/**
* @return the column name for the discriminator as specified in the mapping.
*
* @deprecated Use {@link EntityDiscriminatorMapping#getSelectionExpression()} instead
*/
@Deprecated
String getDiscriminatorColumnName();
/**
* Does the result set contain rowids?
*/
boolean hasRowId();
boolean isAbstract();
/**
* Given a column name and the root table alias in use for the entity hierarchy, determine the proper table alias
* for the table in that hierarchy that contains said column.
*
* @implNote Generally speaking the column is not validated to exist. Most implementations simply return the
* root alias; the exception is {@link JoinedSubclassEntityPersister}.
*
* @param columnName The column name
* @param rootAlias The hierarchy root alias
*
* @return The proper table alias for qualifying the given column.
*/
String getTableAliasForColumn(String columnName, String rootAlias);
/**
* All columns to select, when loading.
*/
String selectFragment(String alias, String suffix);
/**
* Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).
*/
String[] getSubclassPropertyColumnAliases(String propertyName, String suffix);
/**
* May this (subclass closure) property be fetched using an SQL outerjoin?
*/
FetchMode getFetchMode(int i);
/**
* Get the type of the numbered property of the class or a subclass.
*/
Type getSubclassPropertyType(int i);
/**
* Get the column names for the given property path
*/
String[] getPropertyColumnNames(String propertyPath);
}

View File

@ -1,57 +0,0 @@
/*
* 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.persister.entity;
import org.hibernate.metamodel.mapping.EntityMappingType;
/**
* Contract for things that can be locked via a {@link org.hibernate.dialect.lock.LockingStrategy}.
* <p>
* Currently only the root table gets locked, except for the case of HQL and Criteria queries
* against dialects which do not support either (1) FOR UPDATE OF or (2) support hint locking
* (in which case *all* queried tables would be locked).
*
* @author Steve Ebersole
* @since 3.2
*
* @deprecated Use {@link EntityMappingType}
*/
@Deprecated(since = "6", forRemoval = true)
public interface Lockable extends EntityPersister {
/**
* Locks are always applied to the "root table".
*
* @return The root table name
*/
String getRootTableName();
/**
* Get the SQL alias this persister would use for the root table
* given the passed driving alias.
*
* @param drivingAlias The driving alias; or the alias for the table
* mapped by this persister in the hierarchy.
* @return The root table alias.
*/
String getRootTableAlias(String drivingAlias);
/**
* Get the names of columns on the root table used to persist the identifier.
*
* @return The root table identifier column names.
*/
String[] getRootTableIdentifierColumnNames();
/**
* For versioned entities, get the name of the column (again, expected on the
* root table) used to store the version values.
*
* @return The version column name.
*/
String getVersionColumnName();
}

View File

@ -1,66 +0,0 @@
/*
* 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.persister.entity;
import org.hibernate.QueryException;
import org.hibernate.Remove;
import org.hibernate.persister.collection.CompositeElementPropertyMapping;
import org.hibernate.type.Type;
/**
* Contract for all things that know how to map a property to the needed bits of SQL.
* <p>
* The column/formula fragments that represent a property in the table defining the property be obtained by
* calling {@link #toColumns(String)}.
*
* <p>
* Note, the methods here are generally ascribed to accept "property paths". That is a historical necessity because
* of how Hibernate originally understood composites (embeddables) internally. That is in the process of changing
* as Hibernate has added {@link CompositeElementPropertyMapping}
*
* @author Gavin King
* @author Steve Ebersole
*
* @deprecated This interface is obsolete
*/
@Deprecated(since = "6", forRemoval = true)
@Remove
public interface PropertyMapping {
// /**
// * @asciidoc
// *
// * Resolve a sub-reference relative to this PropertyMapping. E.g.,
// * given the PropertyMapping for an entity named `Person` with an embedded
// * property `#name` calling this method with `"name"` returns the
// * PropertyMapping for the `Name` embeddable
// * <p>
// * todo (6.0) : define an exception in the signature for cases where the PropertyMapping
// * cannot be de-referenced (basic values)
// */
// PropertyMapping resolveSubMapping(String name);
// todo (6.0) : add capability to create SqmPath, i.e.
// SqmPath createSqmPath(SqmPath<?> lhs, SqmCreationState creationState);
// todo (6.0) : add capability to resolve SQL tree Expression
// actually define this in ter
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// todo (6.0) remove
/**
* Given a component path expression, get the type of the property
*/
Type toType(String propertyName) throws QueryException;
/**
* Given a property path, return the corresponding column name(s).
*/
String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException;
}

View File

@ -1,163 +0,0 @@
/*
* 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.persister.entity;
import org.hibernate.metamodel.mapping.EntityMappingType;
/**
* Extends the generic {@link EntityPersister} contract to add
* operations required by the Hibernate Query Language
*
* @author Gavin King
*
* @deprecated Use {@link org.hibernate.metamodel.mapping.EntityMappingType}
* instead
*/
@Deprecated(since = "6.0")
public interface Queryable extends Loadable, PropertyMapping, Joinable {
/**
* Is this an abstract class?
*
* @see EntityMappingType#isAbstract()
*/
boolean isAbstract();
/**
* Is this class explicit polymorphism only?
*
* @see EntityMappingType#isExplicitPolymorphism()
*/
boolean isExplicitPolymorphism();
/**
* Get the class that this class is mapped as a subclass of -
* not necessarily the direct superclass
*
* @see EntityMappingType#getSuperMappingType()
*/
String getMappedSuperclass();
/**
* Get the discriminator value for this particular concrete subclass,
* as a string that may be embedded in a select statement
*
* @see EntityMappingType#getDiscriminatorSQLValue()
*/
String getDiscriminatorSQLValue();
/**
* Get the names of columns used to persist the identifier
*/
String[] getIdentifierColumnNames();
/**
* Is the inheritance hierarchy described by this persister contained across
* multiple tables?
*
* @return True if the inheritance hierarchy is spread across multiple tables; false otherwise.
*
* @deprecated Use {@link EntityPersister#getSqmMultiTableMutationStrategy} instead
*/
@Deprecated(since = "6.0")
default boolean isMultiTable() {
return false;
}
/**
* Get the names of all tables used in the hierarchy (up and down) ordered such
* that deletes in the given order would not cause constraint violations.
*
* @return The ordered array of table names.
*/
String[] getConstraintOrderedTableNameClosure();
/**
* For each table specified in {@link #getConstraintOrderedTableNameClosure()}, get
* the columns that define the key between the various hierarchy classes.
* <p>
* The first dimension here corresponds to the table indexes returned in
* {@link #getConstraintOrderedTableNameClosure()}.
* <p>
* The second dimension should have the same length across all the elements in
* the first dimension. If not, that would be a problem ;)
*
*/
String[][] getContraintOrderedTableKeyColumnClosure();
/**
* Given a property name, determine the number of the table which contains the column
* to which this property is mapped.
* <p>
* Note that this is <b>not</b> relative to the results from {@link #getConstraintOrderedTableNameClosure()}.
* It is relative to the subclass table name closure maintained internal to the persister (yick!).
* It is also relative to the indexing used to resolve {@link #getSubclassTableName}...
*
* @param propertyPath The name of the property.
* @return The number of the table to which the property is mapped.
*/
int getSubclassPropertyTableNumber(String propertyPath);
/**
* Determine whether the given property is declared by our
* mapped class, our super class, or one of our subclasses...
* <p>
* Note: the method is called 'subclass property...' simply
* for consistency sake (e.g. {@link #getSubclassPropertyTableNumber}
*
* @param propertyPath The property name.
* @return The property declarer
*/
Declarer getSubclassPropertyDeclarer(String propertyPath);
/**
* Get the name of the table with the given index from the internal
* array.
*
* @param number The index into the internal array.
*/
String getSubclassTableName(int number);
/**
* Is the version property included in insert statements?
*/
boolean isVersionPropertyInsertable();
/**
* The alias used for any filter conditions (mapped where-fragments or
* enabled-filters).
* <p>
* This may or may not be different from the root alias depending upon the
* inheritance mapping strategy.
*
* @param rootAlias The root alias
* @return The alias used for "filter conditions" within the where clause.
*/
String generateFilterConditionAlias(String rootAlias);
/**
* Retrieve the information needed to properly deal with this entity's discriminator
* in a query.
*
* @return The entity discriminator metadata
*/
DiscriminatorMetadata getTypeDiscriminatorMetadata();
String[][] getSubclassPropertyFormulaTemplateClosure();
class Declarer {
public static final Declarer CLASS = new Declarer( "class" );
public static final Declarer SUBCLASS = new Declarer( "subclass" );
public static final Declarer SUPERCLASS = new Declarer( "superclass" );
private final String name;
public Declarer(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
}

View File

@ -48,7 +48,6 @@ import static org.hibernate.internal.util.collections.ArrayHelper.toIntArray;
import static org.hibernate.internal.util.collections.ArrayHelper.toStringArray; import static org.hibernate.internal.util.collections.ArrayHelper.toStringArray;
import static org.hibernate.internal.util.collections.CollectionHelper.toSmallMap; import static org.hibernate.internal.util.collections.CollectionHelper.toSmallMap;
import static org.hibernate.jdbc.Expectations.createExpectation; import static org.hibernate.jdbc.Expectations.createExpectation;
import static org.hibernate.persister.entity.DiscriminatorHelper.NOT_NULL_DISCRIMINATOR;
import static org.hibernate.persister.entity.DiscriminatorHelper.NULL_DISCRIMINATOR; import static org.hibernate.persister.entity.DiscriminatorHelper.NULL_DISCRIMINATOR;
import static org.hibernate.sql.model.ast.builder.TableMutationBuilder.NULL; import static org.hibernate.sql.model.ast.builder.TableMutationBuilder.NULL;
@ -425,17 +424,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
return subclassClosure; return subclassClosure;
} }
@Override
public String getSubclassForDiscriminatorValue(Object value) {
if ( value == null ) {
return subclassesByDiscriminatorValue.get( NULL_DISCRIMINATOR );
}
else {
final String result = subclassesByDiscriminatorValue.get( value );
return result == null ? subclassesByDiscriminatorValue.get( NOT_NULL_DISCRIMINATOR ) : result;
}
}
@Override @Override
public String[] getPropertySpaces() { public String[] getPropertySpaces() {
return spaces; return spaces;
@ -561,7 +549,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
} }
@Override @Override
protected boolean hasMultipleTables() { public boolean hasMultipleTables() {
return getTableSpan() > 1; return getTableSpan() > 1;
} }

View File

@ -298,11 +298,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
return discriminatorSQLValue; return discriminatorSQLValue;
} }
@Override
public String getSubclassForDiscriminatorValue(Object value) {
return subclassByDiscriminatorValue.get( value );
}
@Override @Override
public String[] getPropertySpaces() { public String[] getPropertySpaces() {
return spaces; return spaces;
@ -362,7 +357,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
} }
@Override @Override
protected boolean hasMultipleTables() { public boolean hasMultipleTables() {
// This could also just be true all the time... // This could also just be true all the time...
return isAbstract() || hasSubclasses(); return isAbstract() || hasSubclasses();
} }

View File

@ -248,19 +248,15 @@ public class ResultSetMappingImpl implements ResultSetMapping {
if ( resultBuilders.size() == 1 && domainResults.size() == 1 && domainResults.get( 0 ) instanceof EntityResult ) { if ( resultBuilders.size() == 1 && domainResults.size() == 1 && domainResults.get( 0 ) instanceof EntityResult ) {
// Special case for result set mappings that just fetch a single polymorphic entity // Special case for result set mappings that just fetch a single polymorphic entity
final EntityResult entityResult = (EntityResult) domainResults.get( 0 ); final EntityResult entityResult = (EntityResult) domainResults.get( 0 );
final boolean polymorphic = entityResult.getReferencedMappingContainer() final EntityPersister persister = entityResult.getReferencedMappingContainer().getEntityPersister();
.getEntityPersister() final boolean polymorphic = persister.getEntityMetamodel().isPolymorphic();
.getEntityMetamodel()
.isPolymorphic();
// We only need to check for duplicate aliases if we have join fetches, // We only need to check for duplicate aliases if we have join fetches,
// otherwise we assume that even if there are duplicate aliases, the values are equivalent. // otherwise we assume that even if there are duplicate aliases, the values are equivalent.
// If we don't do that, there is no way to fetch joined inheritance entities // If we don't do that, there is no way to fetch joined inheritance entities
if ( polymorphic && ( legacyFetchBuilders == null || legacyFetchBuilders.isEmpty() ) if ( polymorphic && ( legacyFetchBuilders == null || legacyFetchBuilders.isEmpty() )
&& !entityResult.hasJoinFetches() ) { && !entityResult.hasJoinFetches() ) {
final Set<String> aliases = new TreeSet<>( String.CASE_INSENSITIVE_ORDER ); final Set<String> aliases = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) final AbstractEntityPersister entityPersister = (AbstractEntityPersister) persister;
entityResult.getReferencedMappingContainer()
.getEntityPersister();
for ( String[] columns : entityPersister.getContraintOrderedTableKeyColumnClosure() ) { for ( String[] columns : entityPersister.getContraintOrderedTableKeyColumnClosure() ) {
addColumns( aliases, knownDuplicateAliases, columns ); addColumns( aliases, knownDuplicateAliases, columns );
} }

View File

@ -26,9 +26,7 @@ import org.hibernate.loader.internal.AliasConstantsHelper;
import org.hibernate.metamodel.mapping.CollectionPart; import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Loadable;
import org.hibernate.query.NativeQuery; import org.hibernate.query.NativeQuery;
import org.hibernate.query.results.FetchBuilder; import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.ResultSetMapping; import org.hibernate.query.results.ResultSetMapping;
@ -234,7 +232,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
null, null,
determineNavigablePath( fetchBuilder ) determineNavigablePath( fetchBuilder )
); );
final Loadable loadable = (Loadable) alias2Persister.get( fetchBuilder.getOwnerAlias() ); final EntityPersister loadable = alias2Persister.get( fetchBuilder.getOwnerAlias() );
final List<String> columnNames; final List<String> columnNames;
final String[] columnAliases = loadable.getSubclassPropertyColumnAliases( final String[] columnAliases = loadable.getSubclassPropertyColumnAliases(
fetchBuilder.getFetchableName(), fetchBuilder.getFetchableName(),
@ -306,7 +304,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
String suffix, String suffix,
LockMode lockMode, LockMode lockMode,
NavigablePath navigablePath) { NavigablePath navigablePath) {
final Loadable loadable = (Loadable) entityMapping.getEntityPersister(); final EntityPersister loadable = entityMapping.getEntityPersister();
final DynamicResultBuilderEntityStandard resultBuilderEntity = new DynamicResultBuilderEntityStandard( final DynamicResultBuilderEntityStandard resultBuilderEntity = new DynamicResultBuilderEntityStandard(
entityMapping, entityMapping,
tableAlias, tableAlias,
@ -345,7 +343,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
private void addFetchBuilder( private void addFetchBuilder(
String suffix, String suffix,
Loadable loadable, EntityPersister loadable,
DynamicFetchBuilderContainer resultBuilderEntity, DynamicFetchBuilderContainer resultBuilderEntity,
String tableAlias, String tableAlias,
String[] identifierAliases, String[] identifierAliases,
@ -408,7 +406,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
final CollectionPersister collectionPersister = collectionReturn.getPluralAttribute().getCollectionDescriptor(); final CollectionPersister collectionPersister = collectionReturn.getPluralAttribute().getCollectionDescriptor();
final String[] elementColumnAliases; final String[] elementColumnAliases;
if ( collectionPersister.getElementType().isEntityType() ) { if ( collectionPersister.getElementType().isEntityType() ) {
final Loadable elementPersister = (Loadable) ( ( QueryableCollection ) collectionPersister).getElementPersister(); final EntityPersister elementPersister = collectionPersister.getElementPersister();
final String[] propertyNames = elementPersister.getPropertyNames(); final String[] propertyNames = elementPersister.getPropertyNames();
final String[] identifierAliases = elementPersister.getIdentifierAliases( entitySuffix ); final String[] identifierAliases = elementPersister.getIdentifierAliases( entitySuffix );
final String discriminatorAlias = elementPersister.getDiscriminatorAlias( entitySuffix ); final String discriminatorAlias = elementPersister.getDiscriminatorAlias( entitySuffix );
@ -439,14 +437,9 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
); );
} }
private Loadable getSQLLoadable(String entityName) throws MappingException { private EntityPersister getSQLLoadable(String entityName) throws MappingException {
final EntityPersister entityDescriptor = factory.getRuntimeMetamodels() return factory.getRuntimeMetamodels().getMappingMetamodel()
.getMappingMetamodel()
.getEntityDescriptor( entityName ); .getEntityDescriptor( entityName );
if ( !(entityDescriptor instanceof Loadable) ) {
throw new MappingException( "class persister is not Loadable: " + entityName );
}
return (Loadable) entityDescriptor;
} }
private String generateEntitySuffix() { private String generateEntitySuffix() {
@ -499,12 +492,12 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
return; return;
} }
Loadable persister = (Loadable) rootReturn.getEntityMapping().getEntityPersister(); EntityPersister persister = rootReturn.getEntityMapping().getEntityPersister();
Map<String, String[]> propertyResultsMap = Collections.emptyMap();//rootReturn.getPropertyResultsMap() Map<String, String[]> propertyResultsMap = Collections.emptyMap();//rootReturn.getPropertyResultsMap()
addPersister( rootReturn.getTableAlias(), propertyResultsMap, persister ); addPersister( rootReturn.getTableAlias(), propertyResultsMap, persister );
} }
private void addPersister(String alias, Map<String, String[]> propertyResult, Loadable persister) { private void addPersister(String alias, Map<String, String[]> propertyResult, EntityPersister persister) {
alias2Persister.put( alias, persister ); alias2Persister.put( alias, persister );
String suffix = generateEntitySuffix(); String suffix = generateEntitySuffix();
LOG.tracev( "Mapping alias [{0}] to entity-suffix [{1}]", alias, suffix ); LOG.tracev( "Mapping alias [{0}] to entity-suffix [{1}]", alias, suffix );
@ -514,7 +507,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
private void addCollection(String role, String alias, Map<String, String[]> propertyResults) { private void addCollection(String role, String alias, Map<String, String[]> propertyResults) {
final QueryableCollection collectionDescriptor = (QueryableCollection) final CollectionPersister collectionDescriptor =
factory.getRuntimeMetamodels().getMappingMetamodel() factory.getRuntimeMetamodels().getMappingMetamodel()
.getCollectionDescriptor( role ); .getCollectionDescriptor( role );
@ -525,8 +518,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
collectionPropertyResultMaps.put( alias, propertyResults ); collectionPropertyResultMaps.put( alias, propertyResults );
if ( collectionDescriptor.isOneToMany() || collectionDescriptor.isManyToMany() ) { if ( collectionDescriptor.isOneToMany() || collectionDescriptor.isManyToMany() ) {
Loadable persister = (Loadable) collectionDescriptor.getElementPersister(); addPersister( alias, filter( propertyResults ), collectionDescriptor.getElementPersister() );
addPersister( alias, filter( propertyResults ), persister );
} }
} }
@ -563,7 +555,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
processReturn( alias2Return.get( ownerAlias ) ); processReturn( alias2Return.get( ownerAlias ) );
} }
Loadable ownerPersister = (Loadable) alias2Persister.get( ownerAlias ); EntityPersister ownerPersister = alias2Persister.get( ownerAlias );
Type returnType = ownerPersister.getPropertyType( fetchReturn.getFetchableName() ); Type returnType = ownerPersister.getPropertyType( fetchReturn.getFetchableName() );
if ( returnType.isCollectionType() ) { if ( returnType.isCollectionType() ) {
@ -575,7 +567,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
else if ( returnType.isEntityType() ) { else if ( returnType.isEntityType() ) {
EntityType eType = ( EntityType ) returnType; EntityType eType = ( EntityType ) returnType;
String returnEntityName = eType.getAssociatedEntityName(); String returnEntityName = eType.getAssociatedEntityName();
Loadable persister = getSQLLoadable( returnEntityName ); EntityPersister persister = getSQLLoadable( returnEntityName );
Map<String, String[]> propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap() Map<String, String[]> propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap()
addPersister( alias, propertyResultsMap, persister ); addPersister( alias, propertyResultsMap, persister );
} }
@ -592,13 +584,13 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
} }
@Override @Override
public Loadable getEntityPersister(String alias) { public EntityPersister getEntityPersister(String alias) {
return (Loadable) alias2Persister.get( alias ); return alias2Persister.get( alias );
} }
@Override @Override
public QueryableCollection getCollectionPersister(String alias) { public CollectionPersister getCollectionPersister(String alias) {
return (QueryableCollection) alias2CollectionPersister.get( alias ); return alias2CollectionPersister.get( alias );
} }
@Override @Override

View File

@ -13,8 +13,8 @@ import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.collection.QueryableCollection; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.Loadable; import org.hibernate.persister.entity.EntityPersister;
/** /**
* Substitutes escape sequences of form {@code {alias}}, * Substitutes escape sequences of form {@code {alias}},
@ -36,10 +36,10 @@ public class SQLQueryParser {
public interface ParserContext { public interface ParserContext {
boolean isEntityAlias(String aliasName); boolean isEntityAlias(String aliasName);
Loadable getEntityPersister(String alias); EntityPersister getEntityPersister(String alias);
String getEntitySuffix(String alias); String getEntitySuffix(String alias);
boolean isCollectionAlias(String aliasName); boolean isCollectionAlias(String aliasName);
QueryableCollection getCollectionPersister(String alias); CollectionPersister getCollectionPersister(String alias);
String getCollectionSuffix(String alias); String getCollectionSuffix(String alias);
Map<String, String[]> getPropertyResultsMap(String alias); Map<String, String[]> getPropertyResultsMap(String alias);
} }
@ -207,7 +207,7 @@ public class SQLQueryParser {
String aliasName, String aliasName,
String propertyName) { String propertyName) {
final Map<String, String[]> fieldResults = context.getPropertyResultsMap( aliasName ); final Map<String, String[]> fieldResults = context.getPropertyResultsMap( aliasName );
final QueryableCollection collectionPersister = context.getCollectionPersister( aliasName ); final CollectionPersister collectionPersister = context.getCollectionPersister( aliasName );
final String collectionSuffix = context.getCollectionSuffix( aliasName ); final String collectionSuffix = context.getCollectionSuffix( aliasName );
switch ( propertyName ) { switch ( propertyName ) {
case "*": case "*":
@ -234,7 +234,7 @@ public class SQLQueryParser {
private String resolveProperties(String aliasName, String propertyName) { private String resolveProperties(String aliasName, String propertyName) {
final Map<String, String[]> fieldResults = context.getPropertyResultsMap( aliasName ); final Map<String, String[]> fieldResults = context.getPropertyResultsMap( aliasName );
final Loadable persister = context.getEntityPersister( aliasName ); final EntityPersister persister = context.getEntityPersister( aliasName );
final String suffix = context.getEntitySuffix( aliasName ); final String suffix = context.getEntitySuffix( aliasName );
if ( "*".equals( propertyName ) ) { if ( "*".equals( propertyName ) ) {
if ( !fieldResults.isEmpty() ) { if ( !fieldResults.isEmpty() ) {

View File

@ -614,7 +614,7 @@ public class QuerySqmImpl<R>
final AbstractEntityPersister persister = (AbstractEntityPersister) final AbstractEntityPersister persister = (AbstractEntityPersister)
getSessionFactory().getMappingMetamodel().getEntityDescriptor( entityNameToInsert ); getSessionFactory().getMappingMetamodel().getEntityDescriptor( entityNameToInsert );
boolean useMultiTableInsert = persister.isMultiTable(); boolean useMultiTableInsert = persister.hasMultipleTables();
if ( !useMultiTableInsert && !isSimpleValuesInsert( sqmInsert, persister ) ) { if ( !useMultiTableInsert && !isSimpleValuesInsert( sqmInsert, persister ) ) {
final Generator identifierGenerator = persister.getGenerator(); final Generator identifierGenerator = persister.getGenerator();
if ( identifierGenerator instanceof BulkInsertionCapableIdentifierGenerator if ( identifierGenerator instanceof BulkInsertionCapableIdentifierGenerator

View File

@ -31,7 +31,6 @@ import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.SqlExpressible; import org.hibernate.metamodel.mapping.SqlExpressible;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
import org.hibernate.query.SortDirection; import org.hibernate.query.SortDirection;
import org.hibernate.query.results.TableGroupImpl; import org.hibernate.query.results.TableGroupImpl;
@ -662,7 +661,7 @@ public class CteInsertHandler implements InsertHandler {
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor( rootEntityName ); .getEntityDescriptor( rootEntityName );
final String hierarchyRootTableName = ( (Joinable) rootEntityDescriptor ).getTableName(); final String hierarchyRootTableName = rootEntityDescriptor.getTableName();
final TableReference hierarchyRootTableReference = updatingTableGroup.resolveTableReference( final TableReference hierarchyRootTableReference = updatingTableGroup.resolveTableReference(
updatingTableGroup.getNavigablePath(), updatingTableGroup.getNavigablePath(),
hierarchyRootTableName hierarchyRootTableName

View File

@ -19,7 +19,6 @@ import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
import org.hibernate.query.results.TableGroupImpl; import org.hibernate.query.results.TableGroupImpl;
import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.sqm.ComparisonOperator;
@ -87,7 +86,7 @@ public class CteUpdateHandler extends AbstractCteMutationHandler implements Upda
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor( rootEntityName ); .getEntityDescriptor( rootEntityName );
final String hierarchyRootTableName = ( (Joinable) rootEntityDescriptor ).getTableName(); final String hierarchyRootTableName = rootEntityDescriptor.getTableName();
final TableReference hierarchyRootTableReference = updatingTableGroup.resolveTableReference( final TableReference hierarchyRootTableReference = updatingTableGroup.resolveTableReference(
updatingTableGroup.getNavigablePath(), updatingTableGroup.getNavigablePath(),
hierarchyRootTableName hierarchyRootTableName

View File

@ -25,7 +25,6 @@ import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SelectableConsumer;
import org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper; import org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.DomainQueryExecutionContext;
import org.hibernate.query.spi.QueryOptions; import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.spi.QueryParameterBindings; import org.hibernate.query.spi.QueryParameterBindings;
@ -93,7 +92,7 @@ public class RestrictedDeleteExecutionDelegate extends AbstractDeleteExecutionDe
final EntityPersister entityDescriptor = getSessionFactory().getRuntimeMetamodels() final EntityPersister entityDescriptor = getSessionFactory().getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor( getSqmDelete().getTarget().getEntityName() ); .getEntityDescriptor( getSqmDelete().getTarget().getEntityName() );
final String hierarchyRootTableName = ( (Joinable) entityDescriptor ).getTableName(); final String hierarchyRootTableName = entityDescriptor.getTableName();
final TableGroup deletingTableGroup = getConverter().getMutatingTableGroup(); final TableGroup deletingTableGroup = getConverter().getMutatingTableGroup();
@ -169,7 +168,7 @@ public class RestrictedDeleteExecutionDelegate extends AbstractDeleteExecutionDe
assert getEntityDescriptor() == getEntityDescriptor().getRootEntityDescriptor(); assert getEntityDescriptor() == getEntityDescriptor().getRootEntityDescriptor();
final EntityPersister rootEntityPersister = getEntityDescriptor().getEntityPersister(); final EntityPersister rootEntityPersister = getEntityDescriptor().getEntityPersister();
final String rootTableName = ( (Joinable) rootEntityPersister ).getTableName(); final String rootTableName = rootEntityPersister.getTableName();
final NamedTableReference rootTableReference = (NamedTableReference) tableGroup.resolveTableReference( final NamedTableReference rootTableReference = (NamedTableReference) tableGroup.resolveTableReference(
tableGroup.getNavigablePath(), tableGroup.getNavigablePath(),
rootTableName rootTableName

View File

@ -7,9 +7,6 @@
package org.hibernate.query.sqm.mutation.internal.temptable; package org.hibernate.query.sqm.mutation.internal.temptable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
@ -24,7 +21,6 @@ import org.hibernate.generator.Generator;
import org.hibernate.id.OptimizableGenerator; import org.hibernate.id.OptimizableGenerator;
import org.hibernate.id.enhanced.Optimizer; import org.hibernate.id.enhanced.Optimizer;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.DomainQueryExecutionContext;
import org.hibernate.query.sqm.internal.DomainParameterXref; import org.hibernate.query.sqm.internal.DomainParameterXref;
@ -33,7 +29,6 @@ import org.hibernate.query.sqm.mutation.internal.InsertHandler;
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter; import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
import org.hibernate.query.sqm.mutation.internal.SqmInsertStrategyHelper; import org.hibernate.query.sqm.mutation.internal.SqmInsertStrategyHelper;
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter; import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
import org.hibernate.query.sqm.tree.expression.SqmParameter;
import org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement; import org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement;
import org.hibernate.query.sqm.tree.insert.SqmInsertStatement; import org.hibernate.query.sqm.tree.insert.SqmInsertStatement;
import org.hibernate.query.sqm.tree.insert.SqmInsertValuesStatement; import org.hibernate.query.sqm.tree.insert.SqmInsertValuesStatement;

View File

@ -6,33 +6,19 @@
*/ */
package org.hibernate.query.sqm.mutation.internal.temptable; package org.hibernate.query.sqm.mutation.internal.temptable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Function;
import org.hibernate.dialect.temptable.TemporaryTable; import org.hibernate.dialect.temptable.TemporaryTable;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.MappingMetamodel; import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.DomainQueryExecutionContext;
import org.hibernate.query.sqm.internal.DomainParameterXref; import org.hibernate.query.sqm.internal.DomainParameterXref;
import org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter; import org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter;
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter; import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
import org.hibernate.query.sqm.mutation.internal.UpdateHandler; import org.hibernate.query.sqm.mutation.internal.UpdateHandler;
import org.hibernate.query.sqm.mutation.spi.AbstractMutationHandler; import org.hibernate.query.sqm.mutation.spi.AbstractMutationHandler;
import org.hibernate.query.sqm.tree.expression.SqmParameter;
import org.hibernate.query.sqm.tree.predicate.SqmWhereClause;
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement; import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin; import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
@ -40,9 +26,13 @@ import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.ast.tree.predicate.PredicateCollector; import org.hibernate.sql.ast.tree.predicate.PredicateCollector;
import org.hibernate.sql.ast.tree.update.Assignment; import org.hibernate.sql.ast.tree.update.Assignment;
import org.hibernate.sql.exec.spi.ExecutionContext; import org.hibernate.sql.exec.spi.ExecutionContext;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Function;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@ -60,8 +50,6 @@ public class TableBasedUpdateHandler
private final Function<SharedSessionContractImplementor,String> sessionUidAccess; private final Function<SharedSessionContractImplementor,String> sessionUidAccess;
private final DomainParameterXref domainParameterXref; private final DomainParameterXref domainParameterXref;
private final EntityPersister entityDescriptor;
public TableBasedUpdateHandler( public TableBasedUpdateHandler(
SqmUpdateStatement<?> sqmUpdate, SqmUpdateStatement<?> sqmUpdate,
DomainParameterXref domainParameterXref, DomainParameterXref domainParameterXref,
@ -74,9 +62,6 @@ public class TableBasedUpdateHandler
this.afterUseAction = afterUseAction; this.afterUseAction = afterUseAction;
this.sessionUidAccess = sessionUidAccess; this.sessionUidAccess = sessionUidAccess;
this.domainParameterXref = domainParameterXref; this.domainParameterXref = domainParameterXref;
final String targetEntityName = sqmUpdate.getTarget().getEntityName();
this.entityDescriptor = sessionFactory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor( targetEntityName );
} }
protected SqmUpdateStatement<?> getSqmUpdate() { protected SqmUpdateStatement<?> getSqmUpdate() {
@ -110,7 +95,7 @@ public class TableBasedUpdateHandler
final String rootEntityName = entityDescriptor.getRootEntityName(); final String rootEntityName = entityDescriptor.getRootEntityName();
final EntityPersister rootEntityDescriptor = domainModel.getEntityDescriptor( rootEntityName ); final EntityPersister rootEntityDescriptor = domainModel.getEntityDescriptor( rootEntityName );
final String hierarchyRootTableName = ( (Joinable) rootEntityDescriptor ).getTableName(); final String hierarchyRootTableName = rootEntityDescriptor.getTableName();
final MultiTableSqmMutationConverter converterDelegate = new MultiTableSqmMutationConverter( final MultiTableSqmMutationConverter converterDelegate = new MultiTableSqmMutationConverter(
entityDescriptor, entityDescriptor,

View File

@ -58,7 +58,7 @@ import org.hibernate.metamodel.mapping.ModelPartContainer;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.SqlTypedMapping; import org.hibernate.metamodel.mapping.SqlTypedMapping;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.Loadable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.internal.SqlFragmentPredicate; import org.hibernate.persister.internal.SqlFragmentPredicate;
import org.hibernate.query.IllegalQueryOperationException; import org.hibernate.query.IllegalQueryOperationException;
import org.hibernate.query.ReturnableType; import org.hibernate.query.ReturnableType;
@ -8611,8 +8611,8 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
} }
private String[] determineKeyColumnNames(ModelPart modelPart) { private String[] determineKeyColumnNames(ModelPart modelPart) {
if ( modelPart instanceof Loadable ) { if ( modelPart instanceof EntityPersister) {
return ( (Loadable) modelPart ).getIdentifierColumnNames(); return ( (EntityPersister) modelPart ).getIdentifierColumnNames();
} }
else if ( modelPart instanceof PluralAttributeMapping ) { else if ( modelPart instanceof PluralAttributeMapping ) {
return ((PluralAttributeMapping) modelPart).getCollectionDescriptor().getKeyColumnAliases( null ); return ((PluralAttributeMapping) modelPart).getCollectionDescriptor().getKeyColumnAliases( null );

View File

@ -15,7 +15,6 @@ import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.MappingModelExpressible; import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.mapping.MappingType;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer; import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelection;
@ -35,7 +34,7 @@ public class EntityTypeLiteral
public EntityTypeLiteral(EntityPersister entityTypeDescriptor) { public EntityTypeLiteral(EntityPersister entityTypeDescriptor) {
this.entityTypeDescriptor = entityTypeDescriptor; this.entityTypeDescriptor = entityTypeDescriptor;
this.discriminatorType = (DiscriminatorType) ( (Queryable) entityTypeDescriptor ).getTypeDiscriminatorMetadata().getResolutionType(); this.discriminatorType = (DiscriminatorType) entityTypeDescriptor.getTypeDiscriminatorMetadata().getResolutionType();
} }
public EntityPersister getEntityTypeDescriptor() { public EntityPersister getEntityTypeDescriptor() {

View File

@ -27,7 +27,6 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.spi.NavigablePath; import org.hibernate.spi.NavigablePath;
@ -205,7 +204,7 @@ public class ResultsHelper {
boolean isPutFromLoad = true; boolean isPutFromLoad = true;
if ( collectionDescriptor.getElementType().isAssociationType() ) { if ( collectionDescriptor.getElementType().isAssociationType() ) {
final EntityPersister entityPersister = ( (QueryableCollection) collectionDescriptor ).getElementPersister(); final EntityPersister entityPersister = collectionDescriptor.getElementPersister();
for ( Object id : entry.getState() ) { for ( Object id : entry.getState() ) {
if ( persistenceContext.wasInsertedDuringTransaction( entityPersister, id ) ) { if ( persistenceContext.wasInsertedDuringTransaction( entityPersister, id ) ) {
isPutFromLoad = false; isPutFromLoad = false;

View File

@ -39,7 +39,6 @@ import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable; import org.hibernate.persister.entity.Joinable;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
@ -467,7 +466,7 @@ public abstract class CollectionType extends AbstractType implements Association
throws MappingException { throws MappingException {
try { try {
QueryableCollection collectionPersister = (QueryableCollection) factory.getRuntimeMetamodels().getMappingMetamodel().getCollectionDescriptor( role ); CollectionPersister collectionPersister = factory.getRuntimeMetamodels().getMappingMetamodel().getCollectionDescriptor( role );
if ( !collectionPersister.getElementType().isEntityType() ) { if ( !collectionPersister.getElementType().isEntityType() ) {
throw new MappingException( throw new MappingException(

View File

@ -33,7 +33,6 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.graph.RootGraph; import org.hibernate.graph.RootGraph;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.query.NullPrecedence; import org.hibernate.query.NullPrecedence;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import org.hibernate.sql.SimpleSelect; import org.hibernate.sql.SimpleSelect;
@ -310,9 +309,8 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
s.getTransaction().begin(); s.getTransaction().begin();
try { try {
final QueryableCollection queryableCollection = (QueryableCollection) transactionsPersister;
SimpleSelect select = new SimpleSelect( sessionFactory() ) SimpleSelect select = new SimpleSelect( sessionFactory() )
.setTableName( queryableCollection.getTableName() ) .setTableName( transactionsPersister.getTableName() )
.addColumn( "code" ) .addColumn( "code" )
.addColumn( "transactions_index" ); .addColumn( "transactions_index" );
final String sql = select.toStatementString(); final String sql = select.toStatementString();

View File

@ -15,6 +15,7 @@ import java.util.Set;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.Filter; import org.hibernate.Filter;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -60,6 +61,7 @@ import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy; import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.DiscriminatorMetadata;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.UniqueKeyEntry; import org.hibernate.persister.entity.UniqueKeyEntry;
import org.hibernate.persister.entity.mutation.DeleteCoordinator; import org.hibernate.persister.entity.mutation.DeleteCoordinator;
@ -861,6 +863,91 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
public GeneratedValuesMutationDelegate getUpdateDelegate() { public GeneratedValuesMutationDelegate getUpdateDelegate() {
return null; return null;
} }
@Override
public String getTableName() {
return "";
}
@Override
public String[] getIdentifierAliases(String suffix) {
return new String[0];
}
@Override
public String getRootTableName() {
return "";
}
@Override
public String[] getRootTableIdentifierColumnNames() {
return new String[0];
}
@Override
public String getVersionColumnName() {
return "";
}
@Override
public String[] getPropertyAliases(String suffix, int i) {
return new String[0];
}
@Override
public String getDiscriminatorAlias(String suffix) {
return "";
}
@Override
public String getDiscriminatorColumnName() {
return "";
}
@Override
public Type getDiscriminatorType() {
return null;
}
@Override
public boolean hasRowId() {
return false;
}
@Override
public String[] getSubclassPropertyColumnAliases(String propertyName, String suffix) {
return new String[0];
}
@Override
public FetchMode getFetchMode(int i) {
return null;
}
@Override
public Type getSubclassPropertyType(int i) {
return null;
}
@Override
public String[] getPropertyColumnNames(String propertyPath) {
return new String[0];
}
@Override
public String selectFragment(String alias, String suffix) {
return "";
}
@Override
public DiscriminatorMetadata getTypeDiscriminatorMetadata() {
return null;
}
@Override
public String[] toColumns(String propertyName) {
return new String[0];
}
} }
public static class NoopCollectionPersister implements CollectionPersister { public static class NoopCollectionPersister implements CollectionPersister {
@ -1124,5 +1211,30 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
public void applyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState) { public void applyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState) {
} }
@Override
public String getIdentifierColumnName() {
return "";
}
@Override
public String getTableName() {
return "";
}
@Override
public String selectFragment(String alias, String columnSuffix) {
return "";
}
@Override
public String[] getCollectionPropertyColumnAliases(String propertyName, String string) {
return new String[0];
}
@Override
public EntityPersister getElementPersister() {
return null;
}
} }
} }

View File

@ -16,7 +16,6 @@ import org.hibernate.collection.spi.PersistentList;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.sql.ComparisonRestriction; import org.hibernate.sql.ComparisonRestriction;
import org.hibernate.sql.SimpleSelect; import org.hibernate.sql.SimpleSelect;
@ -72,9 +71,8 @@ public class PersistentListTest {
session2 -> { session2 -> {
session2.doWork( session2.doWork(
connection -> { connection -> {
final QueryableCollection queryableCollection = (QueryableCollection) collectionPersister;
SimpleSelect select = new SimpleSelect( sessionFactory ) SimpleSelect select = new SimpleSelect( sessionFactory )
.setTableName( queryableCollection.getTableName() ) .setTableName( collectionPersister.getTableName() )
.addColumn( "NAME" ) .addColumn( "NAME" )
.addColumn( "LIST_INDEX" ) .addColumn( "LIST_INDEX" )
.addRestriction( "NAME", ComparisonRestriction.Operator.NE, "?" ); .addRestriction( "NAME", ComparisonRestriction.Operator.NE, "?" );
@ -133,9 +131,8 @@ public class PersistentListTest {
session2 -> { session2 -> {
session2.doWork( session2.doWork(
connection -> { connection -> {
final QueryableCollection queryableCollection = (QueryableCollection) collectionPersister;
SimpleSelect select = new SimpleSelect( sessionFactory ) SimpleSelect select = new SimpleSelect( sessionFactory )
.setTableName( queryableCollection.getTableName() ) .setTableName( collectionPersister.getTableName() )
.addColumn( "order_id" ) .addColumn( "order_id" )
.addColumn( "INDX" ) .addColumn( "INDX" )
.addColumn( "PRD_CODE" ); .addColumn( "PRD_CODE" );

View File

@ -15,7 +15,7 @@ import org.hibernate.annotations.FetchMode;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper; import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.persister.entity.Loadable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -172,7 +172,7 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels() EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor(entityClass.getName()); .getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
@ -180,7 +180,7 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels() EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor(entityClass.getName()); .getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );

View File

@ -14,7 +14,7 @@ import org.hibernate.annotations.FetchMode;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper; import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.persister.entity.Loadable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -168,7 +168,7 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels() EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor(entityClass.getName()); .getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
@ -176,7 +176,7 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels() EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor(entityClass.getName()); .getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );

View File

@ -12,7 +12,7 @@ import org.hibernate.annotations.Proxy;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper; import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.persister.entity.Loadable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -89,7 +89,7 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels() EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor(entityClass.getName()); .getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
@ -97,7 +97,7 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels() EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor(entityClass.getName()); .getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );

View File

@ -15,6 +15,7 @@ import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
@ -59,6 +60,7 @@ import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.orm.test.jpa.SettingsGenerator; import org.hibernate.orm.test.jpa.SettingsGenerator;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.DiscriminatorMetadata;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.UniqueKeyEntry; import org.hibernate.persister.entity.UniqueKeyEntry;
import org.hibernate.persister.entity.mutation.DeleteCoordinator; import org.hibernate.persister.entity.mutation.DeleteCoordinator;
@ -892,6 +894,91 @@ public class PersisterClassProviderTest {
public GeneratedValuesMutationDelegate getUpdateDelegate() { public GeneratedValuesMutationDelegate getUpdateDelegate() {
return null; return null;
} }
@Override
public String getTableName() {
return "";
}
@Override
public String[] getIdentifierAliases(String suffix) {
return new String[0];
}
@Override
public String getRootTableName() {
return "";
}
@Override
public String[] getRootTableIdentifierColumnNames() {
return new String[0];
}
@Override
public String getVersionColumnName() {
return "";
}
@Override
public String[] getPropertyAliases(String suffix, int i) {
return new String[0];
}
@Override
public String getDiscriminatorAlias(String suffix) {
return "";
}
@Override
public String getDiscriminatorColumnName() {
return "";
}
@Override
public Type getDiscriminatorType() {
return null;
}
@Override
public boolean hasRowId() {
return false;
}
@Override
public String[] getSubclassPropertyColumnAliases(String propertyName, String suffix) {
return new String[0];
}
@Override
public FetchMode getFetchMode(int i) {
return null;
}
@Override
public Type getSubclassPropertyType(int i) {
return null;
}
@Override
public String[] getPropertyColumnNames(String propertyPath) {
return new String[0];
}
@Override
public String selectFragment(String alias, String suffix) {
return "";
}
@Override
public DiscriminatorMetadata getTypeDiscriminatorMetadata() {
return null;
}
@Override
public String[] toColumns(String propertyName) {
return new String[0];
}
} }
public static class GoofyException extends RuntimeException { public static class GoofyException extends RuntimeException {

View File

@ -15,6 +15,7 @@ import java.util.Objects;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
@ -58,6 +59,7 @@ import org.hibernate.metamodel.mapping.TableDetails;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy; import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.DiscriminatorMetadata;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.UniqueKeyEntry; import org.hibernate.persister.entity.UniqueKeyEntry;
import org.hibernate.persister.entity.mutation.DeleteCoordinator; import org.hibernate.persister.entity.mutation.DeleteCoordinator;
@ -1000,4 +1002,89 @@ public class CustomPersister implements EntityPersister {
public GeneratedValuesMutationDelegate getUpdateDelegate() { public GeneratedValuesMutationDelegate getUpdateDelegate() {
return null; return null;
} }
@Override
public String getTableName() {
return "";
}
@Override
public String[] getIdentifierAliases(String suffix) {
return new String[0];
}
@Override
public String getRootTableName() {
return "";
}
@Override
public String[] getRootTableIdentifierColumnNames() {
return new String[0];
}
@Override
public String getVersionColumnName() {
return "";
}
@Override
public String[] getPropertyAliases(String suffix, int i) {
return new String[0];
}
@Override
public String getDiscriminatorAlias(String suffix) {
return "";
}
@Override
public String getDiscriminatorColumnName() {
return "";
}
@Override
public Type getDiscriminatorType() {
return null;
}
@Override
public boolean hasRowId() {
return false;
}
@Override
public String[] getSubclassPropertyColumnAliases(String propertyName, String suffix) {
return new String[0];
}
@Override
public FetchMode getFetchMode(int i) {
return null;
}
@Override
public Type getSubclassPropertyType(int i) {
return null;
}
@Override
public String[] getPropertyColumnNames(String propertyPath) {
return new String[0];
}
@Override
public String selectFragment(String alias, String suffix) {
return "";
}
@Override
public DiscriminatorMetadata getTypeDiscriminatorMetadata() {
return null;
}
@Override
public String[] toColumns(String propertyName) {
return new String[0];
}
} }

View File

@ -17,7 +17,6 @@ import org.hibernate.annotations.Formula;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;

View File

@ -13,7 +13,6 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.ast.spi.AfterLoadAction; import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor; import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.Loadable;
import org.hibernate.query.sqm.tree.select.SqmSelectStatement; import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.ast.spi.SqlAstCreationContext; import org.hibernate.sql.ast.spi.SqlAstCreationContext;

View File

@ -13,15 +13,13 @@ import java.util.List;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.ValuedModelPart; import org.hibernate.metamodel.mapping.ValuedModelPart;
import org.hibernate.metamodel.mapping.ordering.OrderByFragment; import org.hibernate.metamodel.mapping.ordering.OrderByFragment;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.query.ReturnableType; import org.hibernate.query.ReturnableType;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.query.sqm.function.FunctionRenderer; import org.hibernate.query.sqm.function.FunctionRenderer;
import org.hibernate.spi.NavigablePath; import org.hibernate.spi.NavigablePath;
import org.hibernate.query.spi.QueryEngine; import org.hibernate.query.spi.QueryEngine;
import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.function.AbstractSqmFunctionDescriptor; import org.hibernate.query.sqm.function.AbstractSqmFunctionDescriptor;
import org.hibernate.query.sqm.function.FunctionRenderingSupport;
import org.hibernate.query.sqm.function.SelfRenderingSqmFunction; import org.hibernate.query.sqm.function.SelfRenderingSqmFunction;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor; import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.produce.function.ArgumentsValidator; import org.hibernate.query.sqm.produce.function.ArgumentsValidator;
@ -201,7 +199,7 @@ public class OrderByFragmentFunction extends AbstractSqmFunctionDescriptor {
final TableGroup tableGroup = ( (FromClauseIndex) walker.getFromClauseAccess() ).findTableGroup( final TableGroup tableGroup = ( (FromClauseIndex) walker.getFromClauseAccess() ).findTableGroup(
sqmAlias sqmAlias
); );
final QueryableCollection collectionDescriptor = (QueryableCollection) walker.getCreationContext() final CollectionPersister collectionDescriptor = walker.getCreationContext()
.getSessionFactory() .getSessionFactory()
.getRuntimeMetamodels() .getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
@ -220,7 +218,7 @@ public class OrderByFragmentFunction extends AbstractSqmFunctionDescriptor {
targetTableExpression = collectionDescriptor.getTableName(); targetTableExpression = collectionDescriptor.getTableName();
} }
else { else {
targetTableExpression = ( (Joinable) collectionDescriptor.getElementPersister() ).getTableName(); targetTableExpression = collectionDescriptor.getElementPersister().getTableName();
} }
// We apply the fragment here and return null to signal that this is a no-op // We apply the fragment here and return null to signal that this is a no-op
fragment.apply( fragment.apply(

View File

@ -43,7 +43,7 @@ import org.hibernate.event.spi.EventSource;
import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.persister.entity.JoinedSubclassEntityPersister; import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
import org.hibernate.persister.entity.Queryable; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.UnionSubclassEntityPersister; import org.hibernate.persister.entity.UnionSubclassEntityPersister;
import org.hibernate.property.access.spi.Getter; import org.hibernate.property.access.spi.Getter;
import org.hibernate.sql.ComparisonRestriction; import org.hibernate.sql.ComparisonRestriction;
@ -405,8 +405,8 @@ public class ValidityAuditStrategy implements AuditStrategy {
return convertRevEndTimestampToDate( value ); return convertRevEndTimestampToDate( value );
} }
private Queryable getQueryable(String entityName, SessionImplementor sessionImplementor) { private EntityPersister getEntityPersister(String entityName, SessionImplementor sessionImplementor) {
return (Queryable) sessionImplementor.getFactory() return sessionImplementor.getFactory()
.getMappingMetamodel() .getMappingMetamodel()
.getEntityDescriptor( entityName ); .getEntityDescriptor( entityName );
} }
@ -497,7 +497,7 @@ public class ValidityAuditStrategy implements AuditStrategy {
Object id, Object id,
Object revision) { Object revision) {
Queryable entity = getQueryable( entityName, session ); EntityPersister entity = getEntityPersister( entityName, session );
final List<UpdateContext> contexts = new ArrayList<>( 0 ); final List<UpdateContext> contexts = new ArrayList<>( 0 );
// HHH-9062 - update inherited // HHH-9062 - update inherited
@ -517,7 +517,7 @@ public class ValidityAuditStrategy implements AuditStrategy {
); );
entityName = entity.getEntityMappingType().getSuperMappingType().getEntityName(); entityName = entity.getEntityMappingType().getSuperMappingType().getEntityName();
auditEntityName = configuration.getAuditEntityName( entityName ); auditEntityName = configuration.getAuditEntityName( entityName );
entity = getQueryable( entityName, session ); entity = getEntityPersister( entityName, session );
} }
} }
} }
@ -545,11 +545,11 @@ public class ValidityAuditStrategy implements AuditStrategy {
Object id, Object id,
Object revision) { Object revision) {
final Queryable entity = getQueryable( entityName, session ); final EntityPersister entity = getEntityPersister( entityName, session );
final Queryable rootEntity = getQueryable( entity.getRootEntityName(), session ); final EntityPersister rootEntity = getEntityPersister( entity.getRootEntityName(), session );
final Queryable auditEntity = getQueryable( auditEntityName, session ); final EntityPersister auditEntity = getEntityPersister( auditEntityName, session );
final Queryable rootAuditEntity = getQueryable( auditEntity.getRootEntityName(), session ); final EntityPersister rootAuditEntity = getEntityPersister( auditEntity.getRootEntityName(), session );
final Queryable revisionEntity = getQueryable( configuration.getRevisionInfo().getRevisionInfoEntityName(), session ); final EntityPersister revisionEntity = getEntityPersister( configuration.getRevisionInfo().getRevisionInfoEntityName(), session );
final Number revisionNumber = getRevisionNumber( configuration, revision ); final Number revisionNumber = getRevisionNumber( configuration, revision );
@ -611,8 +611,8 @@ public class ValidityAuditStrategy implements AuditStrategy {
Object id, Object id,
Object revision) { Object revision) {
final Queryable entity = getQueryable( entityName, session ); final EntityPersister entity = getEntityPersister( entityName, session );
final Queryable auditEntity = getQueryable( auditEntityName, session ); final EntityPersister auditEntity = getEntityPersister( auditEntityName, session );
// The expected SQL is an update statement as follows: // The expected SQL is an update statement as follows:
@ -651,7 +651,7 @@ public class ValidityAuditStrategy implements AuditStrategy {
return reader.getRevisionNumber( revisionEntity ); return reader.getRevisionNumber( revisionEntity );
} }
private String getUpdateTableName(Queryable rootEntity, Queryable rootAuditEntity, Queryable auditEntity) { private String getUpdateTableName(EntityPersister rootEntity, EntityPersister rootAuditEntity, EntityPersister auditEntity) {
if ( rootEntity instanceof UnionSubclassEntityPersister ) { if ( rootEntity instanceof UnionSubclassEntityPersister ) {
// we need to specially handle union-subclass mappings // we need to specially handle union-subclass mappings
return auditEntity.getMappedTableDetails().getTableName(); return auditEntity.getMappedTableDetails().getTableName();

View File

@ -6,11 +6,10 @@
*/ */
package org.hibernate.processor.validation; package org.hibernate.processor.validation;
import org.hibernate.FetchMode;
import org.hibernate.QueryException;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.collection.QueryableCollection; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.type.CollectionType; import org.hibernate.type.CollectionType;
import org.hibernate.type.ListType; import org.hibernate.type.ListType;
import org.hibernate.type.MapType; import org.hibernate.type.MapType;
@ -23,10 +22,7 @@ import static org.hibernate.processor.validation.MockSessionFactory.typeConfigur
* @author Gavin King * @author Gavin King
*/ */
@SuppressWarnings("nullness") @SuppressWarnings("nullness")
public abstract class MockCollectionPersister implements QueryableCollection { public abstract class MockCollectionPersister implements CollectionPersister, Joinable {
private static final String[] ID_COLUMN = {"id"};
private static final String[] INDEX_COLUMN = {"pos"};
private final String role; private final String role;
private final MockSessionFactory factory; private final MockSessionFactory factory;
@ -51,11 +47,6 @@ public abstract class MockCollectionPersister implements QueryableCollection {
return role; return role;
} }
@Override
public String getName() {
return role;
}
@Override @Override
public CollectionType getCollectionType() { public CollectionType getCollectionType() {
return collectionType; return collectionType;
@ -68,25 +59,6 @@ public abstract class MockCollectionPersister implements QueryableCollection {
abstract Type getElementPropertyType(String propertyPath); abstract Type getElementPropertyType(String propertyPath);
@Override
public Type toType(String propertyName) throws QueryException {
if ("index".equals(propertyName)) {
//this is what AbstractCollectionPersister does!
//TODO: move it to FromElementType:626 or all
// the way to CollectionPropertyMapping
return getIndexType();
}
Type type = getElementPropertyType(propertyName);
if (type==null) {
throw new QueryException(elementType.getName()
+ " has no mapped "
+ propertyName);
}
else {
return type;
}
}
@Override @Override
public Type getKeyType() { public Type getKeyType() {
return getOwnerEntityPersister().getIdentifierType(); return getOwnerEntityPersister().getIdentifierType();
@ -153,54 +125,8 @@ public abstract class MockCollectionPersister implements QueryableCollection {
return null; return null;
} }
@Override
public String[] getIndexColumnNames() {
return INDEX_COLUMN;
}
@Override
public String[] getIndexColumnNames(String alias) {
return INDEX_COLUMN;
}
@Override
public String[] getIndexFormulas() {
return null;
}
@Override
public String[] getElementColumnNames(String alias) {
return new String[] {""};
}
@Override
public String[] getElementColumnNames() {
return new String[] {""};
}
@Override
public FetchMode getFetchMode() {
return FetchMode.DEFAULT;
}
@Override @Override
public String getTableName() { public String getTableName() {
return role; return role;
} }
@Override
public String[] getKeyColumnNames() {
return ID_COLUMN;
}
@Override
public boolean isCollection() {
return true;
}
@Override
public String[] toColumns(String propertyName) {
return new String[] {""};
}
} }

View File

@ -7,11 +7,10 @@
package org.hibernate.processor.validation; package org.hibernate.processor.validation;
import jakarta.persistence.AccessType; import jakarta.persistence.AccessType;
import org.hibernate.QueryException;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.entity.DiscriminatorMetadata; import org.hibernate.persister.entity.DiscriminatorMetadata;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Queryable; import org.hibernate.persister.entity.Joinable;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.Type; import org.hibernate.type.Type;
@ -30,7 +29,7 @@ import static org.hibernate.processor.validation.MockSessionFactory.typeConfigur
* @author Gavin King * @author Gavin King
*/ */
@SuppressWarnings("nullness") @SuppressWarnings("nullness")
public abstract class MockEntityPersister implements EntityPersister, Queryable, DiscriminatorMetadata { public abstract class MockEntityPersister implements EntityPersister, Joinable, DiscriminatorMetadata {
private static final String[] ID_COLUMN = {"id"}; private static final String[] ID_COLUMN = {"id"};
@ -91,11 +90,6 @@ public abstract class MockEntityPersister implements EntityPersister, Queryable,
return entityName; return entityName;
} }
@Override
public String getName() {
return entityName;
}
@Override @Override
public final Type getPropertyType(String propertyPath) { public final Type getPropertyType(String propertyPath) {
Type result = propertyTypesByName.get(propertyPath); Type result = propertyTypesByName.get(propertyPath);
@ -129,17 +123,6 @@ public abstract class MockEntityPersister implements EntityPersister, Queryable,
return "id"; return "id";
} }
@Override
public Type toType(String propertyName) throws QueryException {
Type type = getPropertyType(propertyName);
if (type == null) {
throw new QueryException(getEntityName()
+ " has no mapped "
+ propertyName);
}
return type;
}
@Override @Override
public String getRootEntityName() { public String getRootEntityName() {
for (MockEntityPersister persister : factory.getMockEntityPersisters()) { for (MockEntityPersister persister : factory.getMockEntityPersisters()) {
@ -162,11 +145,6 @@ public abstract class MockEntityPersister implements EntityPersister, Queryable,
return names; return names;
} }
@Override
public Declarer getSubclassPropertyDeclarer(String s) {
return Declarer.CLASS;
}
@Override @Override
public String[] toColumns(String propertyName) { public String[] toColumns(String propertyName) {
return new String[] { "" }; return new String[] { "" };
@ -187,11 +165,6 @@ public abstract class MockEntityPersister implements EntityPersister, Queryable,
return this; return this;
} }
@Override
public String[] getKeyColumnNames() {
return getIdentifierColumnNames();
}
@Override @Override
public String[] getIdentifierColumnNames() { public String[] getIdentifierColumnNames() {
return ID_COLUMN; return ID_COLUMN;