mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 12:14:47 +00:00
Rebase main -> 7.0
fixups
This commit is contained in:
parent
593295e686
commit
31f495c9d5
@ -1333,25 +1333,25 @@ public AnnotatedClassType addClassType(ClassDetails clazz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static AnnotatedClassType getAnnotatedClassType(ClassDetails clazz) {
|
private static AnnotatedClassType getAnnotatedClassType(ClassDetails clazz) {
|
||||||
if ( clazz.isAnnotationPresent( Entity.class ) ) {
|
if ( clazz.hasDirectAnnotationUsage( Entity.class ) ) {
|
||||||
if ( clazz.isAnnotationPresent( Embeddable.class ) ) {
|
if ( clazz.hasDirectAnnotationUsage( Embeddable.class ) ) {
|
||||||
throw new AnnotationException( "Invalid class annotated both '@Entity' and '@Embeddable': '" + clazz.getName() + "'" );
|
throw new AnnotationException( "Invalid class annotated both '@Entity' and '@Embeddable': '" + clazz.getName() + "'" );
|
||||||
}
|
}
|
||||||
else if ( clazz.isAnnotationPresent( jakarta.persistence.MappedSuperclass.class ) ) {
|
else if ( clazz.hasDirectAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
|
||||||
throw new AnnotationException( "Invalid class annotated both '@Entity' and '@MappedSuperclass': '" + clazz.getName() + "'" );
|
throw new AnnotationException( "Invalid class annotated both '@Entity' and '@MappedSuperclass': '" + clazz.getName() + "'" );
|
||||||
}
|
}
|
||||||
return AnnotatedClassType.ENTITY;
|
return AnnotatedClassType.ENTITY;
|
||||||
}
|
}
|
||||||
else if ( clazz.isAnnotationPresent( Embeddable.class ) ) {
|
else if ( clazz.hasDirectAnnotationUsage( Embeddable.class ) ) {
|
||||||
if ( clazz.isAnnotationPresent( jakarta.persistence.MappedSuperclass.class ) ) {
|
if ( clazz.hasDirectAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
|
||||||
throw new AnnotationException( "Invalid class annotated both '@Embeddable' and '@MappedSuperclass': '" + clazz.getName() + "'" );
|
throw new AnnotationException( "Invalid class annotated both '@Embeddable' and '@MappedSuperclass': '" + clazz.getName() + "'" );
|
||||||
}
|
}
|
||||||
return AnnotatedClassType.EMBEDDABLE;
|
return AnnotatedClassType.EMBEDDABLE;
|
||||||
}
|
}
|
||||||
else if ( clazz.isAnnotationPresent( jakarta.persistence.MappedSuperclass.class ) ) {
|
else if ( clazz.hasDirectAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
|
||||||
return AnnotatedClassType.MAPPED_SUPERCLASS;
|
return AnnotatedClassType.MAPPED_SUPERCLASS;
|
||||||
}
|
}
|
||||||
else if ( clazz.isAnnotationPresent( Imported.class ) ) {
|
else if ( clazz.hasDirectAnnotationUsage( Imported.class ) ) {
|
||||||
return AnnotatedClassType.IMPORTED;
|
return AnnotatedClassType.IMPORTED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1359,13 +1359,6 @@ else if ( clazz.isAnnotationPresent( Imported.class ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AnnotatedClassType addClassType(ClassDetails classDetails) {
|
|
||||||
final AnnotatedClassType type = getAnnotatedClassType2( classDetails );
|
|
||||||
annotatedClassTypeMap.put( classDetails.getName(), type );
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AnnotatedClassType getAnnotatedClassType2(ClassDetails classDetails) {
|
private static AnnotatedClassType getAnnotatedClassType2(ClassDetails classDetails) {
|
||||||
if ( classDetails.hasDirectAnnotationUsage( Entity.class ) ) {
|
if ( classDetails.hasDirectAnnotationUsage( Entity.class ) ) {
|
||||||
return AnnotatedClassType.ENTITY;
|
return AnnotatedClassType.ENTITY;
|
||||||
@ -1384,18 +1377,6 @@ else if ( classDetails.hasDirectAnnotationUsage( Imported.class ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AnnotatedClassType getClassType(ClassDetails classDetails) {
|
|
||||||
final AnnotatedClassType type = annotatedClassTypeMap.get( classDetails.getName() );
|
|
||||||
if ( type == null ) {
|
|
||||||
return addClassType( classDetails );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMappedSuperclass(Class<?> type, MappedSuperclass mappedSuperclass) {
|
public void addMappedSuperclass(Class<?> type, MappedSuperclass mappedSuperclass) {
|
||||||
if ( mappedSuperClasses == null ) {
|
if ( mappedSuperClasses == null ) {
|
||||||
|
@ -418,13 +418,15 @@ static Component fillEmbeddable(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Map<String, String> subclassToSuperclass = component.isPolymorphic() ? new HashMap<>() : null;
|
||||||
final TypeDetails annotatedType = inferredData.getPropertyType();
|
final TypeDetails annotatedType = inferredData.getPropertyType();
|
||||||
final List<PropertyData> classElements = collectClassElements(
|
final List<PropertyData> classElements = collectClassElements(
|
||||||
propertyAccessor,
|
propertyAccessor,
|
||||||
context,
|
context,
|
||||||
returnedClassOrElement,
|
returnedClassOrElement,
|
||||||
annotatedType,
|
annotatedType,
|
||||||
isIdClass
|
isIdClass,
|
||||||
|
subclassToSuperclass
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( component.isPolymorphic() ) {
|
if ( component.isPolymorphic() ) {
|
||||||
@ -637,9 +639,9 @@ private static List<PropertyData> collectClassElements(
|
|||||||
new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor );
|
new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor );
|
||||||
addElementsOfClass( classElements, container, context);
|
addElementsOfClass( classElements, container, context);
|
||||||
//add elements of the embeddable's mapped superclasses
|
//add elements of the embeddable's mapped superclasses
|
||||||
ClassDetails subClass = returnedClassOrElement;
|
ClassDetails subclass = returnedClassOrElement;
|
||||||
XClass superClass;
|
ClassDetails superClass;
|
||||||
while ( isValidSuperclass( superClass = subclass.getSuperclass(), isIdClass ) ) {
|
while ( isValidSuperclass( superClass = subclass.getSuperClass(), isIdClass ) ) {
|
||||||
//FIXME: proper support of type variables incl var resolved at upper levels
|
//FIXME: proper support of type variables incl var resolved at upper levels
|
||||||
final PropertyContainer superContainer = new PropertyContainer(
|
final PropertyContainer superContainer = new PropertyContainer(
|
||||||
superClass,
|
superClass,
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
public class FilterDefAnnotation implements FilterDef {
|
public class FilterDefAnnotation implements FilterDef {
|
||||||
private String name;
|
private String name;
|
||||||
private String defaultCondition;
|
private String defaultCondition;
|
||||||
private org.hibernate.annotations.ParamDef[] parameters;
|
|
||||||
private boolean autoEnabled;
|
private boolean autoEnabled;
|
||||||
|
private boolean applyToLoadByKey;
|
||||||
|
private org.hibernate.annotations.ParamDef[] parameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in creating dynamic annotation instances (e.g. from XML)
|
* Used in creating dynamic annotation instances (e.g. from XML)
|
||||||
@ -40,8 +41,9 @@ public FilterDefAnnotation(SourceModelBuildingContext modelContext) {
|
|||||||
public FilterDefAnnotation(FilterDef annotation, SourceModelBuildingContext modelContext) {
|
public FilterDefAnnotation(FilterDef annotation, SourceModelBuildingContext modelContext) {
|
||||||
this.name = annotation.name();
|
this.name = annotation.name();
|
||||||
this.defaultCondition = annotation.defaultCondition();
|
this.defaultCondition = annotation.defaultCondition();
|
||||||
this.parameters = extractJdkValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
|
||||||
this.autoEnabled = annotation.autoEnabled();
|
this.autoEnabled = annotation.autoEnabled();
|
||||||
|
this.applyToLoadByKey = annotation.applyToLoadByKey();;
|
||||||
|
this.parameters = extractJdkValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,13 +57,19 @@ public FilterDefAnnotation(AnnotationInstance annotation, SourceModelBuildingCon
|
|||||||
"defaultCondition",
|
"defaultCondition",
|
||||||
modelContext
|
modelContext
|
||||||
);
|
);
|
||||||
this.parameters = extractJandexValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
|
||||||
this.autoEnabled = extractJandexValue(
|
this.autoEnabled = extractJandexValue(
|
||||||
annotation,
|
annotation,
|
||||||
HibernateAnnotations.FILTER_DEF,
|
HibernateAnnotations.FILTER_DEF,
|
||||||
"autoEnabled",
|
"autoEnabled",
|
||||||
modelContext
|
modelContext
|
||||||
);
|
);
|
||||||
|
this.applyToLoadByKey = extractJandexValue(
|
||||||
|
annotation,
|
||||||
|
HibernateAnnotations.FILTER_DEF,
|
||||||
|
"applyToLoadByKey",
|
||||||
|
modelContext
|
||||||
|
);
|
||||||
|
this.parameters = extractJandexValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,16 +97,6 @@ public void defaultCondition(String value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.hibernate.annotations.ParamDef[] parameters() {
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void parameters(org.hibernate.annotations.ParamDef[] value) {
|
|
||||||
this.parameters = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean autoEnabled() {
|
public boolean autoEnabled() {
|
||||||
return autoEnabled;
|
return autoEnabled;
|
||||||
@ -109,4 +107,23 @@ public void autoEnabled(boolean value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applyToLoadByKey() {
|
||||||
|
return applyToLoadByKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyToLoadByKey(boolean value) {
|
||||||
|
this.applyToLoadByKey = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.hibernate.annotations.ParamDef[] parameters() {
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void parameters(org.hibernate.annotations.ParamDef[] value) {
|
||||||
|
this.parameters = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -545,6 +545,7 @@ public void collectFilterDefinitions(AnnotationTarget annotationTarget) {
|
|||||||
usage.name(),
|
usage.name(),
|
||||||
usage.defaultCondition(),
|
usage.defaultCondition(),
|
||||||
usage.autoEnabled(),
|
usage.autoEnabled(),
|
||||||
|
usage.applyToLoadByKey(),
|
||||||
paramJdbcMappings,
|
paramJdbcMappings,
|
||||||
parameterResolvers
|
parameterResolvers
|
||||||
);
|
);
|
||||||
@ -597,6 +598,7 @@ public void collectFilterDefinitions(List<JaxbFilterDefImpl> filterDefinitions)
|
|||||||
filterDefinition.getName(),
|
filterDefinition.getName(),
|
||||||
filterDefinition.getDefaultCondition(),
|
filterDefinition.getDefaultCondition(),
|
||||||
filterDefinition.isAutoEnabled(),
|
filterDefinition.isAutoEnabled(),
|
||||||
|
filterDefinition.isApplyToLoadByKey(),
|
||||||
paramJdbcMappings,
|
paramJdbcMappings,
|
||||||
parameterResolvers
|
parameterResolvers
|
||||||
);
|
);
|
||||||
@ -607,6 +609,7 @@ public void collectFilterDefinition(
|
|||||||
String name,
|
String name,
|
||||||
String defaultCondition,
|
String defaultCondition,
|
||||||
boolean autoEnabled,
|
boolean autoEnabled,
|
||||||
|
boolean applyToLoadByKey,
|
||||||
Map<String, ClassDetails> parameterTypes,
|
Map<String, ClassDetails> parameterTypes,
|
||||||
Map<String, ClassDetails> parameterResolvers) {
|
Map<String, ClassDetails> parameterResolvers) {
|
||||||
if ( filterDefRegistrations == null ) {
|
if ( filterDefRegistrations == null ) {
|
||||||
@ -615,7 +618,7 @@ public void collectFilterDefinition(
|
|||||||
|
|
||||||
final FilterDefRegistration previousEntry = filterDefRegistrations.put(
|
final FilterDefRegistration previousEntry = filterDefRegistrations.put(
|
||||||
name,
|
name,
|
||||||
new FilterDefRegistration( name, defaultCondition, autoEnabled, parameterTypes, parameterResolvers )
|
new FilterDefRegistration( name, defaultCondition, autoEnabled, applyToLoadByKey, parameterTypes, parameterResolvers )
|
||||||
);
|
);
|
||||||
if ( previousEntry != null ) {
|
if ( previousEntry != null ) {
|
||||||
// legacy code simply allows the collision overwriting the previous
|
// legacy code simply allows the collision overwriting the previous
|
||||||
|
@ -32,7 +32,7 @@ public class FilterDefRegistration {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final String defaultCondition;
|
private final String defaultCondition;
|
||||||
private final boolean autoEnabled;
|
private final boolean autoEnabled;
|
||||||
|
private final boolean applyToLoadByKey;
|
||||||
private final Map<String, ClassDetails> parameterTypes;
|
private final Map<String, ClassDetails> parameterTypes;
|
||||||
private final Map<String, ClassDetails> parameterResolvers;
|
private final Map<String, ClassDetails> parameterResolvers;
|
||||||
|
|
||||||
@ -40,11 +40,13 @@ public FilterDefRegistration(
|
|||||||
String name,
|
String name,
|
||||||
String defaultCondition,
|
String defaultCondition,
|
||||||
boolean autoEnabled,
|
boolean autoEnabled,
|
||||||
|
boolean applyToLoadByKey,
|
||||||
Map<String, ClassDetails> parameterTypes,
|
Map<String, ClassDetails> parameterTypes,
|
||||||
Map<String, ClassDetails> parameterResolvers) {
|
Map<String, ClassDetails> parameterResolvers) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.defaultCondition = defaultCondition;
|
this.defaultCondition = defaultCondition;
|
||||||
this.autoEnabled = autoEnabled;
|
this.autoEnabled = autoEnabled;
|
||||||
|
this.applyToLoadByKey = applyToLoadByKey;
|
||||||
this.parameterTypes = parameterTypes;
|
this.parameterTypes = parameterTypes;
|
||||||
this.parameterResolvers = parameterResolvers;
|
this.parameterResolvers = parameterResolvers;
|
||||||
}
|
}
|
||||||
@ -61,6 +63,10 @@ public boolean isAutoEnabled() {
|
|||||||
return autoEnabled;
|
return autoEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isApplyToLoadByKey() {
|
||||||
|
return applyToLoadByKey;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, ClassDetails> getParameterTypes() {
|
public Map<String, ClassDetails> getParameterTypes() {
|
||||||
return parameterTypes;
|
return parameterTypes;
|
||||||
}
|
}
|
||||||
@ -104,6 +110,7 @@ public FilterDefinition toFilterDefinition(MetadataBuildingContext buildingConte
|
|||||||
getName(),
|
getName(),
|
||||||
getDefaultCondition(),
|
getDefaultCondition(),
|
||||||
isAutoEnabled(),
|
isAutoEnabled(),
|
||||||
|
isApplyToLoadByKey(),
|
||||||
parameterJdbcMappings,
|
parameterJdbcMappings,
|
||||||
parameterResolvers
|
parameterResolvers
|
||||||
);
|
);
|
||||||
|
@ -132,12 +132,19 @@ public Object insert(String entityName, Object entity) {
|
|||||||
}
|
}
|
||||||
final Generator generator = persister.getGenerator();
|
final Generator generator = persister.getGenerator();
|
||||||
if ( !generator.generatedOnExecution( entity, this ) ) {
|
if ( !generator.generatedOnExecution( entity, this ) ) {
|
||||||
|
if ( generator.generatesOnInsert() ) {
|
||||||
id = ( (BeforeExecutionGenerator) generator).generate( this, entity, null, INSERT );
|
id = ( (BeforeExecutionGenerator) generator).generate( this, entity, null, INSERT );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
id = persister.getIdentifier( entity, this );
|
||||||
|
if ( id == null ) {
|
||||||
|
throw new IdentifierGenerationException( "Identifier of entity '" + persister.getEntityName() + "' must be manually assigned before calling 'insert()'" );
|
||||||
|
}
|
||||||
|
}
|
||||||
if ( firePreInsert(entity, id, state, persister) ) {
|
if ( firePreInsert(entity, id, state, persister) ) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
getInterceptor()
|
getInterceptor().onInsert( entity, id, state, persister.getPropertyNames(), persister.getPropertyTypes() );
|
||||||
.onInsert( entity, id, state, persister.getPropertyNames(), persister.getPropertyTypes() );
|
|
||||||
persister.getInsertCoordinator().insert( entity, id, state, this );
|
persister.getInsertCoordinator().insert( entity, id, state, this );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -754,18 +754,6 @@ public AbstractEntityPersister(
|
|||||||
subclassPropertyFetchModeClosure[j++] = fetchMode;
|
subclassPropertyFetchModeClosure[j++] = fetchMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
propertyDefinedOnSubclass = toBooleanArray( definedBySubclass );
|
|
||||||
|
|
||||||
// Handle any filters applied to the class level
|
|
||||||
filterHelper = isNotEmpty( persistentClass.getFilters() ) ? new FilterHelper(
|
|
||||||
persistentClass.getFilters(),
|
|
||||||
getEntityNameByTableNameMap(
|
|
||||||
persistentClass,
|
|
||||||
factory.getSqlStringGenerationContext()
|
|
||||||
),
|
|
||||||
factory
|
|
||||||
) : null;
|
|
||||||
|
|
||||||
useReferenceCacheEntries = shouldUseReferenceCacheEntries( creationContext.getSessionFactoryOptions() );
|
useReferenceCacheEntries = shouldUseReferenceCacheEntries( creationContext.getSessionFactoryOptions() );
|
||||||
useShallowQueryCacheLayout = shouldUseShallowCacheLayout(
|
useShallowQueryCacheLayout = shouldUseShallowCacheLayout(
|
||||||
persistentClass.getQueryCacheLayout(),
|
persistentClass.getQueryCacheLayout(),
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import org.hibernate.metamodel.spi.ValueAccess;
|
import org.hibernate.metamodel.spi.ValueAccess;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.property.access.spi.Setter;
|
import org.hibernate.property.access.spi.Setter;
|
||||||
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.spi.NavigablePath;
|
import org.hibernate.spi.NavigablePath;
|
||||||
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
||||||
|
@ -2798,6 +2798,7 @@
|
|||||||
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string"/>
|
<xsd:attribute name="name" use="required" type="xsd:string"/>
|
||||||
<xsd:attribute name="auto-enabled" type="xsd:boolean" default="false"/>
|
<xsd:attribute name="auto-enabled" type="xsd:boolean" default="false"/>
|
||||||
|
<xsd:attribute name="apply-to-load-by-key" type="xsd:boolean" default="false"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="hbm-filter">
|
<xsd:complexType name="hbm-filter">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user