HHH-17833 change log warnings for invalid mappings to exceptions

finally decided to just put an end to this because it's bad and that's that
This commit is contained in:
Gavin King 2024-03-10 17:17:37 +01:00
parent 688bb8a222
commit 53301b530d
28 changed files with 155 additions and 248 deletions

View File

@ -8,7 +8,6 @@ package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -28,7 +27,6 @@ import org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource;
import org.hibernate.boot.model.source.spi.AttributePath; import org.hibernate.boot.model.source.spi.AttributePath;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.usertype.internal.AbstractTimeZoneStorageCompositeUserType; import org.hibernate.usertype.internal.AbstractTimeZoneStorageCompositeUserType;
import org.hibernate.usertype.internal.OffsetTimeCompositeUserType; import org.hibernate.usertype.internal.OffsetTimeCompositeUserType;
@ -48,6 +46,7 @@ import jakarta.persistence.MappedSuperclass;
import static org.hibernate.boot.model.internal.TimeZoneStorageHelper.isOffsetTimeClass; import static org.hibernate.boot.model.internal.TimeZoneStorageHelper.isOffsetTimeClass;
import static org.hibernate.boot.model.internal.TimeZoneStorageHelper.useColumnForTimeZoneStorage; import static org.hibernate.boot.model.internal.TimeZoneStorageHelper.useColumnForTimeZoneStorage;
import static org.hibernate.internal.util.StringHelper.qualify;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -191,27 +190,27 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
} }
else { else {
this.currentPropertyColumnOverride = buildColumnOverride( property, getPath(), context ); this.currentPropertyColumnOverride = buildColumnOverride( property, getPath(), context );
if ( this.currentPropertyColumnOverride.size() == 0 ) { if ( this.currentPropertyColumnOverride.isEmpty() ) {
this.currentPropertyColumnOverride = null; this.currentPropertyColumnOverride = null;
} }
this.currentPropertyColumnTransformerOverride = buildColumnTransformerOverride( property ); this.currentPropertyColumnTransformerOverride = buildColumnTransformerOverride( property );
if ( this.currentPropertyColumnTransformerOverride.size() == 0 ) { if ( this.currentPropertyColumnTransformerOverride.isEmpty() ) {
this.currentPropertyColumnTransformerOverride = null; this.currentPropertyColumnTransformerOverride = null;
} }
this.currentPropertyJoinColumnOverride = buildJoinColumnOverride( property, getPath() ); this.currentPropertyJoinColumnOverride = buildJoinColumnOverride( property, getPath() );
if ( this.currentPropertyJoinColumnOverride.size() == 0 ) { if ( this.currentPropertyJoinColumnOverride.isEmpty() ) {
this.currentPropertyJoinColumnOverride = null; this.currentPropertyJoinColumnOverride = null;
} }
this.currentPropertyJoinTableOverride = buildJoinTableOverride( property, getPath() ); this.currentPropertyJoinTableOverride = buildJoinTableOverride( property, getPath() );
if ( this.currentPropertyJoinTableOverride.size() == 0 ) { if ( this.currentPropertyJoinTableOverride.isEmpty() ) {
this.currentPropertyJoinTableOverride = null; this.currentPropertyJoinTableOverride = null;
} }
this.currentPropertyForeignKeyOverride = buildForeignKeyOverride( property, getPath() ); this.currentPropertyForeignKeyOverride = buildForeignKeyOverride( property, getPath() );
if ( this.currentPropertyForeignKeyOverride.size() == 0 ) { if ( this.currentPropertyForeignKeyOverride.isEmpty() ) {
this.currentPropertyForeignKeyOverride = null; this.currentPropertyForeignKeyOverride = null;
} }
} }
@ -226,43 +225,9 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
@Override @Override
public Column[] getOverriddenColumn(String propertyName) { public Column[] getOverriddenColumn(String propertyName) {
Column[] result = getExactOverriddenColumn( propertyName ); Column[] result = getExactOverriddenColumn( propertyName );
if (result == null) { if ( result == null && propertyName.contains(".collection&&element.") ) {
//the commented code can be useful if people use the new prefixes on old mappings and vice versa //support for non map collections where no prefix is needed
// if we enable them: result = getExactOverriddenColumn( propertyName.replace(".collection&&element.", ".") );
// WARNING: this can conflict with user's expectations if:
// - the property uses some restricted values
// - the user has overridden the column
// also change getOverriddenJoinColumn and getOverriddenJoinTable as well
// if ( propertyName.contains( ".key." ) ) {
// //support for legacy @AttributeOverride declarations
// //TODO cache the underlying regexp
// result = getExactOverriddenColumn( propertyName.replace( ".key.", ".index." ) );
// }
// if ( result == null && propertyName.endsWith( ".key" ) ) {
// //support for legacy @AttributeOverride declarations
// //TODO cache the underlying regexp
// result = getExactOverriddenColumn(
// propertyName.substring( 0, propertyName.length() - ".key".length() ) + ".index"
// );
// }
// if ( result == null && propertyName.contains( ".value." ) ) {
// //support for legacy @AttributeOverride declarations
// //TODO cache the underlying regexp
// result = getExactOverriddenColumn( propertyName.replace( ".value.", ".element." ) );
// }
// if ( result == null && propertyName.endsWith( ".value" ) ) {
// //support for legacy @AttributeOverride declarations
// //TODO cache the underlying regexp
// result = getExactOverriddenColumn(
// propertyName.substring( 0, propertyName.length() - ".value".length() ) + ".element"
// );
// }
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
//support for non map collections where no prefix is needed
//TODO cache the underlying regexp
result = getExactOverriddenColumn( propertyName.replace( ".collection&&element.", "." ) );
}
} }
return result; return result;
} }
@ -303,7 +268,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
/** /**
* Get column overriding, property first, then parent, then holder * Get column overriding, property first, then parent, then holder
* replace the placeholder 'collection&&element' with nothing * replace the placeholder 'collection&&element' with nothing
* * <p>
* These rules are here to support both JPA 2 and legacy overriding rules. * These rules are here to support both JPA 2 and legacy overriding rules.
*/ */
@Override @Override
@ -367,7 +332,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
*/ */
@Override @Override
public JoinTable getJoinTable(XProperty property) { public JoinTable getJoinTable(XProperty property) {
final String propertyName = StringHelper.qualify( getPath(), property.getName() ); final String propertyName = qualify( getPath(), property.getName() );
JoinTable result = getOverriddenJoinTable( propertyName ); JoinTable result = getOverriddenJoinTable( propertyName );
if (result == null) { if (result == null) {
result = property.getAnnotation( JoinTable.class ); result = property.getAnnotation( JoinTable.class );
@ -415,8 +380,10 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
Map<String, JoinColumn[]> joinColumnOverride = new HashMap<>(); Map<String, JoinColumn[]> joinColumnOverride = new HashMap<>();
Map<String, JoinTable> joinTableOverride = new HashMap<>(); Map<String, JoinTable> joinTableOverride = new HashMap<>();
Map<String, ForeignKey> foreignKeyOverride = new HashMap<>(); Map<String, ForeignKey> foreignKeyOverride = new HashMap<>();
while ( current != null && !context.getBootstrapContext().getReflectionManager().toXClass( Object.class ).equals( current ) ) { XClass objectClass = context.getBootstrapContext().getReflectionManager().toXClass(Object.class);
if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class ) while ( current != null && !objectClass.equals( current ) ) {
if ( current.isAnnotationPresent( Entity.class )
|| current.isAnnotationPresent( MappedSuperclass.class )
|| current.isAnnotationPresent( Embeddable.class ) ) { || current.isAnnotationPresent( Embeddable.class ) ) {
//FIXME is embeddable override? //FIXME is embeddable override?
Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath(), context ); Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath(), context );
@ -438,18 +405,18 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
current = current.getSuperclass(); current = current.getSuperclass();
} }
holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null; holderColumnOverride = !columnOverride.isEmpty() ? columnOverride : null;
holderColumnTransformerOverride = columnTransformerOverride.size() > 0 ? columnTransformerOverride : null; holderColumnTransformerOverride = !columnTransformerOverride.isEmpty() ? columnTransformerOverride : null;
holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null; holderJoinColumnOverride = !joinColumnOverride.isEmpty() ? joinColumnOverride : null;
holderJoinTableOverride = joinTableOverride.size() > 0 ? joinTableOverride : null; holderJoinTableOverride = !joinTableOverride.isEmpty() ? joinTableOverride : null;
holderForeignKeyOverride = foreignKeyOverride.size() > 0 ? foreignKeyOverride : null; holderForeignKeyOverride = !foreignKeyOverride.isEmpty() ? foreignKeyOverride : null;
} }
private static Map<String, Column[]> buildColumnOverride( private static Map<String, Column[]> buildColumnOverride(
XAnnotatedElement element, XAnnotatedElement element,
String path, String path,
MetadataBuildingContext context) { MetadataBuildingContext context) {
Map<String, Column[]> columnOverride = new HashMap<>(); final Map<String, Column[]> columnOverride = new HashMap<>();
if ( element != null ) { if ( element != null ) {
AttributeOverride singleOverride = element.getAnnotation( AttributeOverride.class ); AttributeOverride singleOverride = element.getAnnotation( AttributeOverride.class );
AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class ); AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class );
@ -465,19 +432,18 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
} }
if ( overrides != null ) { if ( overrides != null ) {
Map<String, List<Column>> columnOverrideList = new HashMap<>(); final Map<String, List<Column>> columnOverrideList = new HashMap<>();
for ( AttributeOverride depAttr : overrides ) { for ( AttributeOverride depAttr : overrides ) {
String qualifiedName = StringHelper.qualify( path, depAttr.name() ); final String qualifiedName = qualify( path, depAttr.name() );
if ( columnOverrideList.containsKey( qualifiedName ) ) { if ( columnOverrideList.containsKey( qualifiedName ) ) {
columnOverrideList.get( qualifiedName ).add( depAttr.column() ); columnOverrideList.get( qualifiedName ).add( depAttr.column() );
} }
else { else {
columnOverrideList.put( List<Column> list = new ArrayList<>();
qualifiedName, list.add( depAttr.column() );
new ArrayList<>( Arrays.asList( depAttr.column() ) ) columnOverrideList.put( qualifiedName, list );
);
} }
} }
@ -619,7 +585,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
if ( overrides != null ) { if ( overrides != null ) {
for ( AssociationOverride depAttr : overrides ) { for ( AssociationOverride depAttr : overrides ) {
columnOverride.put( columnOverride.put(
StringHelper.qualify( path, depAttr.name() ), qualify( path, depAttr.name() ),
depAttr.joinColumns() depAttr.joinColumns()
); );
} }
@ -634,7 +600,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
AssociationOverride[] overrides = buildAssociationOverrides( element, path ); AssociationOverride[] overrides = buildAssociationOverrides( element, path );
if ( overrides != null ) { if ( overrides != null ) {
for ( AssociationOverride depAttr : overrides ) { for ( AssociationOverride depAttr : overrides ) {
foreignKeyOverride.put( StringHelper.qualify( path, depAttr.name() ), depAttr.foreignKey() ); foreignKeyOverride.put( qualify( path, depAttr.name() ), depAttr.foreignKey() );
} }
} }
} }
@ -666,7 +632,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
for ( AssociationOverride depAttr : overrides ) { for ( AssociationOverride depAttr : overrides ) {
if ( depAttr.joinColumns().length == 0 ) { if ( depAttr.joinColumns().length == 0 ) {
tableOverride.put( tableOverride.put(
StringHelper.qualify( path, depAttr.name() ), qualify( path, depAttr.name() ),
depAttr.joinTable() depAttr.joinTable()
); );
} }

View File

@ -14,14 +14,12 @@ import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData; import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.spi.NavigablePath;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Convert; import jakarta.persistence.Convert;
@ -33,6 +31,8 @@ import jakarta.persistence.JoinTable;
import static org.hibernate.boot.model.internal.HCANNHelper.hasAnnotation; import static org.hibernate.boot.model.internal.HCANNHelper.hasAnnotation;
import static org.hibernate.internal.util.StringHelper.isEmpty; import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.qualifyConditionally;
import static org.hibernate.spi.NavigablePath.IDENTIFIER_MAPPER_PROPERTY;
/** /**
* {@link PropertyHolder} for composites (Embeddable/Embedded). * {@link PropertyHolder} for composites (Embeddable/Embedded).
@ -238,7 +238,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
@Override @Override
protected AttributeConversionInfo locateAttributeConversionInfo(String path) { protected AttributeConversionInfo locateAttributeConversionInfo(String path) {
final String embeddedPath = StringHelper.qualifyConditionally( embeddedAttributeName, path ); final String embeddedPath = qualifyConditionally( embeddedAttributeName, path );
final AttributeConversionInfo fromParent = parent.locateAttributeConversionInfo( embeddedPath ); final AttributeConversionInfo fromParent = parent.locateAttributeConversionInfo( embeddedPath );
if ( fromParent != null ) { if ( fromParent != null ) {
return fromParent; return fromParent;
@ -357,7 +357,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
} }
} }
if ( result == null ) { if ( result == null ) {
String userPropertyName = extractUserPropertyName( NavigablePath.IDENTIFIER_MAPPER_PROPERTY, propertyName ); String userPropertyName = extractUserPropertyName( IDENTIFIER_MAPPER_PROPERTY, propertyName );
if ( userPropertyName != null ) { if ( userPropertyName != null ) {
result = super.getOverriddenColumn( userPropertyName ); result = super.getOverriddenColumn( userPropertyName );
} }

View File

@ -17,6 +17,10 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import jakarta.persistence.AssociationOverride;
import jakarta.persistence.AssociationOverrides;
import jakarta.persistence.AttributeOverride;
import jakarta.persistence.AttributeOverrides;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.MappingException; import org.hibernate.MappingException;
@ -85,6 +89,7 @@ import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.spi.FilterDefinition; import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jpa.event.spi.CallbackType; import org.hibernate.jpa.event.spi.CallbackType;
import org.hibernate.mapping.BasicValue; import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.CheckConstraint; import org.hibernate.mapping.CheckConstraint;
@ -109,8 +114,6 @@ import org.hibernate.spi.NavigablePath;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import jakarta.persistence.Access; import jakarta.persistence.Access;
import jakarta.persistence.AttributeOverride;
import jakarta.persistence.AttributeOverrides;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.ConstraintMode; import jakarta.persistence.ConstraintMode;
import jakarta.persistence.DiscriminatorColumn; import jakarta.persistence.DiscriminatorColumn;
@ -120,7 +123,6 @@ import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.IdClass; import jakarta.persistence.IdClass;
import jakarta.persistence.Inheritance; import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable; import jakarta.persistence.JoinTable;
import jakarta.persistence.NamedEntityGraph; import jakarta.persistence.NamedEntityGraph;
@ -132,6 +134,7 @@ import jakarta.persistence.SecondaryTables;
import jakarta.persistence.SharedCacheMode; import jakarta.persistence.SharedCacheMode;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
import static jakarta.persistence.InheritanceType.SINGLE_TABLE;
import static org.hibernate.boot.model.internal.AnnotatedClassType.MAPPED_SUPERCLASS; import static org.hibernate.boot.model.internal.AnnotatedClassType.MAPPED_SUPERCLASS;
import static org.hibernate.boot.model.internal.AnnotatedDiscriminatorColumn.buildDiscriminatorColumn; import static org.hibernate.boot.model.internal.AnnotatedDiscriminatorColumn.buildDiscriminatorColumn;
import static org.hibernate.boot.model.internal.AnnotatedJoinColumn.buildInheritanceJoinColumn; import static org.hibernate.boot.model.internal.AnnotatedJoinColumn.buildInheritanceJoinColumn;
@ -217,9 +220,9 @@ public class EntityBinder {
final InheritanceState inheritanceState = inheritanceStates.get( clazzToProcess ); final InheritanceState inheritanceState = inheritanceStates.get( clazzToProcess );
final PersistentClass superEntity = getSuperEntity( clazzToProcess, inheritanceStates, context, inheritanceState ); final PersistentClass superEntity = getSuperEntity( clazzToProcess, inheritanceStates, context, inheritanceState );
detectedAttributeOverrideProblem( clazzToProcess, superEntity );
final PersistentClass persistentClass = makePersistentClass( inheritanceState, superEntity, context ); final PersistentClass persistentClass = makePersistentClass( inheritanceState, superEntity, context );
checkOverrides( clazzToProcess, superEntity );
final EntityBinder entityBinder = new EntityBinder( clazzToProcess, persistentClass, context ); final EntityBinder entityBinder = new EntityBinder( clazzToProcess, persistentClass, context );
entityBinder.bindEntity(); entityBinder.bindEntity();
entityBinder.handleClassTable( inheritanceState, superEntity ); entityBinder.handleClassTable( inheritanceState, superEntity );
@ -254,6 +257,53 @@ public class EntityBinder {
entityBinder.callTypeBinders( persistentClass ); entityBinder.callTypeBinders( persistentClass );
} }
private static void checkOverrides(XClass clazzToProcess, PersistentClass superEntity) {
if ( superEntity != null ) {
//TODO: correctly handle compound paths (embeddables)
{
AttributeOverrides overrides = clazzToProcess.getAnnotation(AttributeOverrides.class);
if ( overrides != null ) {
for ( AttributeOverride override : overrides.value() ) {
checkOverride( superEntity, override.name(), clazzToProcess, AttributeOverride.class );
}
}
AttributeOverride override = clazzToProcess.getAnnotation(AttributeOverride.class);
if ( override != null ) {
checkOverride( superEntity, override.name(), clazzToProcess, AttributeOverride.class );
}
}
{
AssociationOverrides overrides = clazzToProcess.getAnnotation(AssociationOverrides.class);
if ( overrides != null ) {
for ( AssociationOverride override : overrides.value() ) {
checkOverride( superEntity, override.name(), clazzToProcess, AssociationOverride.class );
}
}
AssociationOverride override = clazzToProcess.getAnnotation(AssociationOverride.class);
if ( override != null ) {
checkOverride( superEntity, override.name(), clazzToProcess, AssociationOverride.class );
}
}
}
}
/**
* The rule is that an entity can override a field declared by a @MappedSuperclass
* if there is no intervening entity which also inherits the field. A wrinkle is
* that a mapped superclass can occur in between the root class and a subclass of
* an entity hierarchy, and then the subclass can override fields declared by the
* mapped superclass even though it cannot override any fields of the root class.
*/
private static void checkOverride(
PersistentClass superEntity, String name, XClass clazzToProcess, Class<?> overrideClass) {
if ( superEntity.hasProperty( StringHelper.root(name) ) ) {
throw new AnnotationException("Property '" + name
+ "' is inherited from entity '" + superEntity.getEntityName()
+ "' and may not be overridden using '@" + overrideClass.getSimpleName()
+ "' in entity subclass '" + clazzToProcess.getName() + "'");
}
}
private static void bindSoftDelete( private static void bindSoftDelete(
XClass xClass, XClass xClass,
RootClass rootClass, RootClass rootClass,
@ -371,14 +421,6 @@ public class EntityBinder {
processComplementaryTableDefinitions( annotatedClass.getAnnotation( jakarta.persistence.Table.class ) ); processComplementaryTableDefinitions( annotatedClass.getAnnotation( jakarta.persistence.Table.class ) );
} }
private static void detectedAttributeOverrideProblem(XClass clazzToProcess, PersistentClass superEntity) {
if ( superEntity != null && (
clazzToProcess.isAnnotationPresent( AttributeOverride.class ) ||
clazzToProcess.isAnnotationPresent( AttributeOverrides.class ) ) ) {
LOG.unsupportedAttributeOverrideWithEntityInheritance( clazzToProcess.getName() );
}
}
private Set<String> handleIdClass( private Set<String> handleIdClass(
PersistentClass persistentClass, PersistentClass persistentClass,
InheritanceState inheritanceState, InheritanceState inheritanceState,
@ -718,11 +760,12 @@ public class EntityBinder {
} }
else { else {
if ( hasTableAnnotation ) { if ( hasTableAnnotation ) {
//TODO: why is this not an error?! throw new AnnotationException( "Entity '" + annotatedClass.getName()
LOG.invalidTableAnnotation( annotatedClass.getName() ); + "' is a subclass in a 'SINGLE_TABLE' hierarchy and may not be annotated '@Table'"
+ " (the root class declares the table mapping for the hierarchy)");
} }
if ( inheritanceState.getType() == InheritanceType.SINGLE_TABLE ) { if ( inheritanceState.getType() == SINGLE_TABLE ) {
// we at least need to properly set up the EntityTableXref // we at least need to properly set up the EntityTableXref
bindTableForDiscriminatedSubclass( collector.getEntityTableXref( superEntity.getEntityName() ) ); bindTableForDiscriminatedSubclass( collector.getEntityTableXref( superEntity.getEntityName() ) );
} }
@ -776,11 +819,8 @@ public class EntityBinder {
bindDiscriminatorValue(); bindDiscriminatorValue();
if ( !isJoinedSubclass ) { if ( !isJoinedSubclass ) {
checkNoJoinColumns( annotatedClass ); checkNoJoinColumns();
if ( annotatedClass.isAnnotationPresent( OnDelete.class ) ) { checkNoOnDelete();
//TODO: why is this not an error!??
LOG.invalidOnDeleteAnnotation( propertyHolder.getEntityName() );
}
} }
} }
@ -833,11 +873,18 @@ public class EntityBinder {
} }
} }
private static void checkNoJoinColumns(XClass clazzToProcess) { private void checkNoJoinColumns() {
if ( clazzToProcess.isAnnotationPresent( PrimaryKeyJoinColumns.class ) if ( annotatedClass.isAnnotationPresent( PrimaryKeyJoinColumns.class )
|| clazzToProcess.isAnnotationPresent( PrimaryKeyJoinColumn.class ) ) { || annotatedClass.isAnnotationPresent( PrimaryKeyJoinColumn.class ) ) {
//TODO: why is this not an error?! throw new AnnotationException( "Entity class '" + annotatedClass.getName()
LOG.invalidPrimaryKeyJoinColumnAnnotation( clazzToProcess.getName() ); + "' may not specify a '@PrimaryKeyJoinColumn'" );
}
}
private void checkNoOnDelete() {
if ( annotatedClass.isAnnotationPresent( OnDelete.class ) ) {
throw new AnnotationException( "Entity class '" + annotatedClass.getName()
+ "' may not be annotated '@OnDelete'" );
} }
} }
@ -1017,7 +1064,7 @@ public class EntityBinder {
} }
else { else {
boolean subclassAndSingleTableStrategy = boolean subclassAndSingleTableStrategy =
inheritanceState.getType() == InheritanceType.SINGLE_TABLE inheritanceState.getType() == SINGLE_TABLE
&& inheritanceState.hasParents(); && inheritanceState.hasParents();
if ( !hasIdAnnotation && property.isAnnotationPresent( GeneratedValue.class ) ) { if ( !hasIdAnnotation && property.isAnnotationPresent( GeneratedValue.class ) ) {
throw new AnnotationException( throw new AnnotationException(
@ -1274,7 +1321,9 @@ public class EntityBinder {
bindRootEntity(); bindRootEntity();
} }
else if ( !isMutable() ) { else if ( !isMutable() ) {
LOG.immutableAnnotationOnNonRoot( annotatedClass.getName() ); throw new AnnotationException("Entity class '" + annotatedClass.getName()
+ "' is annotated '@Immutable' but it is a subclass in an entity inheritance hierarchy"
+ " (only root classes may declare mutability)");
} }
ensureNoMutabilityPlan(); ensureNoMutabilityPlan();

View File

@ -254,15 +254,15 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
@Override @Override
public Package packageForNameOrNull(String packageName) { public Package packageForNameOrNull(String packageName) {
try { try {
Class<?> aClass = Class.forName( packageName + ".package-info", true, getAggregatedClassLoader() ); return Class.forName( packageName + ".package-info", true, getAggregatedClassLoader() )
return aClass == null ? null : aClass.getPackage(); .getPackage();
} }
catch (ClassNotFoundException e) { catch (ClassNotFoundException e) {
log.packageNotFound( packageName ); log.packageNotFound( packageName );
return null; return null;
} }
catch (LinkageError e) { catch (LinkageError e) {
log.warn( "LinkageError while attempting to load Package named " + packageName, e ); log.linkageError( packageName, e );
return null; return null;
} }
} }

View File

@ -388,10 +388,6 @@ public interface CoreMessageLogger extends BasicLogger {
String name, String name,
String propertyName); String propertyName);
@LogMessage(level = WARN)
@Message(value = "@Immutable used on a non root entity: ignored for %s", id = 124)
void immutableAnnotationOnNonRoot(String className);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Mapping metadata cache was not completely processed", id = 125) @Message(value = "Mapping metadata cache was not completely processed", id = 125)
void incompleteMappingMetadataCacheProcessing(); void incompleteMappingMetadataCacheProcessing();
@ -412,11 +408,6 @@ public interface CoreMessageLogger extends BasicLogger {
@Message(value = "Array element type error\n%s", id = 132) @Message(value = "Array element type error\n%s", id = 132)
void invalidArrayElementType(String message); void invalidArrayElementType(String message);
@LogMessage(level = WARN)
@Message(value = "Discriminator column has to be defined in the root entity, it will be ignored in subclass: %s",
id = 133)
void invalidDiscriminatorAnnotation(String className);
@LogMessage(level = ERROR) @LogMessage(level = ERROR)
@Message(value = "Application attempted to edit read only item: %s", id = 134) @Message(value = "Application attempted to edit read only item: %s", id = 134)
void invalidEditOfReadOnlyItem(Object key); void invalidEditOfReadOnlyItem(Object key);
@ -427,23 +418,11 @@ public interface CoreMessageLogger extends BasicLogger {
String name, String name,
@Cause JndiNameException e); @Cause JndiNameException e);
@LogMessage(level = WARN)
@Message(value = "Inapropriate use of @OnDelete on entity, annotation ignored: %s", id = 136)
void invalidOnDeleteAnnotation(String entityName);
@LogMessage(level = WARN)
@Message(value = "Root entity should not hold a PrimaryKeyJoinColum(s), will be ignored: %s", id = 137)
void invalidPrimaryKeyJoinColumnAnnotation(String className);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Mixing inheritance strategy in a entity hierarchy is not allowed, ignoring sub strategy in: %s", @Message(value = "Mixing inheritance strategy in a entity hierarchy is not allowed, ignoring sub strategy in: %s",
id = 138) id = 138)
void invalidSubStrategy(String className); void invalidSubStrategy(String className);
@LogMessage(level = WARN)
@Message(value = "Illegal use of @Table in a subclass of a SINGLE_TABLE hierarchy: %s", id = 139)
void invalidTableAnnotation(String className);
@LogMessage(level = INFO) @LogMessage(level = INFO)
@Message(value = "JACC contextID: %s", id = 140) @Message(value = "JACC contextID: %s", id = 140)
void jaccContextId(String contextId); void jaccContextId(String contextId);
@ -555,21 +534,17 @@ public interface CoreMessageLogger extends BasicLogger {
@Message(value = "Optimistic lock failures: %s", id = 187) @Message(value = "Optimistic lock failures: %s", id = 187)
void optimisticLockFailures(long optimisticFailureCount); void optimisticLockFailures(long optimisticFailureCount);
@LogMessage(level = WARN)
@Message(value = "@OrderBy not allowed for an indexed collection, annotation ignored.", id = 189)
void orderByAnnotationIndexedCollection();
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Overriding %s is dangerous, this might break the EJB3 specification implementation", id = 193) @Message(value = "Overriding %s is dangerous, this might break the EJB3 specification implementation", id = 193)
void overridingTransactionStrategyDangerous(String transactionStrategy); void overridingTransactionStrategyDangerous(String transactionStrategy);
@LogMessage(level = DEBUG) @LogMessage(level = DEBUG)
@Message(value = "Package not found or wo package-info.java: %s", id = 194) @Message(value = "Package not found or no package-info.java: %s", id = 194)
void packageNotFound(String packageName); void packageNotFound(String packageName);
// @LogMessage(level = WARN) @LogMessage(level = WARN)
// @Message(value = "Parameter position [%s] occurred as both JPA and Hibernate positional parameter", id = 195) @Message(value = "LinkageError while attempting to load package: %s", id = 195)
// void parameterPositionOccurredAsBothJpaAndHibernatePositionalParameter(Integer position); void linkageError(String packageName, @Cause LinkageError e);
@LogMessage(level = ERROR) @LogMessage(level = ERROR)
@Message(value = "Error parsing XML: (%s) %s", id = 196) @Message(value = "Error parsing XML: (%s) %s", id = 196)
@ -753,10 +728,6 @@ public interface CoreMessageLogger extends BasicLogger {
@Message(value = "Sessions opened: %s", id = 242) @Message(value = "Sessions opened: %s", id = 242)
void sessionsOpened(long sessionOpenCount); void sessionsOpened(long sessionOpenCount);
@LogMessage(level = WARN)
@Message(value = "@Sort not allowed for an indexed collection, annotation ignored.", id = 244)
void sortAnnotationIndexedCollection();
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Manipulation query [%s] resulted in [%s] split queries", id = 245) @Message(value = "Manipulation query [%s] resulted in [%s] split queries", id = 245)
void splitQueries( void splitQueries(
@ -1712,10 +1683,6 @@ public interface CoreMessageLogger extends BasicLogger {
) )
void unknownJavaTypeNoEqualsHashCode(Class javaType); void unknownJavaTypeNoEqualsHashCode(Class javaType);
@LogMessage(level = WARN)
@Message(value = "@org.hibernate.annotations.Cache used on a non-root entity: ignored for [%s]. Please see the Hibernate documentation for proper usage.", id = 482)
void cacheOrCacheableAnnotationOnNonRoot(String className);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message( @Message(
id = 483, id = 483,
@ -1794,20 +1761,6 @@ public interface CoreMessageLogger extends BasicLogger {
@Message(value = "Detaching an uninitialized collection with queued operations from a session due to rollback: %s", id = 498) @Message(value = "Detaching an uninitialized collection with queued operations from a session due to rollback: %s", id = 498)
void queuedOperationWhenDetachFromSessionOnRollback(String collectionInfoString); void queuedOperationWhenDetachFromSessionOnRollback(String collectionInfoString);
@LogMessage(level = WARN)
@Message(value = "Using @AttributeOverride or @AttributeOverrides in conjunction with entity inheritance is not supported: %s. The overriding definitions are ignored.", id = 499)
void unsupportedAttributeOverrideWithEntityInheritance(String entityName);
/* 6.0 message loggers
@LogMessage(level = WARN)
@Message(value = "The bytecode provider class [%s] could not be loaded", id = 500)
void bytecodeProviderClassNotFound(String className);
@LogMessage(level = WARN)
@Message(value = "The bytecode provider class [%s] does not implement BytecodeProvider", id = 501)
void bytecodeProviderInvalidClass(String className);
*/
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "The [%s] property of the [%s] entity was modified, but it won't be updated because the property is immutable.", id = 502) @Message(value = "The [%s] property of the [%s] entity was modified, but it won't be updated because the property is immutable.", id = 502)
void ignoreImmutablePropertyModification(String propertyName, String entityName); void ignoreImmutablePropertyModification(String propertyName, String entityName);

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/ */
package org.hibernate.mapping; package org.hibernate.mapping;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.hibernate.MappingException; import org.hibernate.MappingException;

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.mapping; package org.hibernate.mapping;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.hibernate.MappingException; import org.hibernate.MappingException;

View File

@ -8,7 +8,6 @@ package org.hibernate.mapping;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/ */
package org.hibernate.mapping; package org.hibernate.mapping;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;

View File

@ -11,7 +11,6 @@ import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.SecondaryTable; import jakarta.persistence.SecondaryTable;
import jakarta.persistence.Table;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -19,7 +18,6 @@ import jakarta.persistence.Table;
@Entity @Entity
@DiscriminatorValue("D") @DiscriminatorValue("D")
@SecondaryTable(name = "DocumentMixed") @SecondaryTable(name = "DocumentMixed")
@Table(name="Document_Wrong") //illegal use, a warn is raised
public class Document extends File { public class Document extends File {
private int size; private int size;

View File

@ -6,29 +6,25 @@
*/ */
package org.hibernate.orm.test.annotations.override.inheritance; package org.hibernate.orm.test.annotations.override.inheritance;
import org.hibernate.boot.model.internal.EntityBinder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.logger.LoggerInspectionRule;
import org.hibernate.testing.logger.Triggerable;
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.jboss.logging.Logger;
import jakarta.persistence.AttributeOverride; import jakarta.persistence.AttributeOverride;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Inheritance; import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType; import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
import org.hibernate.AnnotationException;
import org.hibernate.boot.model.internal.EntityBinder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.logger.LoggerInspectionRule;
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
import org.jboss.logging.Logger;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail;
/** /**
@ -50,19 +46,15 @@ public class EntityInheritanceAttributeOverrideTest extends EntityManagerFactory
}; };
} }
@Override
public EntityManagerFactory produceEntityManagerFactory() {
Triggerable warningLogged = logInspection.watchForLogMessages( "HHH000499:" );
EntityManagerFactory entityManagerFactory = super.produceEntityManagerFactory();
assertTrue( warningLogged.wasTriggered(), "A warning should have been logged for this unsupported configuration");
return entityManagerFactory;
}
@Test @Test
public void test() { public void test() {
produceEntityManagerFactory().close(); try {
produceEntityManagerFactory().close();
fail();
}
catch (AnnotationException ae) {
//expected
}
} }
@Entity(name = "AbstractEntity") @Entity(name = "AbstractEntity")

View File

@ -48,10 +48,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
) )
@ServiceRegistry @ServiceRegistry
@SessionFactory @SessionFactory
@Disabled("@AttributeOverrides is not supported for inheritance.")
public class TablePerClassOverrideTests { public class TablePerClassOverrideTests {
@Test @Test
@Disabled("@AttributeOverrides is not supported for inheritance. See CoreMessageLogger#unsupportedAttributeOverrideWithEntityInheritance")
public void testSchema(SessionFactoryScope scope) { public void testSchema(SessionFactoryScope scope) {
MetadataImplementor metadata = scope.getMetadataImplementor(); MetadataImplementor metadata = scope.getMetadataImplementor();
assertTrue( SchemaUtil.isColumnPresent( "CUSTOMER", "STREET", metadata ) ); assertTrue( SchemaUtil.isColumnPresent( "CUSTOMER", "STREET", metadata ) );

View File

@ -6,26 +6,17 @@
*/ */
package org.hibernate.orm.test.cfg; package org.hibernate.orm.test.cfg;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.model.internal.EntityBinder;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.logger.LoggerInspectionRule;
import org.hibernate.testing.logger.Triggerable;
import org.hibernate.testing.util.ServiceRegistryUtil;
import org.junit.Rule;
import org.junit.Test;
import org.jboss.logging.Logger;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.PrimaryKeyJoinColumn; import jakarta.persistence.PrimaryKeyJoinColumn;
import org.hibernate.AnnotationException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.util.ServiceRegistryUtil;
import org.junit.Test;
import static org.junit.Assert.assertTrue; import static junit.framework.TestCase.fail;
/** /**
* @author Dominique Toupin * @author Dominique Toupin
@ -33,27 +24,18 @@ import static org.junit.Assert.assertTrue;
@TestForIssue(jiraKey = "HHH-10456") @TestForIssue(jiraKey = "HHH-10456")
public class AnnotationBinderTest { public class AnnotationBinderTest {
@Rule
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
Logger.getMessageLogger( CoreMessageLogger.class, EntityBinder.class.getName() ) );
@Test @Test
public void testInvalidPrimaryKeyJoinColumnAnnotationMessageContainsClassName() throws Exception { public void testInvalidPrimaryKeyJoinColumn() {
Triggerable triggerable = logInspection.watchForLogMessages( "HHH000137" );
try (StandardServiceRegistry serviceRegistry = ServiceRegistryUtil.serviceRegistry()) { try (StandardServiceRegistry serviceRegistry = ServiceRegistryUtil.serviceRegistry()) {
try {
Metadata metadata = new MetadataSources( serviceRegistry ) new MetadataSources( serviceRegistry )
.addAnnotatedClass( InvalidPrimaryKeyJoinColumnAnnotationEntity.class ) .addAnnotatedClass( InvalidPrimaryKeyJoinColumnAnnotationEntity.class )
.buildMetadata(); .buildMetadata();
fail();
assertTrue( "Expected warning HHH00137 but it wasn't triggered", triggerable.wasTriggered() ); }
assertTrue( catch (AnnotationException ae) {
"Expected invalid class name in warning HHH00137 message but it does not appear to be present; got " + triggerable.triggerMessage(), // expected!
triggerable.triggerMessage() }
.matches( ".*\\b\\Q" + InvalidPrimaryKeyJoinColumnAnnotationEntity.class.getName() + "\\E\\b.*" )
);
} }
} }

View File

@ -8,14 +8,12 @@ package org.hibernate.orm.test.filter.subclass.singletable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef; import org.hibernate.annotations.ParamDef;
@Entity @Entity
@Table(name="ZOOLOGY_HUMAN")
@FilterDef(name="iqRange", parameters= @FilterDef(name="iqRange", parameters=
{ {
@ParamDef(name="min", type=Integer.class), @ParamDef(name="min", type=Integer.class),

View File

@ -16,10 +16,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Entity @Entity
@Table(name="ZOOLOGY_MAMMAL")
@FilterDef(name="pregnantOnly") @FilterDef(name="pregnantOnly")
@Filter(name="pregnantOnly", condition="IS_PREGNANT = 1") @Filter(name="pregnantOnly", condition="IS_PREGNANT = 1")
public class Mammal extends Animal{ public class Mammal extends Animal {
@Column(name="IS_PREGNANT") @Column(name="IS_PREGNANT")
@Convert( converter = NumericBooleanConverter.class ) @Convert( converter = NumericBooleanConverter.class )

View File

@ -108,7 +108,6 @@ public class SingleTableWithEmbeddableTest {
} }
@Entity(name = "Employee") @Entity(name = "Employee")
@Table(name = "employees")
public static class Employee extends Person { public static class Employee extends Person {
private Integer employeeNumber; private Integer employeeNumber;

View File

@ -112,7 +112,6 @@ public class InsertOrderingWithSecondaryTable extends BaseInsertOrderingTest {
@Entity(name = "ShapePolygonEntity") @Entity(name = "ShapePolygonEntity")
@DiscriminatorValue("POLYGON") @DiscriminatorValue("POLYGON")
@Table(name = "POLYGON")
public static class ShapePolygonEntity extends ShapeEntity { public static class ShapePolygonEntity extends ShapeEntity {
} }
@ -120,7 +119,6 @@ public class InsertOrderingWithSecondaryTable extends BaseInsertOrderingTest {
@Entity(name = "ShapeCircleEntity") @Entity(name = "ShapeCircleEntity")
@DiscriminatorValue("CIRCLE") @DiscriminatorValue("CIRCLE")
@SecondaryTable(name = "SHAPE_CIRCLE", pkJoinColumns = @PrimaryKeyJoinColumn(name = "SHAPE_ID")) @SecondaryTable(name = "SHAPE_CIRCLE", pkJoinColumns = @PrimaryKeyJoinColumn(name = "SHAPE_ID"))
@Table(name = "CIRCLE")
public static class ShapeCircleEntity extends ShapeEntity { public static class ShapeCircleEntity extends ShapeEntity {
@Column(table = "SHAPE_CIRCLE") @Column(table = "SHAPE_CIRCLE")
private String centre; private String centre;

View File

@ -13,6 +13,5 @@ import jakarta.persistence.Table;
* Elephant * Elephant
*/ */
@Entity @Entity
@Table(name = "ELEPHANT")
public class Elephant extends Animal { public class Elephant extends Animal {
} }

View File

@ -13,6 +13,5 @@ import jakarta.persistence.Table;
* Human * Human
*/ */
@Entity @Entity
@Table(name = "HUMAN")
public class Human extends Animal { public class Human extends Animal {
} }

View File

@ -170,7 +170,6 @@ public class EntitySuperclassComponentWithCollectionTest {
} }
@Entity(name = "Manager") @Entity(name = "Manager")
@Table(name = "MANAGER")
public static class Manager extends Employee { public static class Manager extends Employee {
} }
@ -275,7 +274,6 @@ public class EntitySuperclassComponentWithCollectionTest {
} }
@Entity(name = "Leader") @Entity(name = "Leader")
@Table(name = "LEADER")
public static class Leader extends Person { public static class Leader extends Person {
} }

View File

@ -348,7 +348,6 @@ public class AnnotationMappingJoinClassTest extends BaseCoreFunctionalTestCase {
} }
@Entity(name = "EwtAssessmentExtension") @Entity(name = "EwtAssessmentExtension")
@Table(name = "claimsettlement_ext_i3_ewt")
public static class EwtAssessmentExtension extends SettlementExtension { public static class EwtAssessmentExtension extends SettlementExtension {
public static final long serialVersionUID = 1L; public static final long serialVersionUID = 1L;
@ -630,7 +629,6 @@ public class AnnotationMappingJoinClassTest extends BaseCoreFunctionalTestCase {
} }
@Entity(name = "GapAssessmentExtension") @Entity(name = "GapAssessmentExtension")
@Table(name = "claim_settlement_ext_gap")
public static class GapAssessmentExtension extends SettlementExtension { public static class GapAssessmentExtension extends SettlementExtension {
private Double insuredsObligation = 0.0; private Double insuredsObligation = 0.0;

View File

@ -34,7 +34,6 @@ public class JoinOrderTest {
} }
@Entity(name = "TaskLocation") @Entity(name = "TaskLocation")
@Table(name = "vin_task_location")
public class TaskLocation extends Location { public class TaskLocation extends Location {
@Id @GeneratedValue Long id; @Id @GeneratedValue Long id;

View File

@ -128,7 +128,6 @@ public class DiscriminatedTreatSmokeTesting {
} }
@Entity( name = "ExtendedVolume" ) @Entity( name = "ExtendedVolume" )
@Table( name = "treated_extended_volume" )
@DiscriminatorValue( "E" ) @DiscriminatorValue( "E" )
public static class ExtendedVolume extends Volume { public static class ExtendedVolume extends Volume {
private String strategy; private String strategy;

View File

@ -127,7 +127,6 @@ public class DiscriminatedTreatSqmSmokeTesting {
} }
@Entity( name = "ExtendedVolume" ) @Entity( name = "ExtendedVolume" )
@Table( name = "treated_extended_volume" )
@DiscriminatorValue( "E" ) @DiscriminatorValue( "E" )
public static class ExtendedVolume extends Volume { public static class ExtendedVolume extends Volume {
private String strategy; private String strategy;

View File

@ -14,7 +14,6 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.PrimaryKeyJoinColumn;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.boot.MetadataSources; import org.hibernate.boot.MetadataSources;
@ -294,7 +293,6 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase {
} }
@Entity @Entity
@PrimaryKeyJoinColumn
@Table(name = "UnqualifiedMissingEntity") @Table(name = "UnqualifiedMissingEntity")
public static class UnqualifiedMissingEntity { public static class UnqualifiedMissingEntity {
@ -311,7 +309,6 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase {
} }
@Entity @Entity
@PrimaryKeyJoinColumn
@Table(name = "MissingEntity", catalog = "SomeCatalog", schema = "SomeSchema") @Table(name = "MissingEntity", catalog = "SomeCatalog", schema = "SomeSchema")
public static class MissingEntity { public static class MissingEntity {
@ -328,7 +325,6 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase {
} }
@Entity @Entity
@PrimaryKeyJoinColumn
@Table(name = "ColumnEntity", schema = "SomeSchema") @Table(name = "ColumnEntity", schema = "SomeSchema")
public static class NoNameColumn { public static class NoNameColumn {
@ -345,7 +341,6 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase {
} }
@Entity @Entity
@PrimaryKeyJoinColumn
@Table(name = "ColumnEntity", schema = "SomeSchema") @Table(name = "ColumnEntity", schema = "SomeSchema")
public static class NameColumn { public static class NameColumn {
@ -372,7 +367,6 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase {
} }
@Entity @Entity
@PrimaryKeyJoinColumn
@Table(name = "ColumnEntity", schema = "SomeSchema") @Table(name = "ColumnEntity", schema = "SomeSchema")
public static class IntegerNameColumn { public static class IntegerNameColumn {

View File

@ -12,14 +12,12 @@ import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.util.List; import java.util.List;
/** /**
* @author Luke Chen * @author Luke Chen
*/ */
@Entity @Entity
@Table(name = "child_user")
public class ChildUser extends User { public class ChildUser extends User {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user", cascade = CascadeType.REMOVE) @OneToMany(fetch = FetchType.LAZY, mappedBy = "user", cascade = CascadeType.REMOVE)

View File

@ -8,7 +8,6 @@ package org.hibernate.orm.test.envers.entities.onetomany.detached;
import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
@ -19,7 +18,6 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org) * @author Adam Warski (adam at warski dot org)
*/ */
@Entity @Entity
@Table(name = "ListJoinColBiInhRefEdChild")
@DiscriminatorValue("2") @DiscriminatorValue("2")
@Audited @Audited
public class ListJoinColumnBidirectionalInheritanceRefEdChildEntity public class ListJoinColumnBidirectionalInheritanceRefEdChildEntity

View File

@ -9,8 +9,6 @@ package org.hibernate.testing.orm.junit;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -29,12 +27,9 @@ import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableM
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy; import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy; import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy;
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
import org.hibernate.testing.util.ServiceRegistryUtil; import org.hibernate.testing.util.ServiceRegistryUtil;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.jboss.logging.Logger;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.SharedCacheMode; import jakarta.persistence.SharedCacheMode;
@ -49,7 +44,6 @@ import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@FunctionalEntityManagerFactoryTesting @FunctionalEntityManagerFactoryTesting
public class EntityManagerFactoryBasedFunctionalTest public class EntityManagerFactoryBasedFunctionalTest
implements EntityManagerFactoryProducer, EntityManagerFactoryScopeContainer { implements EntityManagerFactoryProducer, EntityManagerFactoryScopeContainer {
private static final Logger log = Logger.getLogger( EntityManagerFactoryBasedFunctionalTest.class );
private EntityManagerFactoryScope entityManagerFactoryScope; private EntityManagerFactoryScope entityManagerFactoryScope;