Reputation: 6043
Working on a JPA compliancy kit for my internship... Part of that kit is testing all corner cases.
I'm looking at @Embeddable
today.
No attributes to deal with.
Then I started wondering...
What if a class is annotated with both @Entity
and @Embeddable
? I found this related question A class that behaves like @Entity and @Embeddable that states JPA does not allows @Entity and @Embeddable at the same time.
However, he's doing this in the context of an @ElementCollection, which is my guess as to what would be causing JPA not to like it (can't stuff non basic/embeddable types in there).
Basically, According to JPA 2.0, Should an error be thrown if a class is annotated with both @Entity and @Embeddable? If not, what should happen?
Upvotes: 3
Views: 628
Reputation: 80603
From page 323 of JSR-317:
Managed class to be included in the persistence unit and to scan for annotations. It should be annotated with either @Entity, @Embeddable or @MappedSuperclass.
This is in reference to managed class definitions in a persistence unit. Based off that I do not believe it is valid to annotate a class with more than one of @Entity
, @Embeddable
or @MappedSuperclass
.
Upvotes: 3