You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Patrick Linskey <pl...@gmail.com> on 2007/09/08 18:55:44 UTC

Re: Mapping an enum collection

Hi,

As with mapping Collections and Maps of primitives, this is something
that Kodo does but is not available in OpenJPA.

-Patrick

On 8/29/07, Uri Boness <ur...@jteam.nl> wrote:
> Hi,
>
> I have a User entity that holds set of Role's. A Role is of an Enum
> type. I tried using the @PersistentCollection and @ContainerTable
> annotations as follows:
>
> public enum Role {
>
>     NORMAL_USER, ADMINISRATOR
>
> }
>
> @Entity
> public class User {
>     ..
>     @PersistentCollection
>     @ContainerTable(name = "user_role", joinColumns = @XJoinColumn(name
> = "user_id", referencedColumnName = "id"))
>     private Set<Role> roles;
>
> }
>
> I guess my question is how do I define the column in the container table
> to which the Role.name() will be saved? (I noticed that Kodo defines an
> @ElementColumn annotation which is not present in OpenJPA). Btw, when
> openjpa builds the schema for this mapping, no exception is thrown but
> also the "user_role" table is not created, any idea?
>
> cheers,
> Uri
>
>


-- 
Patrick Linskey
202 669 5907