[hibernate-dev] overriding target through annotations

Emmanuel Bernard emmanuel at hibernate.org
Wed Nov 29 15:23:29 EST 2006


I'm looking at ANN-422

In HA, the target is usually inferred from the API (generics), and can 
be overridden in all associations through targetEntity ( 
@ManyToOne(targetEntity...) )
currently, you cannot override the target for a component, nor you can 
override it for a <map-key-many-to-many/>

Two solutions

1.
Define a @Target annotation that will work like the targetEntity for 
association and also handle components (@Embedded)
Define a @MapKeyTarget to override the <map-key-many-to-many/> or 
<map-key/> (composite-element) target

2.
Define a @Target annotation that will work like the targetEntity for 
association and also handle components (@Embedded)
add a targetElement to @MapKey and @MapKeyManyToMany annotations

I don't like much 2 because it mixes physical concerns and logical ones, 
but it reduce the amount of needed annotations

Note that I hope the future spec will hopefully handle all cases nicely 
(ie add a targetElement in @Embedded), @MapKey should go to back the 
drawing board from a spec POV so we can think of something clean from 
the begining.

Any preference, or alternative solution?




More information about the hibernate-dev mailing list