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);
entity.addProperty(prop);
}
}