rootEntityDescriptor.addProperty( prop );
property.setValue( mapper ); property.setPropertyAccessorName( "embedded" ); rootEntityDescriptor.addProperty( property );
private void bindVersionProperty(Table table, TableIdentifier identifier, Column column, RootClass rc, Set<Column> processed, Mapping mapping) { processed.add(column); String propertyName = revengStrategy.columnToPropertyName( identifier, column.getName() ); Property property = bindBasicProperty(BinderUtils.makeUnique(rc, propertyName), table, column, processed, mapping); rc.addProperty(property); rc.setVersion(property); rc.setOptimisticLockStyle(OptimisticLockStyle.VERSION); log.debug("Column " + column.getName() + " will be used for <version>/<timestamp> columns in " + identifier); }
private void bindVersionProperty(Table table, TableIdentifier identifier, Column column, RootClass rc, Set<Column> processed, Mapping mapping) { processed.add(column); String propertyName = revengStrategy.columnToPropertyName( identifier, column.getName() ); Property property = bindBasicProperty(BinderUtils.makeUnique(rc, propertyName), table, column, processed, mapping); rc.addProperty(property); rc.setVersion(property); rc.setOptimisticLockStyle(OptimisticLockStyle.VERSION); log.debug("Column " + column.getName() + " will be used for <version>/<timestamp> columns in " + identifier); }
/** * @param table * @param rc * @param primaryKey */ private void bindColumnsToProperties(Table table, RootClass rc, Set<Column> processedColumns, Mapping mapping) { for (Iterator<?> iterator = table.getColumnIterator(); iterator.hasNext();) { Column column = (Column) iterator.next(); if ( !processedColumns.contains(column) ) { checkColumn(column); String propertyName = RevEngUtils.getColumnToPropertyNameInRevengStrategy( revengStrategy, table, defaultCatalog, defaultSchema, column.getName()); Property property = bindBasicProperty( BinderUtils.makeUnique(rc,propertyName), table, column, processedColumns, mapping ); rc.addProperty(property); } } }
/** * @param table * @param rc * @param primaryKey */ private void bindColumnsToProperties(Table table, RootClass rc, Set<Column> processedColumns, Mapping mapping) { for (Iterator<?> iterator = table.getColumnIterator(); iterator.hasNext();) { Column column = (Column) iterator.next(); if ( !processedColumns.contains(column) ) { checkColumn(column); String propertyName = RevEngUtils.getColumnToPropertyNameInRevengStrategy( revengStrategy, table, defaultCatalog, defaultSchema, column.getName()); Property property = bindBasicProperty( BinderUtils.makeUnique(rc,propertyName), table, column, processedColumns, mapping ); rc.addProperty(property); } } }
private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings, String name, RootClass entity, java.util.Map inheritedMetas) { String propertyName = subnode.attributeValue( "name" ); SimpleValue val = new SimpleValue( table ); bindSimpleValue( subnode, val, false, propertyName, mappings ); if ( !val.isTypeSpecified() ) { val.setTypeName( "version".equals( name ) ? "integer" : "timestamp" ); } Property prop = new Property(); prop.setValue( val ); bindProperty( subnode, prop, mappings, inheritedMetas ); makeVersion( subnode, val ); entity.setVersion( prop ); entity.addProperty( prop ); }
entity.addProperty( prop );
entity.addProperty( prop );
private static void bindVersion(GrailsDomainClassProperty version, RootClass entity, Mappings mappings, String sessionFactoryBeanName) { SimpleValue val = new SimpleValue(mappings, entity.getTable()); bindSimpleValue(version, null, val, EMPTY_PATH, mappings, sessionFactoryBeanName); if (val.isTypeSpecified()) { if (!(val.getType() instanceof IntegerType || val.getType() instanceof LongType || val.getType() instanceof TimestampType)) { LOG.warn("Invalid version class specified in " + version.getDomainClass().getClazz().getName() + "; must be one of [int, Integer, long, Long, Timestamp, Date]. Not mapping the version."); return; } } else { val.setTypeName("version".equals(version.getName()) ? "integer" : "timestamp"); } Property prop = new Property(); prop.setValue(val); bindProperty(version, prop, mappings); val.setNullValue("undefined"); entity.setVersion(prop); entity.addProperty(prop); }
protected void bindVersion(PersistentProperty version, RootClass entity, Mappings mappings, String sessionFactoryBeanName) { if(version != null) { SimpleValue val = new SimpleValue(mappings, entity.getTable()); bindSimpleValue(version, null, val, EMPTY_PATH, mappings, sessionFactoryBeanName); if (val.isTypeSpecified()) { if (!(val.getType() instanceof IntegerType || val.getType() instanceof LongType || val.getType() instanceof TimestampType)) { LOG.warn("Invalid version class specified in " + version.getOwner().getName() + "; must be one of [int, Integer, long, Long, Timestamp, Date]. Not mapping the version."); return; } } else { val.setTypeName("version".equals(version.getName()) ? "integer" : "timestamp"); } Property prop = new Property(); prop.setValue(val); bindProperty(version, prop, mappings); val.setNullValue("undefined"); entity.setVersion(prop); entity.setOptimisticLockMode(0); // 0 is to use version column entity.addProperty(prop); } }
} else if (revengStrategy.isOneToOne(foreignKey)){ Property property = bindOneToOne(rc, foreignKey.getReferencedTable(), foreignKey, processedColumns, true, false); rc.addProperty(property); } else { boolean isUnique = isUniqueReference(foreignKey); ); rc.addProperty(property);
} else if (revengStrategy.isOneToOne(foreignKey)){ Property property = bindOneToOne(rc, foreignKey.getReferencedTable(), foreignKey, processedColumns, true, false); rc.addProperty(property); } else { boolean isUnique = isUniqueReference(foreignKey); ); rc.addProperty(property);
clazz.addProperty(prop); prop.setPropertyAccessorName(mappings.getDefaultAccess());
Column col = createColumn(mappings, tab, column); if(col != null) { clazz.addProperty(createProperty(column, col.getValue()));
clazz.addProperty(prop); prop.setPropertyAccessorName(mappings.getDefaultAccess());
@Override protected void afterMetadataBuilt(Metadata metadata) { if (addVersions) { for (PersistentClass clazz : metadata.getEntityBindings()) { if (clazz.getVersion() != null) { continue; } try { clazz.getMappedClass().getMethod("getVersion"); clazz.getMappedClass().getMethod("setVersion", long.class); } catch (NoSuchMethodException e) { continue; } RootClass rootClazz = clazz.getRootClass(); Property versionProperty = new Property(); versionProperty.setName("version"); SimpleValue value = new SimpleValue((MetadataImplementor) metadata, rootClazz.getTable()); value.setTypeName("long"); Column column = new Column(); column.setValue(value); column.setName("version"); value.addColumn(column); rootClazz.getTable().addColumn(column); versionProperty.setValue(value); rootClazz.setVersion(versionProperty); rootClazz.addProperty(versionProperty); } } }
rootEntityDescriptor.addProperty( prop );
property.setValue( mapper ); property.setPropertyAccessorName( "embedded" ); rootEntityDescriptor.addProperty( property );