@Override protected List<EntityMapping> doCreateMapping(Class<?> entityType) { ArrayList<EntityMapping> mappings = new ArrayList<EntityMapping>(); IdentityManaged identityManaged = entityType.getAnnotation(IdentityManaged.class); if (identityManaged == null) { throw MESSAGES.configJpaStoreRequiredMappingAnnotation(entityType, IdentityManaged.class); } Class<? extends AttributedType>[] supportedTypes = null; if (identityManaged != null) { supportedTypes = identityManaged.value(); } else { supportedTypes = new Class[]{AttributedType.class}; } for (Class<?> supportedType: supportedTypes) { mappings.add(configure(supportedType, entityType)); } return mappings; }
@Override protected List<EntityMapping> doCreateMapping(Class<?> entityType) { ArrayList<EntityMapping> mappings = new ArrayList<EntityMapping>(); IdentityManaged identityManaged = entityType.getAnnotation(IdentityManaged.class); if (identityManaged == null) { throw MESSAGES.configJpaStoreRequiredMappingAnnotation(entityType, IdentityManaged.class); } Class<? extends AttributedType>[] supportedTypes = null; if (identityManaged != null) { supportedTypes = identityManaged.value(); } else { supportedTypes = new Class[]{AttributedType.class}; } for (Class<?> supportedType: supportedTypes) { mappings.add(configure(supportedType, entityType)); } return mappings; }
@Override public void setValue(Object instance, Object value) { IdentityManaged identityManaged = (IdentityManaged) ownerProperty.getJavaClass().getAnnotation(IdentityManaged.class); for (Class<?> ownerType : identityManaged.value()) { Property<Object> ownerProperty = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new TypedPropertyCriteria(ownerType, TypedPropertyCriteria.MatchOption.ALL)) .getFirstResult(); if (ownerProperty != null && ownerType.isInstance(value)) { ownerProperty.setValue(instance, value); return; } } } }, ownerProperty);
@Override public void setValue(Object instance, Object value) { IdentityManaged identityManaged = (IdentityManaged) ownerProperty.getJavaClass().getAnnotation(IdentityManaged.class); for (Class<?> ownerType : identityManaged.value()) { Property<Object> ownerProperty = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new TypedPropertyCriteria(ownerType, TypedPropertyCriteria.MatchOption.ALL)) .getFirstResult(); if (ownerProperty != null && ownerType.isInstance(value)) { ownerProperty.setValue(instance, value); return; } } } }, ownerProperty);
@Override public Object getValue(Object instance) { IdentityManaged identityManaged = (IdentityManaged) ownerProperty.getJavaClass().getAnnotation(IdentityManaged.class); if (identityManaged != null) { for (Class<?> ownerType : identityManaged.value()) { Property<Object> ownerProperty = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new TypedPropertyCriteria(ownerType, TypedPropertyCriteria.MatchOption.ALL)) .getFirstResult(); if (ownerProperty != null && !ownerProperty.getJavaClass().equals(instance.getClass())) { return ownerProperty.getValue(instance); } } } return instance; }
@Override public Object getValue(Object instance) { IdentityManaged identityManaged = (IdentityManaged) ownerProperty.getJavaClass().getAnnotation(IdentityManaged.class); if (identityManaged != null) { for (Class<?> ownerType : identityManaged.value()) { Property<Object> ownerProperty = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new TypedPropertyCriteria(ownerType, TypedPropertyCriteria.MatchOption.ALL)) .getFirstResult(); if (ownerProperty != null && !ownerProperty.getJavaClass().equals(instance.getClass())) { return ownerProperty.getValue(instance); } } } return instance; }
@Override protected List<EntityMapping> doCreateMapping(final Class<?> entityType) { List<EntityMapping> mappings = new ArrayList<EntityMapping>(); Class<?> mappedClass = Relationship.class; IdentityManaged identityManaged = entityType.getAnnotation(IdentityManaged.class); if (identityManaged != null) { Class<? extends AttributedType>[] value = identityManaged.value(); if (value.length > 1) { throw new IdentityManagementException("Relationship identity mappings must map to a single @IdentityManaged type."); } mappedClass = value[0]; } EntityMapping entityMapping = new EntityMapping(mappedClass); entityMapping.addMappedProperty(getAnnotatedProperty(RelationshipDescriptor.class, entityType)); entityMapping.addMappedProperty(getAnnotatedProperty(RelationshipMember.class, entityType)); entityMapping.addOwnerProperty(entityType); mappings.add(entityMapping); return mappings; } }
@Override protected List<EntityMapping> doCreateMapping(final Class<?> entityType) { List<EntityMapping> mappings = new ArrayList<EntityMapping>(); Class<?> mappedClass = Relationship.class; IdentityManaged identityManaged = entityType.getAnnotation(IdentityManaged.class); if (identityManaged != null) { Class<? extends AttributedType>[] value = identityManaged.value(); if (value.length > 1) { throw new IdentityManagementException("Relationship identity mappings must map to a single @IdentityManaged type."); } mappedClass = value[0]; } EntityMapping entityMapping = new EntityMapping(mappedClass); entityMapping.addMappedProperty(getAnnotatedProperty(RelationshipDescriptor.class, entityType)); entityMapping.addMappedProperty(getAnnotatedProperty(RelationshipMember.class, entityType)); entityMapping.addOwnerProperty(entityType); mappings.add(entityMapping); return mappings; } }