The _@Transient_ annotation seems to be ignored in an _@Embeddable_ object within another _@Embeddable_ object.
Following is the szenario: I have translatable fields for an entity (_Book_) which are mapped by a language key and stored in a separate table like this:
{code:java} @ElementCollection(targetClass = BookTranslation.class, fetch = FetchType.LAZY) @CollectionTable(name = "BOOK_TRANSLATION", joinColumns = @JoinColumn(name = "BOOK_ID")) @MapKeyClass(String.class) @MapKeyColumn(name = "LANGUAGE_KEY") private Map<String, BookTranslation> translations = new HashMap<>(); {code}
The BookTranslation _BookTranslation_ itself contains another _@Embedded_ object (_ImageObject_) which has a field annotated with _@Transient_. In this case, the annotation seems to be ignored and the following exception is thrown, when trying to start the application:
{code:java} org.hibernate.PropertyNotFoundException: Could not locate setter method for property [com.synconia.bookstore.entity.ImageObject#referenceType] {code}
If a setter method is present, the application starts but a DDL-generation would generate also a column for the field annotated with _ @Transient_. See the example attached: [^hibernate-embedded-transient.zip] @Transient_. See the example attached. |
|