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

Paul Benedict (JIRA) noreply at atlassian.com
Wed May 14 02:02:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30183 ] 

Paul Benedict commented on HHH-2907:
------------------------------------

Why not provide a class that can generate a value? I think the design could be similar to the identity generators.

@Generated(INSERT)
@Generator(MyValueGenerator.class)
private Date when;

> 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.0
>
>
> 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