Attribute lockNode = node.attribute( "optimistic-lock" );
property.setOptimisticLocked( lockNode == null || "true".equals( lockNode.getValue() ) );
Attribute generatedNode = node.attribute( "generated" );
String generationName = generatedNode == null ? null : generatedNode.getValue();
PropertyGeneration generation = PropertyGeneration.parse( generationName );
property.setGeneration( generation );
if ( generation == PropertyGeneration.ALWAYS || generation == PropertyGeneration.INSERT ) {
// generated properties can *never* be insertable...
if ( property.isInsertable() ) {
if ( insertNode == null ) {
// insertable simply because that is the user did not specify
// anything; just override it
property.setInsertable( false );
}
else {
// the user specifically supplied insert="true",
// which constitutes an illegal combo
throw new MappingException(
"cannot specify both insert=\"true\" and generated=\"" + generation.getName() +
"\" for property: " +
propName
);
}
}
// properties generated on update can never be updateable...
if ( property.isUpdateable() && generation == PropertyGeneration.ALWAYS ) {
if ( updateNode == null ) {
// updateable only because the user did not specify
// anything; just override it
property.setUpdateable( false );
}
else {
// the user specifically supplied update="true",
// which constitutes an illegal combo
throw new MappingException(
"cannot specify both update=\"true\" and generated=\"" + generation.getName() +
"\" for property: " +
propName
);
}
}