[hibernate-dev] HHH-2907 : re-purpose org.hibernate.annotations.Generated ?

Gunnar Morling gunnar at hibernate.org
Thu Oct 17 08:24:03 EDT 2013


2013/10/16 Steve Ebersole <steve at hibernate.org>

> Reference : https://hibernate.atlassian.net/browse/HHH-2907
>
> I'd like to get people's feedback on the idea of re-purposing
> org.hibernate.annotations.Generated as discussed on HHH-2907.  As
> mentioned in the Jira, my inclination is to do the re-purposing.
>

Sounds like a good idea to me.

Also, thoughts on the distinction between specifying genertator (Class)
> versus generatorName (String)?
>

I think I'd keep it simple and with one way of specifying the generator and
see how it works. If there is demand for the other option it could be added
later on.

Regarding @CreationTimestamp and the like, would this be a fixed set of
built-in annotations or do you envision a mechanism which also allows for
custom implementations provided by the user?

If so, it might make sense to use @Generated on such custom annotation
types as well to mark them as custom generator annotations (a bit similar
to BV constraints):

    @Generated(
        when = ALWAYS,
        generator = MyCreationTimestampGenerator.class
    }
    public @interface MyCreationTimestamp {
        TemporalType type();
        String source default "vm";
    }

    public class MyCreationTimestampGenerator implements
DynamicValueGenerator<String, MyCreationTimestamp> {

        void initialize(MyCreationTimestamp annotation) {
             //save type etc.
        }

        String generateValue(Session session, Object owner) {
            ...
        }
    }

--Gunnar


> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list