final String explicitName = versioningElement.attributeValue( "name" );
if ( explicitName == null ) {
throw new MappingException( "Mising property name for version/timestamp mapping [" + entityBinding.getEntity().getName() + "]" );
}
entityBinding.getEntity().getOrCreateSingularAttribute( explicitName );
SimpleAttributeBinding versionBinding = entityBinding.makeSimpleAttributeBinding( explicitName );
basicAttributeBinding( versioningElement, versionBinding );
if ( versionBinding.getHibernateTypeDescriptor().getTypeName() == null ) {
if ( isVersion ) {
versionBinding.getHibernateTypeDescriptor().setTypeName( "integer" );
}
else {
final String tsSource = versioningElement.attributeValue( "source" );
if ( "db".equals( tsSource ) ) {
versionBinding.getHibernateTypeDescriptor().setTypeName( "dbtimestamp" );
}
else {
versionBinding.getHibernateTypeDescriptor().setTypeName( "timestamp" );
}
}
}
// Handle the relational portion of the binding...
Value discriminatorValue = processValues( versioningElement, entityBinding.getBaseTable(), explicitName );
versionBinding.setValue( discriminatorValue );
// for version properties marked as being generated, make sure they are "always"
// generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
// but just to make sure...
if ( versionBinding.getGeneration() == PropertyGeneration.INSERT ) {
throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
}
entityBinding.setVersioningValueBinding( versionBinding );
}