How can I store this aliases field through JPA?
JPA 1.0 doesn't support collections of basic types so you'll have to either:
- Introduce an entity and map it as a
@OneToMany
~or~
- Get your
Set
stored in a BLOB (as a Serializable
) ~or~
- Mark it
@Transient
and use another getter/setter to store it using a custom string representation (using a seperator) ~or~
- Use an extension of your JPA provider supporting collection of basic types (e.g. Hibernate has the
@CollectionOfElements
annotation).
Solution #1 would be the cleanest portable solution. Solution #2 can lead to some troubles on upgrades. Solution #3 is a ugly workaround for #2. Solution #4 is clean but non portable.
In JPA 2.0, there is the @ElementCollection
annotation for this use case (this is of course the ideal solution).
How this field get stored in database
Depending on the chosen implementation, it may be in a BLOB, in a VARCHAR, in another table.