parent
593295e686
commit
31f495c9d5
|
@ -1333,25 +1333,25 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
|
|||
}
|
||||
|
||||
private static AnnotatedClassType getAnnotatedClassType(ClassDetails clazz) {
|
||||
if ( clazz.isAnnotationPresent( Entity.class ) ) {
|
||||
if ( clazz.isAnnotationPresent( Embeddable.class ) ) {
|
||||
if ( clazz.hasDirectAnnotationUsage( Entity.class ) ) {
|
||||
if ( clazz.hasDirectAnnotationUsage( Embeddable.class ) ) {
|
||||
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() + "'" );
|
||||
}
|
||||
return AnnotatedClassType.ENTITY;
|
||||
}
|
||||
else if ( clazz.isAnnotationPresent( Embeddable.class ) ) {
|
||||
if ( clazz.isAnnotationPresent( jakarta.persistence.MappedSuperclass.class ) ) {
|
||||
else if ( clazz.hasDirectAnnotationUsage( Embeddable.class ) ) {
|
||||
if ( clazz.hasDirectAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
|
||||
throw new AnnotationException( "Invalid class annotated both '@Embeddable' and '@MappedSuperclass': '" + clazz.getName() + "'" );
|
||||
}
|
||||
return AnnotatedClassType.EMBEDDABLE;
|
||||
}
|
||||
else if ( clazz.isAnnotationPresent( jakarta.persistence.MappedSuperclass.class ) ) {
|
||||
else if ( clazz.hasDirectAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
|
||||
return AnnotatedClassType.MAPPED_SUPERCLASS;
|
||||
}
|
||||
else if ( clazz.isAnnotationPresent( Imported.class ) ) {
|
||||
else if ( clazz.hasDirectAnnotationUsage( Imported.class ) ) {
|
||||
return AnnotatedClassType.IMPORTED;
|
||||
}
|
||||
else {
|
||||
|
@ -1359,13 +1359,6 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotatedClassType addClassType(ClassDetails classDetails) {
|
||||
final AnnotatedClassType type = getAnnotatedClassType2( classDetails );
|
||||
annotatedClassTypeMap.put( classDetails.getName(), type );
|
||||
return type;
|
||||
}
|
||||
|
||||
private static AnnotatedClassType getAnnotatedClassType2(ClassDetails classDetails) {
|
||||
if ( classDetails.hasDirectAnnotationUsage( Entity.class ) ) {
|
||||
return AnnotatedClassType.ENTITY;
|
||||
|
@ -1384,18 +1377,6 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotatedClassType getClassType(ClassDetails classDetails) {
|
||||
final AnnotatedClassType type = annotatedClassTypeMap.get( classDetails.getName() );
|
||||
if ( type == null ) {
|
||||
return addClassType( classDetails );
|
||||
}
|
||||
else {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addMappedSuperclass(Class<?> type, MappedSuperclass mappedSuperclass) {
|
||||
if ( mappedSuperClasses == null ) {
|
||||
|
|
|
@ -418,13 +418,15 @@ public class EmbeddableBinder {
|
|||
);
|
||||
}
|
||||
|
||||
final Map<String, String> subclassToSuperclass = component.isPolymorphic() ? new HashMap<>() : null;
|
||||
final TypeDetails annotatedType = inferredData.getPropertyType();
|
||||
final List<PropertyData> classElements = collectClassElements(
|
||||
propertyAccessor,
|
||||
context,
|
||||
returnedClassOrElement,
|
||||
annotatedType,
|
||||
isIdClass
|
||||
isIdClass,
|
||||
subclassToSuperclass
|
||||
);
|
||||
|
||||
if ( component.isPolymorphic() ) {
|
||||
|
@ -637,9 +639,9 @@ public class EmbeddableBinder {
|
|||
new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor );
|
||||
addElementsOfClass( classElements, container, context);
|
||||
//add elements of the embeddable's mapped superclasses
|
||||
ClassDetails subClass = returnedClassOrElement;
|
||||
XClass superClass;
|
||||
while ( isValidSuperclass( superClass = subclass.getSuperclass(), isIdClass ) ) {
|
||||
ClassDetails subclass = returnedClassOrElement;
|
||||
ClassDetails superClass;
|
||||
while ( isValidSuperclass( superClass = subclass.getSuperClass(), isIdClass ) ) {
|
||||
//FIXME: proper support of type variables incl var resolved at upper levels
|
||||
final PropertyContainer superContainer = new PropertyContainer(
|
||||
superClass,
|
||||
|
|
|
@ -22,8 +22,9 @@ import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkV
|
|||
public class FilterDefAnnotation implements FilterDef {
|
||||
private String name;
|
||||
private String defaultCondition;
|
||||
private org.hibernate.annotations.ParamDef[] parameters;
|
||||
private boolean autoEnabled;
|
||||
private boolean applyToLoadByKey;
|
||||
private org.hibernate.annotations.ParamDef[] parameters;
|
||||
|
||||
/**
|
||||
* Used in creating dynamic annotation instances (e.g. from XML)
|
||||
|
@ -40,8 +41,9 @@ public class FilterDefAnnotation implements FilterDef {
|
|||
public FilterDefAnnotation(FilterDef annotation, SourceModelBuildingContext modelContext) {
|
||||
this.name = annotation.name();
|
||||
this.defaultCondition = annotation.defaultCondition();
|
||||
this.parameters = extractJdkValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
||||
this.autoEnabled = annotation.autoEnabled();
|
||||
this.applyToLoadByKey = annotation.applyToLoadByKey();;
|
||||
this.parameters = extractJdkValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,13 +57,19 @@ public class FilterDefAnnotation implements FilterDef {
|
|||
"defaultCondition",
|
||||
modelContext
|
||||
);
|
||||
this.parameters = extractJandexValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
||||
this.autoEnabled = extractJandexValue(
|
||||
annotation,
|
||||
HibernateAnnotations.FILTER_DEF,
|
||||
"autoEnabled",
|
||||
modelContext
|
||||
);
|
||||
this.applyToLoadByKey = extractJandexValue(
|
||||
annotation,
|
||||
HibernateAnnotations.FILTER_DEF,
|
||||
"applyToLoadByKey",
|
||||
modelContext
|
||||
);
|
||||
this.parameters = extractJandexValue( annotation, HibernateAnnotations.FILTER_DEF, "parameters", modelContext );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,16 +97,6 @@ public class FilterDefAnnotation implements FilterDef {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public org.hibernate.annotations.ParamDef[] parameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void parameters(org.hibernate.annotations.ParamDef[] value) {
|
||||
this.parameters = value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean autoEnabled() {
|
||||
return autoEnabled;
|
||||
|
@ -109,4 +107,23 @@ public class FilterDefAnnotation implements FilterDef {
|
|||
}
|
||||
|
||||
|
||||
@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 class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
usage.name(),
|
||||
usage.defaultCondition(),
|
||||
usage.autoEnabled(),
|
||||
usage.applyToLoadByKey(),
|
||||
paramJdbcMappings,
|
||||
parameterResolvers
|
||||
);
|
||||
|
@ -597,6 +598,7 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
filterDefinition.getName(),
|
||||
filterDefinition.getDefaultCondition(),
|
||||
filterDefinition.isAutoEnabled(),
|
||||
filterDefinition.isApplyToLoadByKey(),
|
||||
paramJdbcMappings,
|
||||
parameterResolvers
|
||||
);
|
||||
|
@ -607,6 +609,7 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
String name,
|
||||
String defaultCondition,
|
||||
boolean autoEnabled,
|
||||
boolean applyToLoadByKey,
|
||||
Map<String, ClassDetails> parameterTypes,
|
||||
Map<String, ClassDetails> parameterResolvers) {
|
||||
if ( filterDefRegistrations == null ) {
|
||||
|
@ -615,7 +618,7 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
|
||||
final FilterDefRegistration previousEntry = filterDefRegistrations.put(
|
||||
name,
|
||||
new FilterDefRegistration( name, defaultCondition, autoEnabled, parameterTypes, parameterResolvers )
|
||||
new FilterDefRegistration( name, defaultCondition, autoEnabled, applyToLoadByKey, parameterTypes, parameterResolvers )
|
||||
);
|
||||
if ( previousEntry != null ) {
|
||||
// legacy code simply allows the collision overwriting the previous
|
||||
|
|
|
@ -32,7 +32,7 @@ public class FilterDefRegistration {
|
|||
private final String name;
|
||||
private final String defaultCondition;
|
||||
private final boolean autoEnabled;
|
||||
|
||||
private final boolean applyToLoadByKey;
|
||||
private final Map<String, ClassDetails> parameterTypes;
|
||||
private final Map<String, ClassDetails> parameterResolvers;
|
||||
|
||||
|
@ -40,11 +40,13 @@ public class FilterDefRegistration {
|
|||
String name,
|
||||
String defaultCondition,
|
||||
boolean autoEnabled,
|
||||
boolean applyToLoadByKey,
|
||||
Map<String, ClassDetails> parameterTypes,
|
||||
Map<String, ClassDetails> parameterResolvers) {
|
||||
this.name = name;
|
||||
this.defaultCondition = defaultCondition;
|
||||
this.autoEnabled = autoEnabled;
|
||||
this.applyToLoadByKey = applyToLoadByKey;
|
||||
this.parameterTypes = parameterTypes;
|
||||
this.parameterResolvers = parameterResolvers;
|
||||
}
|
||||
|
@ -61,6 +63,10 @@ public class FilterDefRegistration {
|
|||
return autoEnabled;
|
||||
}
|
||||
|
||||
public boolean isApplyToLoadByKey() {
|
||||
return applyToLoadByKey;
|
||||
}
|
||||
|
||||
public Map<String, ClassDetails> getParameterTypes() {
|
||||
return parameterTypes;
|
||||
}
|
||||
|
@ -104,6 +110,7 @@ public class FilterDefRegistration {
|
|||
getName(),
|
||||
getDefaultCondition(),
|
||||
isAutoEnabled(),
|
||||
isApplyToLoadByKey(),
|
||||
parameterJdbcMappings,
|
||||
parameterResolvers
|
||||
);
|
||||
|
|
|
@ -132,12 +132,19 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
}
|
||||
final Generator generator = persister.getGenerator();
|
||||
if ( !generator.generatedOnExecution( entity, this ) ) {
|
||||
id = ( (BeforeExecutionGenerator) generator).generate( this, entity, null, INSERT );
|
||||
if ( generator.generatesOnInsert() ) {
|
||||
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) ) {
|
||||
return id;
|
||||
}
|
||||
getInterceptor()
|
||||
.onInsert( entity, id, state, persister.getPropertyNames(), persister.getPropertyTypes() );
|
||||
getInterceptor().onInsert( entity, id, state, persister.getPropertyNames(), persister.getPropertyTypes() );
|
||||
persister.getInsertCoordinator().insert( entity, id, state, this );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -754,18 +754,6 @@ public abstract class AbstractEntityPersister
|
|||
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() );
|
||||
useShallowQueryCacheLayout = shouldUseShallowCacheLayout(
|
||||
persistentClass.getQueryCacheLayout(),
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.hibernate.metamodel.spi.EmbeddableInstantiator;
|
|||
import org.hibernate.metamodel.spi.ValueAccess;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.property.access.spi.Setter;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.proxy.LazyInitializer;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
||||
|
|
|
@ -2798,6 +2798,7 @@
|
|||
|
||||
<xsd:attribute name="name" use="required" type="xsd:string"/>
|
||||
<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 name="hbm-filter">
|
||||
|
|
Loading…
Reference in New Issue