You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Tedman Leung <te...@sfu.ca> on 2009/03/20 20:19:08 UTC

persisting collections of enums as strings

Hi I'm trying to persista a Collection of Enums in string format and I 
can't seem to find much information on how to do this.

There were some things that said it defaults to String but when I 
generated the tables (using the MappingToolTask) it comes out as a number 
column.

i.e.
	public enum Role {A, B, C}

	...

	@ManyToMany(fetch=FetchType.EAGER)
	@ContainerTable(name="UserRole", joinColumns=@XJoinColumn(name="userId", referencedColumnName="id"), joinForeignKey=@ForeignKey)
	@ElementJoinColumn(name="Role")
	private Set<Role> roles=new HashSet<Role>();

generates 

	CREATE TABLE UserRole (userId INTEGER, Role SMALLINT) TYPE = innodb;

Is there a way to do the equivalent of 
@Enumerated(EnumType.String) on collections?

 -- 
                                                           Ted Leung
                                                           tedman@sfu.ca

I can speak Canadian, American, Australian, and little English.