1 Reply Latest reply on Mar 27, 2009 9:45 PM by swd847

    Seam ORACLE with CREATED_BY, CREATED_DATE, MODIFIED_BY and MODIFIED_DATE fields

    shawnwevans

      How do other users deal with CREATEDBY, CREATEDDATE, MODIFIEDBY and MODIFIEDDATE when using seam-gen created CRUD?


      Those are required fields on all my tables, they are not nullable and not editable by the user. I have already set up the database with triggers to populate the DATE fields, but how do I have the CRUD automatically generate the edit pages so those 4 fields are not visible when a user edits a row, especially since in hibernate it identifies it as NOT NULL? And how do I ensure the hibernate object is updated with the DATES from the trigger?

      Also where would I appropriately inject the
      BY fields during INSERT and UPDATE?


      Thank you,
      Shawn

        • 1. Re: Seam ORACLE with CREATED_BY, CREATED_DATE, MODIFIED_BY and MODIFIED_DATE fields
          swd847

          You can use the hibernate.revenge.xml (it may be called seam-gen.revenge.xml) or something to prevent these columns from being generated. You have to do this for every table however, which is a pain.


          You then have to copy and paste the actual mappings into each class, there is an annotation that tells hibernate the database generates these values, I think it is something like @GeneratedValue.


          The way I would do it is to get hold of the templates that seam-gen uses to generate the entities. These used to be in the hibernate tools source, but I am not sure where they are now (I have not looked at seam gen since the 1.0 days, so I am not sure how much it has changed). You can then make changes to these templates and tell the seam-gen buildfile where to find your new improved templates that automatically map these columns correctly.


          If you want to go down this route but are having trouble I can give you step by step instructions if you need it.