HHH-7529 Bind @LazyCollection
This commit is contained in:
parent
1c26ef34cc
commit
cee1fc8b20
|
@ -240,6 +240,8 @@ public class EntitySourceImpl implements EntitySource {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ONE_TO_MANY:
|
case ONE_TO_MANY:
|
||||||
|
attributeList.add( new PluralAttributeSourceImpl( ( PluralAssociationAttribute ) associationAttribute ) );
|
||||||
|
break;
|
||||||
default: {
|
default: {
|
||||||
throw new NotYetImplementedException();
|
throw new NotYetImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,14 +51,15 @@ import org.hibernate.metamodel.spi.source.TableSpecificationSource;
|
||||||
*/
|
*/
|
||||||
public class PluralAttributeSourceImpl implements PluralAttributeSource {
|
public class PluralAttributeSourceImpl implements PluralAttributeSource {
|
||||||
|
|
||||||
PluralAssociationAttribute attribute;
|
private final PluralAssociationAttribute attribute;
|
||||||
|
private final PluralAttributeNature nature;
|
||||||
|
|
||||||
public PluralAttributeSourceImpl(PluralAssociationAttribute attribute) {
|
public PluralAttributeSourceImpl(PluralAssociationAttribute attribute) {
|
||||||
this.attribute = attribute;
|
this.attribute = attribute;
|
||||||
|
this.nature = resolveAttributeNature();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private PluralAttributeNature resolveAttributeNature(){
|
||||||
public PluralAttributeNature getPluralAttributeNature() {
|
|
||||||
if ( Map.class.isAssignableFrom( attribute.getAttributeType() ) ) {
|
if ( Map.class.isAssignableFrom( attribute.getAttributeType() ) ) {
|
||||||
return PluralAttributeNature.MAP;
|
return PluralAttributeNature.MAP;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +74,11 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PluralAttributeNature getPluralAttributeNature() {
|
||||||
|
return nature;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluralAttributeKeySource getKeySource() {
|
public PluralAttributeKeySource getKeySource() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
@ -148,12 +154,12 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomSQL getCustomSqlDeleteAll() {
|
public CustomSQL getCustomSqlDeleteAll() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return attribute.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -184,17 +190,23 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FetchMode getFetchMode() {
|
public FetchMode getFetchMode() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return attribute.getFetchMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FetchTiming getFetchTiming() {
|
public FetchTiming getFetchTiming() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
if ( attribute.isExtraLazy() ) {
|
||||||
|
return FetchTiming.EXTRA_DELAYED;
|
||||||
|
}
|
||||||
|
if ( attribute.isLazy() ) {
|
||||||
|
return FetchTiming.DELAYED;
|
||||||
|
}
|
||||||
|
return FetchTiming.IMMEDIATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FetchStyle getFetchStyle() {
|
public FetchStyle getFetchStyle() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return attribute.getFetchStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OneToManyPluralAttributeElementSourceImpl implements OneToManyPluralAttributeElementSource {
|
private class OneToManyPluralAttributeElementSourceImpl implements OneToManyPluralAttributeElementSource {
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class AssociationAttribute extends MappedAttribute {
|
||||||
this.referencedEntityType = determineReferencedEntityType( associationAnnotation );
|
this.referencedEntityType = determineReferencedEntityType( associationAnnotation );
|
||||||
this.mappedBy = determineMappedByAttributeName( associationAnnotation );
|
this.mappedBy = determineMappedByAttributeName( associationAnnotation );
|
||||||
this.isOptional = determineOptionality( associationAnnotation );
|
this.isOptional = determineOptionality( associationAnnotation );
|
||||||
this.isLazy = determineFetchType( associationAnnotation );
|
this.isLazy = determinIsLazy( associationAnnotation );
|
||||||
this.isOrphanRemoval = determineOrphanRemoval( associationAnnotation );
|
this.isOrphanRemoval = determineOrphanRemoval( associationAnnotation );
|
||||||
this.cascadeTypes = determineCascadeTypes( associationAnnotation );
|
this.cascadeTypes = determineCascadeTypes( associationAnnotation );
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public class AssociationAttribute extends MappedAttribute {
|
||||||
return orphanRemoval;
|
return orphanRemoval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean determineFetchType(AnnotationInstance associationAnnotation) {
|
protected boolean determinIsLazy(AnnotationInstance associationAnnotation) {
|
||||||
boolean lazy = false;
|
boolean lazy = false;
|
||||||
AnnotationValue fetchValue = associationAnnotation.value( "fetch" );
|
AnnotationValue fetchValue = associationAnnotation.value( "fetch" );
|
||||||
if ( fetchValue != null ) {
|
if ( fetchValue != null ) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.jboss.jandex.DotName;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext;
|
import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext;
|
||||||
import org.hibernate.metamodel.internal.source.annotations.util.AnnotationParserHelper;
|
import org.hibernate.metamodel.internal.source.annotations.util.AnnotationParserHelper;
|
||||||
|
@ -55,6 +56,8 @@ public class PluralAssociationAttribute extends AssociationAttribute {
|
||||||
private final CustomSQL customUpdate;
|
private final CustomSQL customUpdate;
|
||||||
private final CustomSQL customDelete;
|
private final CustomSQL customDelete;
|
||||||
private final ClassInfo entityClassInfo;
|
private final ClassInfo entityClassInfo;
|
||||||
|
private final boolean isExtraLazy;
|
||||||
|
private LazyCollectionOption lazyOption;
|
||||||
|
|
||||||
|
|
||||||
// Used for the non-owning side of a ManyToMany relationship
|
// Used for the non-owning side of a ManyToMany relationship
|
||||||
|
@ -123,6 +126,7 @@ public class PluralAssociationAttribute extends AssociationAttribute {
|
||||||
this.orderBy = determineOrderBy();
|
this.orderBy = determineOrderBy();
|
||||||
this.inverseForeignKeyName = determineInverseForeignKeyName();
|
this.inverseForeignKeyName = determineInverseForeignKeyName();
|
||||||
this.caching = determineCachingSettings();
|
this.caching = determineCachingSettings();
|
||||||
|
this.isExtraLazy = lazyOption == LazyCollectionOption.EXTRA;
|
||||||
this.customPersister = determineCustomPersister();
|
this.customPersister = determineCustomPersister();
|
||||||
this.customInsert = AnnotationParserHelper.processCustomSqlAnnotation(
|
this.customInsert = AnnotationParserHelper.processCustomSqlAnnotation(
|
||||||
HibernateDotNames.SQL_INSERT, annotations()
|
HibernateDotNames.SQL_INSERT, annotations()
|
||||||
|
@ -161,6 +165,29 @@ public class PluralAssociationAttribute extends AssociationAttribute {
|
||||||
return foreignKeyName;
|
return foreignKeyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean determinIsLazy(AnnotationInstance associationAnnotation) {
|
||||||
|
boolean lazy = super.determinIsLazy( associationAnnotation );
|
||||||
|
final AnnotationInstance lazyCollectionAnnotationInstance = JandexHelper.getSingleAnnotation(
|
||||||
|
annotations(),
|
||||||
|
HibernateDotNames.LAZY_COLLECTION
|
||||||
|
);
|
||||||
|
if ( lazyCollectionAnnotationInstance != null ) {
|
||||||
|
LazyCollectionOption option = JandexHelper.getEnumValue(
|
||||||
|
lazyCollectionAnnotationInstance,
|
||||||
|
"value",
|
||||||
|
LazyCollectionOption.class
|
||||||
|
);
|
||||||
|
return option == LazyCollectionOption.TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
return lazy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExtraLazy() {
|
||||||
|
return isExtraLazy;
|
||||||
|
}
|
||||||
|
|
||||||
private String determineWereClause() {
|
private String determineWereClause() {
|
||||||
String where = null;
|
String where = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue