rootEntityDescriptor.setVersion( prop ); rootEntityDescriptor.setDeclaredVersion( prop ); rootEntityDescriptor.addProperty( prop );
Property prop = propertyBinder.makePropertyValueAndBind(); setVersionInformation( property, propertyBinder ); rootClass.setVersion( prop );
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); }
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.setVersion( prop ); entity.addProperty( prop );
entity.setVersion( prop ); entity.addProperty( prop );
entity.setVersion( 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); } }
Property prop = propertyBinder.makePropertyValueAndBind(); propertyBinder.getSimpleValueBinder().setVersion( true ); rootClass.setVersion( prop );
@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); } } }
rootClass.setVersion( prop ); SimpleValue simpleValue = (SimpleValue) prop.getValue(); if ( !simpleValue.isTypeSpecified() ) simpleValue.setTypeName( "integer" );
Property prop = propertyBinder.makePropertyValueAndBind(); setVersionInformation( property, propertyBinder ); rootClass.setVersion( prop );
Property prop = propertyBinder.makePropertyValueAndBind(); setVersionInformation( property, propertyBinder ); rootClass.setVersion( prop );