public AssociatedNavigableMap(ObjectModel objectModel, int propertyId) { super(null); Arguments.mustNotBeNull("objectModel", objectModel); this.owner = objectModel.getOwner(); ModelProperty property = objectModel.getModelClass().getProperty(propertyId); if (property.getAssociationType() != AssociationType.MAP || !SortedMap.class.isAssignableFrom(property.getStandardCollectionType())) { throw new IllegalArgumentException( CommonMessages.createFailedBecausePropertyMustBe( this.getClass(), property, SortedMap.class ) ); } this.associationProperty = property; if (property.getOppositeProperty() != null) { this.oppositePropertyId = property.getOppositeProperty().getId(); } else { this.oppositePropertyId = -1; } }
private int getInitializationState() { int initializationState = 0; ObjectModel objectModel = this.defaultObjectModel; for (ModelProperty modelProperty : this.defaultObjectModel.getModelClass().getPropertyList()) { if (modelProperty.getPropertyType() == PropertyType.SCALAR && modelProperty.isDeferrable()) { int propertyId = modelProperty.getId(); if (objectModel.isDisabled(propertyId) || objectModel.isUnloaded(propertyId)) { initializationState |= STATE_UNINITIALIZIED; } else { initializationState |= STATE_INITIALIZIED; } if ((initializationState & (STATE_UNINITIALIZIED | STATE_INITIALIZIED)) == (STATE_UNINITIALIZIED | STATE_INITIALIZIED)) { break; } } } return initializationState; }
private static ModelProperty realAssociationProperty(ModelProperty modelProperty) { while (true) { ModelProperty convarianceProperty = modelProperty.getConvarianceProperty(); if (convarianceProperty == null) { break; } modelProperty = convarianceProperty; } return modelProperty; }
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.oppositePropertyId = this.associationProperty.getOppositeProperty().getId(); } }
public AssociatedIndexedReference(ObjectModel objectModel, int propertyId) { Arguments.mustNotBeNull("objectModel", objectModel); this.owner = objectModel.getOwner(); ModelProperty property = objectModel.getModelClass().getProperty(propertyId); if (property.getAssociationType() != AssociationType.INDEXED_REFERENCE) { throw new IllegalArgumentException( CommonMessages.createFailedBecausePropertyMustBe( this.getClass(), property, IndexedReference.class ) ); } if (property.getOppositeProperty() == null) { throw new IllegalArgumentException( CommonMessages.createFailedBecauseOfunidirectionalAssociation( this.getClass(), IndexedReference.class, property ) ); } this.associationProperty = property; this.oppositePropertyId = property.getOppositeProperty().getId(); }
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(((ObjectModelProvider)this.endpoint.getOwner()).objectModel()); out.writeInt(this.endpoint.getAssociationProperty().getId()); out.writeObject(this.endpoint.getBase(true)); }
if (modelProperty.getPropertyType() != PropertyType.SCALAR) { throw new IllegalArgumentException( mustBeScalarAttribute( propertyIdSet.add(modelProperty.getId());
JPAModelClass modelClass = (JPAModelClass)objectModel.getModelClass(); for (ModelProperty modelProperty : modelClass.getPropertyList()) { if (modelProperty.getPropertyType() != PropertyType.ASSOCIATION) { continue; ModelProperty oppositeProperty = modelProperty.getOppositeProperty(); if (oppositeProperty == null || !oppositeProperty.getAssociationType().isReference()) { continue; AssociatedEndpoint associatedEndpoint = objectModel.getAssociatedEndpoint(modelProperty.getId()); if (associatedEndpoint.isDisabled() || !associatedEndpoint.isLoaded()) { continue; int oppositePropertyId = oppositeProperty.getId(); if (associatedEndpoint instanceof Collection<?>) { for (Object o : (Collection<?>)associatedEndpoint) {
switch (modelProperty.getPropertyType()) { case SCALAR: scalarPropertyIdSet.add(modelProperty.getId()); break; case INDEX: case KEY: associationPropertyIdSet.add(realAssociationProperty(modelProperty.getReferenceProperty()).getId()); break; default: associationPropertyIdSet.add(realAssociationProperty(modelProperty).getId()); break;
@SuppressWarnings("unchecked") public static <E, A> XOrderedSet<A> extractAttribute(Collection<E> entities, SingularAttribute<? super E, A> attribute) { XOrderedSet<A> values; if (entities.size() < 1024) { values = new LinkedHashSet<>((entities.size() * 4 + 2) / 3); } else { values = new LinkedHashSet<>(); } for (E entity : entities) { validateArgument("entity", entity); ModelClass modelClass = JPAModelClass.of(entity.getClass()); ObjectModel objectModel = ((ObjectModelProvider)entity).objectModel(); ModelProperty modelProperty = getModelProperty(modelClass, attribute); if (modelProperty.getAssociationType() == AssociationType.NONE) { values.add((A)objectModel.get(modelProperty.getId())); } else { Reference<?> reference = (Reference<?>)objectModel.getAssociatedEndpoint(modelProperty.getId()); values.add((A)reference.get()); } } return values; }
if (endpoint.getAssociationProperty().getOppositeProperty() == null) { return; this.setSuspended(true); try { if (endpoint.getAssociationProperty().getOppositeProperty().getAssociationType() == AssociationType.INDEXED_REFERENCE) { EventAttributeContext globalContext = e.getAttributeContext(AttributeScope.GLOBAL); IndexRange indexRange = globalContext.getAttribute(AK_INDEX_RANGE);
Map<Object, ObjectModel> idMap = new LinkedHashMap<>(); for (ObjectModel objectModel : objectModels) { idMap.put(objectModel.get(idProperty.getId()), objectModel); ProjectionList projectionList = Projections.projectionList(); if (batch) { projectionList.add(Projections.property(idProperty.getName())); String propertyName = modelClass.getProperty(propertyId).getName(); projectionList.add(Projections.property(propertyName)); .add( Restrictions.in( idProperty.getName(), idMap.keySet() .add( Restrictions.eq( idProperty.getName(), idMap.keySet().iterator().next()
if (modelProperty.getConvarianceProperty() != null) { continue; Property hibernateProperty = persistentClass.getProperty(modelProperty.getName()); hibernateProperty.setPropertyAccessorName(propertyAccessorName); Class<?> standardCollectionType = modelProperty.getStandardCollectionType(); if (standardCollectionType == null) { continue;
protected EqualityComparator<?> createDefaultEqualityComparator() { if (this.type == ModelType.REFERENCE) { return ReferenceEqualityComparator.getInstance(); } ComparatorPart[] parts = new ComparatorPart[this.propertyArray.length]; int propertyCount = 0; for (ModelProperty modelProperty : this.propertyArray) { if (!modelProperty.getTargetType().isArray()) { parts[propertyCount++] = new ComparatorPart(modelProperty.getId()); } } if (propertyCount == 0) { return ReferenceEqualityComparator.getInstance(); } if (propertyCount != parts.length) { ComparatorPart[] newParts = new ComparatorPart[propertyCount]; System.arraycopy(parts, 0, newParts, 0, propertyCount); parts = newParts; } return this.getEqualityComparator(parts); }
if (endpoint.getAssociationProperty().getOppositeProperty() == null) { return;
public AssociatedKeyedReference(ObjectModel objectModel, int propertyId) { Arguments.mustNotBeNull("objectModel", objectModel); this.owner = objectModel.getOwner(); ModelProperty property = objectModel.getModelClass().getProperty(propertyId); if (property.getAssociationType() != AssociationType.KEYED_REFERENCE) { throw new IllegalArgumentException( CommonMessages.createFailedBecausePropertyMustBe( this.getClass(), property, KeyedReference.class ) ); } if (property.getOppositeProperty() == null) { throw new IllegalArgumentException( CommonMessages.createFailedBecauseOfunidirectionalAssociation( this.getClass(), KeyedReference.class, property ) ); } this.associationProperty = property; this.oppositePropertyId = property.getOppositeProperty().getId(); }
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(((ObjectModelProvider)this.endpoint.getOwner()).objectModel()); out.writeInt(this.endpoint.getAssociationProperty().getId()); out.writeObject(this.endpoint.getBase(true)); }
if (modelProperty.getPropertyType() != PropertyType.SCALAR) { throw new IllegalArgumentException( mustBeScalarAttribute( propertyIdSet.add(modelProperty.getId());
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.oppositePropertyId = this.associationProperty.getOppositeProperty().getId(); } }
map.put(getModelProperty(modelClass, attribute).getId(), flags); continue; int propertyId = modelProperty.getId(); Integer flags = map.get(propertyId); if (flags == null) { if (!objectModel.isDisabled(modelProperty.getId())) { builder = lazyAppend( builder, if (modelProperty.getAssociationType() == AssociationType.NONE) { propertyValue = objectModel.get(propertyId); } else {