private boolean hasAnyMutableNaturalIdProps() { final Iterator itr = rootEntityDescriptor.getDeclaredPropertyIterator(); while ( itr.hasNext() ) { final Property prop = (Property) itr.next(); if ( prop.isNaturalIdentifier() && prop.isUpdateable() ) { return true; } } return false; }
@Override public boolean[] getColumnUpdateability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); boolean[] chunk = prop.getValue().getColumnUpdateability(); if ( prop.isUpdateable() ) { System.arraycopy(chunk, 0, result, i, chunk.length); } i+=chunk.length; } return result; }
protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties) throws MappingException { while ( properties.hasNext() ) { Property prop = (Property) properties.next(); if ( prop.getValue() instanceof Component ) { //TODO: remove use of instanceof! Component component = (Component) prop.getValue(); checkPropertyColumnDuplication( distinctColumns, component.getPropertyIterator() ); } else { if ( prop.isUpdateable() || prop.isInsertable() ) { checkColumnDuplication( distinctColumns, prop.getColumnIterator() ); } } } }
/** * @deprecated See mainly {@link #buildEntityBasedAttribute} */ @Deprecated public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) { final Type type = property.getValue().getType(); // we need to dirty check collections, since they can cause an owner // version number increment // we need to dirty check many-to-ones with not-found="ignore" in order // to update the cache (not the database), since in this case a null // entity reference can lose information boolean alwaysDirtyCheck = type.isAssociationType() && ( (AssociationType) type ).isAlwaysDirtyChecked(); return new StandardProperty( property.getName(), type, lazyAvailable && property.isLazy(), property.isInsertable(), property.isUpdateable(), property.getValueGenerationStrategy(), property.isOptional(), alwaysDirtyCheck || property.isUpdateable(), property.isOptimisticLocked(), property.getCascadeStyle(), property.getValue().getFetchMode() ); }
if ( property.isUpdateable() && generationTiming == GenerationTiming.ALWAYS ) { log.debugf( "Property [%s] specified ALWAYS generation, setting updateable to false : %s",
.setLazy( lazy ) .setInsertable( property.isInsertable() ) .setUpdateable( property.isUpdateable() ) .setValueGenerationStrategy( property.getValueGenerationStrategy() ) .setNullable( property.isOptional() ) .setDirtyCheckable( property.isUpdateable() && !lazy ) .setVersionable( property.isOptimisticLocked() ) .setCascadeStyle( property.getCascadeStyle() )
.setLazy( lazyAvailable && property.isLazy() ) .setInsertable( property.isInsertable() ) .setUpdateable( property.isUpdateable() ) .setValueGenerationStrategy( property.getValueGenerationStrategy() ) .setNullable( property.isOptional() ) .setDirtyCheckable( alwaysDirtyCheck || property.isUpdateable() ) .setVersionable( property.isOptimisticLocked() ) .setCascadeStyle( property.getCascadeStyle() ) .setLazy( lazyAvailable && property.isLazy() ) .setInsertable( property.isInsertable() ) .setUpdateable( property.isUpdateable() ) .setValueGenerationStrategy( property.getValueGenerationStrategy() ) .setNullable( property.isOptional() ) .setDirtyCheckable( alwaysDirtyCheck || property.isUpdateable() ) .setVersionable( property.isOptimisticLocked() ) .setCascadeStyle( property.getCascadeStyle() ) .setLazy( lazyAvailable && property.isLazy() ) .setInsertable( property.isInsertable() ) .setUpdateable( property.isUpdateable() ) .setValueGenerationStrategy( property.getValueGenerationStrategy() ) .setNullable( property.isOptional() ) .setDirtyCheckable( alwaysDirtyCheck || property.isUpdateable() ) .setVersionable( property.isOptimisticLocked() ) .setCascadeStyle( property.getCascadeStyle() )
if ( prop.isUpdateable() ) { foundUpdateableNaturalIdProperty = true;
/** * create a property copy reusing the same value */ public static Property shallowCopy(Property property) { Property clone = new Property(); clone.setCascade( property.getCascade() ); clone.setInsertable( property.isInsertable() ); clone.setLazy( property.isLazy() ); clone.setName( property.getName() ); clone.setNaturalIdentifier( property.isNaturalIdentifier() ); clone.setOptimisticLocked( property.isOptimisticLocked() ); clone.setOptional( property.isOptional() ); clone.setPersistentClass( property.getPersistentClass() ); clone.setPropertyAccessorName( property.getPropertyAccessorName() ); clone.setSelectable( property.isSelectable() ); clone.setUpdateable( property.isUpdateable() ); clone.setValue( property.getValue() ); return clone; }
@Override public boolean isIncludedInDirtyChecking() { return isUpdateable() || shouldAlwaysDirtyCheck(); }
public boolean[] getColumnUpdateability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); boolean[] chunk = prop.getValue().getColumnUpdateability(); if ( prop.isUpdateable() ) { System.arraycopy(chunk, 0, result, i, chunk.length); } i+=chunk.length; } return result; }
private boolean hasAnyMutableNaturalIdProps() { final Iterator itr = rootEntityDescriptor.getDeclaredPropertyIterator(); while ( itr.hasNext() ) { final Property prop = (Property) itr.next(); if ( prop.isNaturalIdentifier() && prop.isUpdateable() ) { return true; } } return false; }
/** * create a property copy reusing the same value */ public static Property shallowCopy(Property property) { Property clone = new Property(); clone.setCascade( property.getCascade() ); clone.setInsertable( property.isInsertable() ); clone.setLazy( property.isLazy() ); clone.setName( property.getName() ); clone.setNodeName( property.getNodeName() ); clone.setNaturalIdentifier( property.isNaturalIdentifier() ); clone.setOptimisticLocked( property.isOptimisticLocked() ); clone.setOptional( property.isOptional() ); clone.setPersistentClass( property.getPersistentClass() ); clone.setPropertyAccessorName( property.getPropertyAccessorName() ); clone.setSelectable( property.isSelectable() ); clone.setUpdateable( property.isUpdateable() ); clone.setValue( property.getValue() ); return clone; }
public boolean[] getColumnUpdateability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); boolean[] chunk = prop.getValue().getColumnUpdateability(); if ( prop.isUpdateable() ) { System.arraycopy(chunk, 0, result, i, chunk.length); } i+=chunk.length; } return result; }
public boolean[] getColumnUpdateability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); boolean[] chunk = prop.getValue().getColumnUpdateability(); if ( prop.isUpdateable() ) { System.arraycopy(chunk, 0, result, i, chunk.length); } i+=chunk.length; } return result; }
public boolean[] getColumnUpdateability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); boolean[] chunk = prop.getValue().getColumnUpdateability(); if ( prop.isUpdateable() ) { System.arraycopy(chunk, 0, result, i, chunk.length); } i+=chunk.length; } return result; }
protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties) throws MappingException { while ( properties.hasNext() ) { Property prop = (Property) properties.next(); if ( prop.getValue() instanceof Component ) { //TODO: remove use of instanceof! Component component = (Component) prop.getValue(); checkPropertyColumnDuplication( distinctColumns, component.getPropertyIterator() ); } else { if ( prop.isUpdateable() || prop.isInsertable() ) { checkColumnDuplication( distinctColumns, prop.getColumnIterator() ); } } } }
protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties) throws MappingException { while ( properties.hasNext() ) { Property prop = (Property) properties.next(); if ( prop.getValue() instanceof Component ) { //TODO: remove use of instanceof! Component component = (Component) prop.getValue(); checkPropertyColumnDuplication( distinctColumns, component.getPropertyIterator() ); } else { if ( prop.isUpdateable() || prop.isInsertable() ) { checkColumnDuplication( distinctColumns, prop.getColumnIterator() ); } } } }
@Test public void testManyToOneAttributeDefaults() { Metadata metadata = MetadataDescriptorFactory .createJdbcDescriptor(null, null, true) .createMetadata(); PersistentClass classMapping = metadata.getEntityBinding("Employee"); Property property = classMapping.getProperty("employee"); Assert.assertEquals("none", property.getCascade()); Assert.assertEquals(true, property.isUpdateable()); Assert.assertEquals(true, property.isInsertable()); Assert.assertEquals("SELECT", property.getValue().getFetchMode().toString()); }
@Test public void testManyToOneAttributeOverrides() { OverrideRepository or = new OverrideRepository(); or.addResource(FOREIGN_KEY_TEST_XML); ReverseEngineeringStrategy repository = or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()); Metadata metadata = MetadataDescriptorFactory .createJdbcDescriptor(repository, null, true) .createMetadata(); PersistentClass classMapping = metadata.getEntityBinding("Employee"); Property property = classMapping.getProperty("manager"); Assert.assertEquals("all", property.getCascade()); Assert.assertEquals(false, property.isUpdateable()); Assert.assertEquals(false, property.isInsertable()); Assert.assertEquals("JOIN", property.getValue().getFetchMode().toString()); }