[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2907) ability to apply 'generation strategy' to generated properties

Steve Ebersole (JIRA) noreply at atlassian.com
Tue Oct 23 10:12:38 EDT 2007


ability to apply 'generation strategy' to generated properties
--------------------------------------------------------------

                 Key: HHH-2907
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2907
             Project: Hibernate3
          Issue Type: New Feature
          Components: core
            Reporter: Steve Ebersole
            Assignee: Steve Ebersole
            Priority: Minor
             Fix For: 3.3


Currently, the support for generated properties allows only for db-generated values (ala triggers etc).  Would be great to allow the user to provide a seperate (optional) strategy for generating the generated values.

It would be nice to have a generic solution, which we can build on top of for the more common use cases.  Also, we may need to use a name other than 'generated' in the annotations to avoid conflicts with the current @Generated annotation; for now lets use the term @Dynamic.

Consider mapping a 'created timestamp' column.  Currently, provided we are using a trigger, that would look like:
@Generated(INSERT) Date created;

The strategy here (^^) is implicitly 'db', as the db is taking care of the generation.  In the most generic form, that could be written as:
@Dynamic(time=INSERT,strategy=DB) Date created;

Additionally, since this is such a common case, also allow this:
@CreationTimestamp Date created;

The final form would also allow the definition of strategies.  As an example, consider:
@CreationTimestamp(strategy=NOW) Date created;

Here we are not relying on the db to generate the value, but are explicitly telling Hibernate to do it (basically 'use the current timestamp to generate a value here whenever we do an insert').


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list