Results 1 to 4 of 4

Thread: versionField

  1. #1

    Default versionField

    Is this required for RooEntities. The doc does not say it s mandatory.
    I would like to know if I need this for Roo 1.1.1

    Thanks,


    fm

  2. #2
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    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.
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  3. #3

    Default DBRE won't let it be optional

    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.

  4. #4
    Join Date
    Dec 2005
    Posts
    930

    Default

    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.
    Alan
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •