CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder( propertyHolder.getEntityName(), property, context ); collectionBinder.setIndexColumn( indexColumn ); collectionBinder.setMapKey( property.getAnnotation( MapKey.class ) ); collectionBinder.setPropertyName( inferredData.getPropertyName() ); collectionBinder.setBatchSize( property.getAnnotation( BatchSize.class ) ); collectionBinder.setJpaOrderBy( property.getAnnotation( javax.persistence.OrderBy.class ) ); collectionBinder.setSqlOrderBy( property.getAnnotation( OrderBy.class ) ); collectionBinder.setSort( property.getAnnotation( Sort.class ) ); collectionBinder.setNaturalSort( property.getAnnotation( SortNatural.class ) ); collectionBinder.setComparatorSort( property.getAnnotation( SortComparator.class ) ); collectionBinder.setCache( cachAnn ); collectionBinder.setPropertyHolder( propertyHolder ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() ); collectionBinder.setBuildingContext( context ); collectionBinder.setAccessType( inferredData.getDefaultAccess() );
) { bindOneToManySecondPass( getCollection(), persistentClasses, fkJoinColumns, bindManyToManySecondPass( this.collection, persistentClasses,
@Override public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas) throws MappingException { bindStarToManySecondPass( persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns, isEmbedded, property, unique, assocTableBinder, ignoreNotFound, buildingContext ); } };
public void bind() { this.collection = createCollection( propertyHolder.getPersistentClass() ); String role = StringHelper.qualify( propertyHolder.getPath(), propertyName ); LOG.debugf( "Collection role: %s", role ); defineFetchingStrategy(); collection.setBatchSize( batchSize ); applySortingAndOrdering( collection ); buildingContext.getMetadataCollector().addMappedBy( getCollectionType().getName(), mappedBy, propertyName ); XClass collectionType = getCollectionType(); if ( inheritanceStatePerClass == null) throw new AssertionFailure( "inheritanceStatePerClass not set" ); SecondPass sp = getSecondPass( fkJoinColumns, joinColumns,
indexAnn, propertyHolder, inferredData, mappings ); CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder( propertyHolder.getEntityName(), property, ! indexColumn.isImplicit() ); collectionBinder.setIndexColumn( indexColumn ); MapKey mapKeyAnn = property.getAnnotation( MapKey.class ); collectionBinder.setMapKey( mapKeyAnn ); collectionBinder.setPropertyName( inferredData.getPropertyName() ); BatchSize batchAnn = property.getAnnotation( BatchSize.class ); javax.persistence.OrderBy ejb3OrderByAnn = property.getAnnotation( javax.persistence.OrderBy.class ); OrderBy orderByAnn = property.getAnnotation( OrderBy.class ); collectionBinder.setEjb3OrderBy( ejb3OrderByAnn ); collectionBinder.setSqlOrderBy( orderByAnn ); Sort sortAnn = property.getAnnotation( Sort.class ); collectionBinder.setSort( sortAnn ); Cache cachAnn = property.getAnnotation( Cache.class ); collectionBinder.setCache( cachAnn ); collectionBinder.setPropertyHolder( propertyHolder ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() ); collectionBinder.setMappings( mappings ); collectionBinder.setPropertyAccessorName( inferredData.getDefaultAccess() );
collValue.setCollectionTable( associationTableBinder.bind() ); bindFilters( isCollectionOfEntities ); bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, mappings ); buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() ) ); if ( isMap() ) { if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); String orderBy = buildOrderByClauseFromHql( hqlOrderBy, component, path ); if ( orderBy != null ) { collValue.setOrderBy( orderBy ); checkFilterConditions( collValue ); bindManytoManyInverseFk( collectionEntity, inverseJoinColumns, element, unique, mappings );
public void bind() { this.collection = createCollection( propertyHolder.getPersistentClass() ); log.debug( "Collection role: {}", StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); collection.setRole( StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); defineFetchingStrategy(); collection.setBatchSize( batchSize ); if ( orderBy != null && hqlOrderBy != null ) { throw new AnnotationException( "Cannot use sql order by clause in conjunction of EJB3 order by clause: " + safeCollectionRole() ); throw new AnnotationException( "Comparator not implementing java.util.Comparator class: " + comparator.getName() + "(" + safeCollectionRole() + ")" ); throw new AnnotationException( "Could not instantiate comparator class: " + comparator.getName() + "(" + safeCollectionRole() + ")" ); throw new AnnotationException( "A sorted collection has to define @Sort: " + safeCollectionRole() ); mappings.addMappedBy( getCollectionType().getName(), mappedBy, propertyName ); XClass collectionType = getCollectionType();
final String hqlOrderBy = extractHqlOrderBy( jpaOrderBy ); bindFilters( isCollectionOfEntities ); bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, propertyHolder, buildingContext ); buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() ) ); if ( isMap() ) { if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); String orderBy = adjustUserSuppliedValueCollectionOrderingFragment( hqlOrderBy ); if ( orderBy != null ) { collValue.setOrderBy( orderBy ); elementBinder.setAccessType( accessType ); collValue.setElement( elementBinder.make() ); String orderBy = adjustUserSuppliedValueCollectionOrderingFragment( hqlOrderBy ); if ( orderBy != null ) { collValue.setOrderBy( orderBy ); checkFilterConditions( collValue ); bindManytoManyInverseFk( collectionEntity, inverseJoinColumns, element, unique, buildingContext );
checkFilterConditions( collValue ); bindManytoManyInverseFk( collectionEntity, inverseJoinColumns, element, unique, mappings );
private static void bindCollectionSecondPass( Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled, XProperty property, PropertyHolder propertyHolder, MetadataBuildingContext buildingContext) { try { BinderHelper.createSyntheticPropertyReference( joinColumns, collValue.getOwner(), collectionEntity, collValue, false, buildingContext ); } catch (AnnotationException ex) { throw new AnnotationException( "Unable to map collection " + collValue.getOwner().getClassName() + "." + property.getName(), ex ); } SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, propertyHolder, buildingContext ); if ( property.isAnnotationPresent( ElementCollection.class ) && joinColumns.length > 0 ) { joinColumns[0].setJPA2ElementCollection( true ); } TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, buildingContext ); }
collValue.setCollectionTable( associationTableBinder.bind() ); bindFilters( isCollectionOfEntities ); bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, mappings ); buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() ) ); if ( isMap() ) { if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); String orderBy = buildOrderByClauseFromHql( hqlOrderBy, component, path ); if ( orderBy != null ) { collValue.setOrderBy( orderBy ); checkFilterConditions( collValue ); bindManytoManyInverseFk( collectionEntity, inverseJoinColumns, element, unique, mappings );
public void bind() { this.collection = createCollection( propertyHolder.getPersistentClass() ); log.debug( "Collection role: " + StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); collection.setRole( StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); defineFetchingStrategy(); if ( orderBy != null && hqlOrderBy != null ) { throw new AnnotationException( "Cannot use sql order by clause in conjunction of EJB3 order by clause: " + safeCollectionRole() ); SecondPass sp = getSecondPass( fkJoinColumns, joinColumns,
final String hqlOrderBy = extractHqlOrderBy( jpaOrderBy ); bindFilters( isCollectionOfEntities ); bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, propertyHolder, buildingContext ); buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() ) ); if ( isMap() ) { if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); String orderBy = adjustUserSuppliedValueCollectionOrderingFragment( hqlOrderBy ); if ( orderBy != null ) { collValue.setOrderBy( orderBy ); ); elementBinder.setPersistentClassName( propertyHolder.getEntityName() ); String orderBy = adjustUserSuppliedValueCollectionOrderingFragment( hqlOrderBy ); if ( orderBy != null ) { collValue.setOrderBy( orderBy ); checkFilterConditions( collValue ); bindManytoManyInverseFk( collectionEntity, inverseJoinColumns, element, unique, buildingContext );
public void bind() { this.collection = createCollection( propertyHolder.getPersistentClass() ); String role = StringHelper.qualify( propertyHolder.getPath(), propertyName ); LOG.debugf( "Collection role: %s", role ); defineFetchingStrategy(); collection.setBatchSize( batchSize ); applySortingAndOrdering( collection ); buildingContext.getMetadataCollector().addMappedBy( getCollectionType().getName(), mappedBy, propertyName ); XClass collectionType = getCollectionType(); if ( inheritanceStatePerClass == null) throw new AssertionFailure( "inheritanceStatePerClass not set" ); SecondPass sp = getSecondPass( fkJoinColumns, joinColumns,
private static void bindCollectionSecondPass( Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled, XProperty property, ExtendedMappings mappings ) { BinderHelper.createSyntheticPropertyReference( joinColumns, collValue.getOwner(), collectionEntity, collValue, false, mappings ); SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, mappings ); if ( property.isAnnotationPresent( ElementCollection.class ) && joinColumns.length > 0 ) { joinColumns[0].setJPA2ElementCollection( true ); } TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, mappings ); }
CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder( propertyHolder.getEntityName(), property, collectionBinder.setIndexColumn( indexColumn ); MapKey mapKeyAnn = property.getAnnotation( MapKey.class ); collectionBinder.setMapKey( mapKeyAnn ); collectionBinder.setPropertyName( inferredData.getPropertyName() ); BatchSize batchAnn = property.getAnnotation( BatchSize.class ); collectionBinder.setBatchSize( batchAnn ); javax.persistence.OrderBy ejb3OrderByAnn = property.getAnnotation( javax.persistence.OrderBy.class ); OrderBy orderByAnn = property.getAnnotation( OrderBy.class ); collectionBinder.setEjb3OrderBy( ejb3OrderByAnn ); collectionBinder.setSqlOrderBy( orderByAnn ); Sort sortAnn = property.getAnnotation( Sort.class ); collectionBinder.setSort( sortAnn ); Cache cachAnn = property.getAnnotation( Cache.class ); collectionBinder.setCache( cachAnn ); collectionBinder.setPropertyHolder( propertyHolder ); Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); collectionBinder.setIgnoreNotFound( ignoreNotFound ); collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() ); collectionBinder.setMappings( mappings ); collectionBinder.setAccessType( inferredData.getDefaultAccess() ); mappings );
collValue.setCollectionTable( associationTableBinder.bind() ); bindFilters( isCollectionOfEntities ); bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, mappings ); buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() ) ); if ( isMap() ) { if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); if ( isHibernateExtensionMapping() ) { inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass ); String orderBy = buildOrderByClauseFromHql( hqlOrderBy, component, path ); if ( orderBy != null ) { collValue.setOrderBy( orderBy ); checkFilterConditions( collValue ); bindManytoManyInverseFk( collectionEntity, inverseJoinColumns, element, unique, mappings );
public void bind() { this.collection = createCollection( propertyHolder.getPersistentClass() ); String role = StringHelper.qualify( propertyHolder.getPath(), propertyName ); LOG.debugf( "Collection role: %s", role ); defineFetchingStrategy(); collection.setBatchSize( batchSize ); if ( orderBy != null && hqlOrderBy != null ) { throw new AnnotationException( "Cannot use sql order by clause in conjunction of EJB3 order by clause: " + safeCollectionRole() ); throw new AnnotationException( "Comparator not implementing java.util.Comparator class: " + comparator.getName() + "(" + safeCollectionRole() + ")" ); throw new AnnotationException( "Could not instantiate comparator class: " + comparator.getName() + "(" + safeCollectionRole() + ")" ); throw new AnnotationException( "A sorted collection has to define @Sort: " + safeCollectionRole() ); mappings.addMappedBy( getCollectionType().getName(), mappedBy, propertyName ); XClass collectionType = getCollectionType();
) { bindOneToManySecondPass( getCollection(), persistentClasses, fkJoinColumns, bindManyToManySecondPass( this.collection, persistentClasses,
public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas) throws MappingException { bindStarToManySecondPass( persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns, isEmbedded, property, unique, assocTableBinder, ignoreNotFound, mappings ); } };