Setup: Hibernate 4.0 (JPA 2.0), Java EE 6
I have the following problem: I have a class “HandAttributes” annotated with @Embeddable which holds a lot of boolean attributes. In another class “Person” I want to embed this class twice. The idea is, that the values in the class “Attributes” represent attributes the “Person” can have on its left and right hand.
As far as I understand the possibilites with @AttributeOverride, I could override each attribute in the HandAttributes class and give them a new Column name i.e. “BrokenNailRight” and “BrokenNailLeft”. But as I mentioned, there are many of those Attributes, so I would like to rather not override them all explicitly.
Is there a possibility to Override all attributes in the Embeddable class by giving some kind of naming pattern? Like add the String “left” to all columns or anything similar.
I hope the question is understandable and I’m looking forward any ideas you might have!
I’ve never heard of something like this and am pretty sure that this is not possible.
Are you sure that you want to embed these objects? This results in a lot of really static code, that might better be written like this:
or even
This should also enable generic versions of
getBrokenNails()…