Hi,
I've got a sparkly new oracle database and I'm having a go at generating EJB3 entities from the database using the tools in hibernate 3.2.beta8.
It is working ok (in that java classess with the correct EJB3 entity annotations are created) - with one exception...
The @Version annotation is not being created in the entities.
The field we are using for optimistic locking is an int called LOCK_SEQ (the name VERSION is already taken for domain specific stuff).
I have a simple ReverseEngineeringStrategy which includes:
Code:
public static final String COL_OPTIMISTIC_LOCK = "LOCK_SEQ";
public String getOptimisticLockColumnName(TableIdentifier identifier) {
System.out.println("called getOptimisticLockColumnName on table: " + identifier.getName() );
return COL_OPTIMISTIC_LOCK;
}
public boolean useColumnForOptimisticLock(TableIdentifier identifier, String column) {
boolean optLock = false;
System.out.println("into useColumnForOptimisticLock for column: " + column);
if (COL_OPTIMISTIC_LOCK.equals(column)){
optLock = true;
System.out.println("column: " + column + " is used for optimistic lock.");
} else {
System.out.println("column: " + column + " is not used for optimistic lock.");
}
return optLock;
}
I think this is working fine as it also has getTableIdentifierStrategyName and getTableIdentifierProperties which are working as expected.
The tools are run from as an ant task:
Code:
<hibernatetool destdir="${hbm-output-dir}" templatepath="${basedir}/templates/tools-jar">
<jdbcconfiguration
propertyfile="./hibernate.properties"
packagename="com.the.customer.entity.thing"
revengfile="${basedir}/conf/hbm-tools/reveng.xml"
reversestrategy="com.the.customer.bootstrap.reveng.MetadataEntityRevEngStrategy"
detectOptimisticLock="true"
/>
<hbm2java jdk5="true" ejb3="true"></hbm2java>
</hibernatetool>
Is it expected that the @Version annotation should be created under these conditions? If so, any suggestions where I should be looking to see why it isn't? I've had a bit of a look around but seem to be missing the connection between starting to generate a pojo and pulling in the template "fragments" for an ejb3 entity...
Thanks,
Andy