public Property getMappedForm() { return classMapping.getEntity().getIdentity().getMapping().getMappedForm(); } };
public DocumentCollectionMapping(PersistentEntity entity, MappingContext context) { super(entity, context); if(entity.isExternal()) { this.mappedForm = null; } else { this.mappedForm = (Collection) context.getMappingFactory().createMappedForm(DocumentPersistentEntity.this); } } @Override
@Override public void setCanInitializeEntities(boolean canInitializeEntities) { super.setCanInitializeEntities(canInitializeEntities); syntaxStrategy.setCanExpandMappingContext(false); }
/** * @return The inverse side or null if the association is not bidirectional */ public Association getInverseSide() { final PersistentProperty associatedProperty = associatedEntity.getPropertyByName(referencedPropertyName); if (associatedProperty == null) return null; if (associatedProperty instanceof Association) { return (Association) associatedProperty; } throw new IllegalMappingException("The inverse side [" + associatedEntity.getName() + "." + associatedProperty.getName() + "] of the association [" + getOwner().getName() + "." + getName() + "] is not valid. Associations can only map to other entities and collection types."); }
@Override public void convertArguments(PersistentEntity persistentEntity) { ConversionService conversionService = persistentEntity .getMappingContext().getConversionService(); String propertyName = this.propertyName; PersistentProperty<?> prop = persistentEntity .getPropertyByName(propertyName); Object[] arguments = this.arguments; convertArgumentsForProp(persistentEntity, prop, propertyName, arguments, conversionService); } }
@Override protected String getNativePropertyKey(PersistentProperty prop) { PropertyMapping<KeyValue> pm = prop.getMapping(); String propKey = null; if (pm.getMappedForm()!=null) { propKey = pm.getMappedForm().getKey(); } if (propKey == null) { propKey = prop.getName(); } return propKey; }
@Override public Class getPropertyType(String name) { PersistentProperty property = persistentEntity.getPropertyByName(name); if(property != null) { return property.getType(); } return null; }
public NativeEntryEntityPersister(MappingContext mappingContext, PersistentEntity entity, Session session, ApplicationEventPublisher publisher) { super(mappingContext, entity, session, publisher); classMapping = entity.getMapping(); }
public PersistentEntity getRootEntity() { PersistentEntity root = this; PersistentEntity parent = getParentEntity(); while (parent != null) { if(!parent.isInitialized()) { parent.initialize(); } root = parent; parent = parent.getParentEntity(); } return root; }
public HibernatePersistentEntity(Class javaClass, final MappingContext context) { super(javaClass, context); this.classMapping = new AbstractClassMapping<Mapping>(this, context) { Mapping mappedForm = (Mapping) context.getMappingFactory().createMappedForm(HibernatePersistentEntity.this); @Override public PersistentEntity getEntity() { return HibernatePersistentEntity.this; } @Override public Mapping getMappedForm() { return mappedForm; } }; }
/** * Obtains the identifier name to use. Subclasses can override to provide their own strategy for looking up an identifier name * @param cm The ClassMapping instance * @return The identifier name */ protected String getIdentifierName(ClassMapping cm) { return cm.getIdentifier().getIdentifierName()[0]; }
@Override public IdentityMapping getIdentifier() { if (identityMapping == null) { identityMapping = context.getMappingFactory().createIdentityMapping(this); } return identityMapping; } }
public AbstractClassMapping(PersistentEntity entity, MappingContext context) { this.entity = entity; this.context = context; MappingConfigurationStrategy syntaxStrategy = context.getMappingSyntaxStrategy(); this.identifierMapping = syntaxStrategy.getIdentityMapping(this); }
public PersistentEntity createEmbeddedEntity(Class type) { EmbeddedPersistentEntity embedded = new EmbeddedPersistentEntity(type, this); embedded.initialize(); return embedded; }
protected PersistentProperty resolveIdentifier() { return context.getMappingSyntaxStrategy().getIdentity(javaClass, context); }
/** * Obtains the identity mapping for the specified class mapping * * @param classMapping The class mapping * @return The identity mapping */ public IdentityMapping getIdentityMapping(ClassMapping classMapping) { return propertyFactory.createIdentityMapping(classMapping); }
public Property getMappedForm() { return classMapping.getEntity().getIdentity().getMapping().getMappedForm(); } };
@Override public void convertArguments(PersistentEntity persistentEntity) { ConversionService conversionService = persistentEntity .getMappingContext().getConversionService(); PersistentProperty<?> prop = persistentEntity .getPropertyByName(propertyName); convertArgumentsForProp(persistentEntity, prop, propertyName, arguments, conversionService); }
protected String getIdentifierName(ClassMapping cm) { final IdentityMapping identifier = cm.getIdentifier(); if (identifier != null && identifier.getIdentifierName() != null) { String[] identifierName = identifier.getIdentifierName(); if(identifierName.length > 0) { return identifierName[0]; } } return null; }
public String[] getIdentifierName() { PersistentProperty identity = classMapping.getEntity().getIdentity(); String propertyName = identity != null ? identity.getMapping().getMappedForm().getName() : null; if(propertyName != null) { return new String[] { propertyName }; } else { return new String[] { IDENTITY_PROPERTY }; } }