Welcome to the new Spring.io forums!
If this is your first visit, be sure to check out the
by clicking the link above, and for security reasons, use the
forgot password link to reset your password..
You may have to register before you can post: click the register
link above to proceed. To start viewing messages, select the forum that you want to visit
from the selection below.
The use of JPA @Version is optional. It indicates that the table contains versioned data which can be very helpful if you plan to use long transactions and have the possibility of dirty reads. So I would recommend for you to use it but it is an optional feature of JPA.
Roo is forcing a versionField setting in the DBRE addon. If a table dosn't already have a version field, it creates a blank one (versionField="") in createNewManagedEntityFromTable. If you remove it from the generated class file, DBRE adds it back next time updateOrDeleteManagedEntity gets called. The documentation sayys that you can incrementally update the database and run DBRE repeatedly, but that will result in the versionField attribute getting added back every time.
It kind of looks like a bug to me. In updateOrDeleteManagedEntity:
get existing version field attribute
if the version field attribute is not null:
get version field value
if the current table has a column called "version" AND (the version field value is blank OR the version field value equals "version", then remove the versionField attribute.
if the version field attribute is null:
if the current table has a column called "version", remove the version field
if the current table doesn't have a column called "version", add version field attribute with a version value of "".
So, I'm really confused by this logic. If I don't have a version field in my table, I'm always going to get a versionField attribute added to my classes. If there's a version field in the table, but no versionField attribute, then the code will try to delete a non-existent versionField attribute.
If there is no version field in the table the versionField = "" attribute will ensure a version field is not created in the entity ITD. If you don't have this attribute, then a field called "version" will be created and annotated with @Version. You need to leave this in or else create a version field in the table.