Refine search
final Value value = pc.getRecursiveProperty( reducedName ).getValue(); final ToOne toOne = (ToOne) value; final PersistentClass referencedPc = context.getMetadataCollector() .getEntityBinding( toOne.getReferencedEntityName() ); if ( toOne.getReferencedPropertyName() != null ) { try { parentPropItr = ( (Component) referencedPc.getRecursiveProperty( toOne.getReferencedPropertyName() ) .getValue() ).getPropertyIterator(); if ( referencedPc.getIdentifierMapper() == null ) { parentPropItr = ( (Component) referencedPc.getIdentifierProperty() .getValue() ).getPropertyIterator();
public boolean isLazy() { if ( value instanceof ToOne ) { // both many-to-one and one-to-one are represented as a // Property. EntityPersister is relying on this value to // determine "lazy fetch groups" in terms of field-level // interception. So we need to make sure that we return // true here for the case of many-to-one and one-to-one // with lazy="no-proxy" // // * impl note - lazy="no-proxy" currently forces both // lazy and unwrap to be set to true. The other case we // are extremely interested in here is that of lazy="proxy" // where lazy is set to true, but unwrap is set to false. // thus we use both here under the assumption that this // return is really only ever used during persister // construction to determine the lazy property/field fetch // groupings. If that assertion changes then this check // needs to change as well. Partially, this is an issue with // the overloading of the term "lazy" here... ToOne toOneValue = ( ToOne ) value; return toOneValue.isLazy() && toOneValue.isUnwrapProxy(); } return lazy; }
toOne.setLazy( !( lazy.value() == LazyToOneOption.FALSE ) ); toOne.setUnwrapProxy( ( lazy.value() == LazyToOneOption.NO_PROXY ) ); toOne.setLazy( fetchType == FetchType.LAZY ); toOne.setUnwrapProxy( false ); toOne.setFetchMode( FetchMode.JOIN ); toOne.setLazy( false ); toOne.setUnwrapProxy( false ); toOne.setFetchMode( FetchMode.SELECT ); toOne.setFetchMode( getFetchMode( fetchType ) );
private Iterator getSubPropertyIterator(PersistentClass pc, String reducedName) { Value value = pc.getRecursiveProperty( reducedName ).getValue(); Iterator parentPropIter; if ( value instanceof Component ) { PersistentClass referencedPc = context.getMetadataCollector().getEntityBinding( toOne.getReferencedEntityName() ); if ( toOne.getReferencedPropertyName() != null ) { try { parentPropIter = ( (Component) referencedPc.getRecursiveProperty( toOne.getReferencedPropertyName() ).getValue() ).getPropertyIterator(); if ( referencedPc.getIdentifierMapper() == null ) { parentPropIter = ( (Component) referencedPc.getIdentifierProperty() .getValue() ).getPropertyIterator();
String referencedPropertyName = null; if ( element instanceof ToOne ) { referencedPropertyName = ( (ToOne) element ).getReferencedPropertyName(); referencedEntityColumns = referencedProperty.getColumnIterator(); while ( properties.hasNext() ) { Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setGeneration( current.getGeneration() ); newProperty.setInsertable( false );
String referencedPropertyName = null; if ( element instanceof ToOne ) { referencedPropertyName = ( (ToOne) element ).getReferencedPropertyName(); referencedEntityColumns = referencedProperty.getColumnIterator(); while ( properties.hasNext() ) { Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setValueGenerationStrategy( current.getValueGenerationStrategy() ); newProperty.setInsertable( false );
for (Property property : properties) { Property clone = BinderHelper.shallowCopy( property ); clone.setInsertable( false ); clone.setUpdateable( false ); clone.setNaturalIdentifier( false ); clone.setGeneration( property.getGeneration() ); embeddedComp.addProperty( clone ); ( (ToOne) value ).setReferencedPropertyName( syntheticPropertyName ); mappings.addUniquePropertyReference( ownerEntity.getEntityName(), syntheticPropertyName );
for (Property property : properties) { Property clone = BinderHelper.shallowCopy( property ); clone.setInsertable( false ); clone.setUpdateable( false ); clone.setNaturalIdentifier( false ); clone.setValueGenerationStrategy( property.getValueGenerationStrategy() ); embeddedComp.addProperty( clone ); ( (ToOne) value ).setReferencedPropertyName( syntheticPropertyName ); ( (ToOne) value ).setReferenceToPrimaryKey( syntheticPropertyName == null ); context.getMetadataCollector().addUniquePropertyReference( ownerEntity.getEntityName(),
@SuppressWarnings("unchecked") public String generateJoinColumnsAnnotation(Property property, Metadata md) { boolean insertable = property.isInsertable(); boolean updatable = property.isUpdateable(); Value value = property.getValue(); int span; Iterator<Selectable> columnIterator; if(property.getValue() instanceof ToOne) { String referencedEntityName = ((ToOne)property.getValue()).getReferencedEntityName(); PersistentClass target = md.getEntityBinding(referencedEntityName); if(target!=null) {
return; if(m2o.isReferenceToPrimaryKey()) { DependantValue dv; Table tableMany = clazzMany.getTable(); set.setKey(dv); } else { set.setReferencedPropertyName(m2o.getReferencedPropertyName()); KeyValue keyVal = (KeyValue) set.getOwner().getReferencedProperty(m2o.getReferencedPropertyName()).getValue(); Property prop = new Property(); prop.setName(relationship.getActualManyPropertyName()); prop.setValue(set);
if ( property.getValue() instanceof Collection ) { Collection collection = ( (Collection) property.getValue() ); Value element = collection.getElement(); if ( element == null ) { mappedByColumns = property.getValue().getColumnIterator(); String referencedPropertyName; if ( value instanceof ToOne ) { referencedPropertyName = ( (ToOne) value ).getReferencedPropertyName();
private String findMappedByProperty(Collection collection, String ownerEntityName, List<String> columnNames, Iterator propertyIterator) { while (propertyIterator.hasNext()) { Property property = (Property) propertyIterator.next(); if (property.getValue() instanceof Component) { String name = findMappedByProperty(collection, ownerEntityName, columnNames, ((Component) property.getValue()).getPropertyIterator()); if (name != null) { return property.getName() + "." + name; } } else if (property.getValue() instanceof ToOne) { ToOne toOne = (ToOne) property.getValue(); if (ownerEntityName.equals(toOne.getReferencedEntityName()) && matches(columnNames, collection.getKey().getColumnIterator())) { return property.getName(); } } } return null; }
private static Property createProperty(final Value value, final String propertyName, final String className, final Element subnode, final Mappings mappings, java.util.Map inheritedMetas) throws MappingException { value.setTypeUsingReflection( className, propertyName ); // this is done here 'cos we might only know the type here (ugly!) // TODO: improve this a lot: if ( value instanceof ToOne ) { ToOne toOne = (ToOne) value; String propertyRef = toOne.getReferencedPropertyName(); if ( propertyRef != null ) { mappings.addUniquePropertyReference( toOne.getReferencedEntityName(), propertyRef ); } } else if ( value instanceof Collection ) { Collection coll = (Collection) value; String propertyRef = coll.getReferencedPropertyName(); // not necessarily a *unique* property reference if ( propertyRef != null ) { mappings.addPropertyReference( coll.getOwnerEntityName(), propertyRef ); } } value.createForeignKey(); Property prop = new Property(); prop.setValue( value ); bindProperty( subnode, prop, mappings, inheritedMetas ); return prop; }
public String getFetchType(Property property) { Value value = property.getValue(); String fetchType = importType( "javax.persistence.FetchType"); boolean lazy = false; if ( value instanceof ToOne ) { lazy = ( (ToOne) value ).isLazy(); } else if ( value instanceof Collection ) { lazy = ( (Collection) value ).isLazy(); } else { //we're not collection neither *toone so we are looking for property fetching lazy = property.isLazy(); } if ( lazy ) { return fetchType + "." + "LAZY"; } else { return fetchType + "." + "EAGER"; } }
private void generateSecondPass(String entityName, Component component) { Iterator properties = component.getPropertyIterator(); while ( properties.hasNext() ) { final Property property = (Property) properties.next(); if ( property.getValue() instanceof ToOne ) { final PropertyAuditingData propertyData = getIdPersistentPropertyAuditingData( property ); final String referencedEntityName = ( (ToOne) property.getValue() ).getReferencedEntityName(); final String prefix = mainGenerator.getVerEntCfg().getOriginalIdPropName() + "." + propertyData.getName(); final IdMapper relMapper; if ( mainGenerator.getEntitiesConfigurations().containsKey( referencedEntityName ) ) { relMapper = mainGenerator.getEntitiesConfigurations().get( referencedEntityName ).getIdMapper(); } else if ( mainGenerator.getNotAuditedEntitiesConfigurations().containsKey( referencedEntityName ) ) { relMapper = mainGenerator.getNotAuditedEntitiesConfigurations().get( referencedEntityName ).getIdMapper(); } else { throw new MappingException( "Unable to locate entity configuration for [" + referencedEntityName + "]" ); } final IdMapper prefixedMapper = relMapper.prefixMappedProperties( prefix + "." ); mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneRelation( prefix, referencedEntityName, prefixedMapper, true, false ); } } }
@Override public String getReferencedEntityName() { return ( (ToOne) value ).getReferencedEntityName(); }
if ( property.getValue() instanceof Collection ) { Collection collection = ( (Collection) property.getValue() ); Value element = collection.getElement(); if ( element == null ) { mappedByColumns = property.getValue().getMappedColumns(); String referencedPropertyName; if ( value instanceof ToOne ) { referencedPropertyName = ( (ToOne) value ).getReferencedPropertyName();
referencedUkAttributeName = valueMapping.getReferencedPropertyName(); if ( valueMapping.getReferencedEntityName() == null ) { throw new MappingException( "Name of target entity of a to-one association not known : " + navigableRole.getFullPath() .findEntityDescriptor( valueMapping.getReferencedEntityName() ); if ( entityDescriptor == null ) { throw new MappingException( "Cannot create SingularPersistentAttributeEntity [%s] : could not locate target entity descriptor [%s]", navigableRole.getFullPath(), valueMapping.getReferencedEntityName() if ( valueMapping.getForeignKey() != null ) { this.foreignKey = context.getDatabaseObjectResolver().resolveForeignKey( valueMapping.getForeignKey() );
private static void initLaziness( Element node, ToOne fetchable, Mappings mappings, boolean defaultLazy ) { if ( "no-proxy".equals( node.attributeValue( "lazy" ) ) ) { fetchable.setUnwrapProxy(true); fetchable.setLazy(true); //TODO: better to degrade to lazy="false" if uninstrumented } else { initLaziness(node, fetchable, mappings, "proxy", defaultLazy); } }
) { if ( "no-proxy".equals( node.attributeValue( "lazy" ) ) ) { fetchable.setUnwrapProxy(true); fetchable.setLazy(true); .getClassName(), subnode, mappings, inheritedMetas ); if ( !mutable ) property.setUpdateable(false); if ( naturalId ) property.setNaturalIdentifier(true); persistentClass.addProperty( property ); if ( uniqueKey!=null ) uniqueKey.addColumns( property.getColumnIterator() );