Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setValueGenerationStrategy( current.getValueGenerationStrategy() ); newProperty.setInsertable( 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.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; }
Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setGeneration( current.getGeneration() ); newProperty.setInsertable( 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 String[] getCascadeTypes(Property property) { StringTokenizer st = new StringTokenizer( property.getCascade(), ", ", false ); List<String> types = new ArrayList<String>(); while ( st.hasMoreElements() ) { String element = ( (String) st.nextElement() ).toLowerCase(); if ( "persist".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType" ) + ".PERSIST"); } else if ( "merge".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".MERGE"); } else if ( "delete".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".REMOVE"); } else if ( "refresh".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".REFRESH"); } else if ( "all".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".ALL"); } } return (String[]) types.toArray( new String[types.size()] ); }
public String[] getCascadeTypes(Property property) { StringTokenizer st = new StringTokenizer( property.getCascade(), ", ", false ); List<String> types = new ArrayList<String>(); while ( st.hasMoreElements() ) { String element = ( (String) st.nextElement() ).toLowerCase(); if ( "persist".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType" ) + ".PERSIST"); } else if ( "merge".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".MERGE"); } else if ( "delete".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".REMOVE"); } else if ( "refresh".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".REFRESH"); } else if ( "all".equals( element ) ) { types.add(importType( "javax.persistence.CascadeType") + ".ALL"); } } return (String[]) types.toArray( new String[types.size()] ); }
public String getHibernateCascadeTypeAnnotation(Property property) { StringTokenizer st = new StringTokenizer( property.getCascade(), ", ", false ); String cascadeType = null; StringBuffer cascade = new StringBuffer();
public String getHibernateCascadeTypeAnnotation(Property property) { StringTokenizer st = new StringTokenizer( property.getCascade(), ", ", false ); String cascadeType = null; StringBuffer cascade = new StringBuffer();
@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()); }
Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setGeneration( current.getGeneration() ); newProperty.setInsertable( false );
property.setCascade( hibernateProperty.getCascade() ); property.setCollection( type.isCollectionType() );
@Test public void testOneToOne() throws MalformedURLException, ClassNotFoundException { 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 person = metadata.getEntityBinding("Person"); PersistentClass addressPerson = metadata.getEntityBinding("AddressPerson"); PersistentClass addressMultiPerson = metadata.getEntityBinding("AddressMultiPerson"); PersistentClass multiPerson = metadata.getEntityBinding("MultiPerson"); assertPropertyNotExists(addressPerson, "person", "should be removed by reveng.xml"); assertPropertyNotExists(person, "addressPerson", "should be removed by reveng.xml"); Property property = addressMultiPerson.getProperty("renamedOne"); Assert.assertNotNull(property); Assert.assertEquals("Casade should be set to delete by reveng.xml", "delete", property.getCascade()); assertPropertyNotExists(multiPerson, "addressMultiPerson", "should not be there"); Property o2o = multiPerson.getProperty("renamedInversedOne"); Assert.assertNotNull(o2o); Assert.assertEquals("update", o2o.getCascade()); Assert.assertEquals("JOIN", o2o.getValue().getFetchMode().toString()); }
Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setGeneration( current.getGeneration() ); newProperty.setInsertable( false );
@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()); }
public Property shallowCopy() { Property clone = new Property( context ); clone.setCascade( getCascade() ); clone.setInsertable( isInsertable() ); clone.setLazy( isLazy() ); clone.setName( getName() ); clone.setNaturalIdentifier( isNaturalIdentifier() ); clone.setOptimisticLocked( isOptimisticLocked() ); clone.setOptional( isOptional() ); clone.setPersistentClass( (PersistentClass) getEntity() ); clone.setPropertyAccessorName( getPropertyAccessorName() ); clone.setSelectable( isSelectable() ); clone.setUpdateable( isUpdateable() ); clone.setValue( getValue() ); return clone; } }
.forEach( current -> { Property newProperty = new Property( getBuildingContext() ); newProperty.setCascade( current.getCascade() ); newProperty.setValueGenerationStrategy( current.getValueGenerationStrategy() ); newProperty.setInsertable( 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.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; }
/** * 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; }
/** * 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; }
Property setProperty = employee.getProperty("managedProjects"); Assert.assertNotNull("should be renamed by reveng.xml", setProperty); Assert.assertEquals("delete, update", setProperty.getCascade()); Assert.assertEquals(4, employee.getPropertyClosureSpan()); Assert.assertEquals("id", employee.getIdentifierProperty().getName());