Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Index on enumerated collection?(Index on enumerated collection via annotation?)
Index on enumerated collection? [message #1697123] Mon, 01 June 2015 18:00 Go to next message
Mike Summers is currently offline Mike SummersFriend
Messages: 7
Registered: November 2014
Junior Member
I have an entity with an enumerated collection and I'd like to set an index on the enumeration string. This has no effect (no error, no index):
   @Enumerated(EnumType.STRING)
   @ElementCollection
   @Updateable
   @Index(table="fitableentity_state", columnNames={"state"})
   private Set<FitableEntityState> state = numSet.of(FitableEntityState.Inactive);

I don't get an index on state in the table fitableentity_state as I'd expect.

Is there a way to do this via annotation or is a migration the only choice?

Thanks.
Re: Index on enumerated collection? [message #1697205 is a reply to message #1697123] Tue, 02 June 2015 12:46 Go to previous message
Mike Summers is currently offline Mike SummersFriend
Messages: 7
Registered: November 2014
Junior Member
For future reference this a solution:

   @CollectionTable(indexes={@Index(columnList="state")})
   @Enumerated(EnumType.STRING)
   @ElementCollection(targetClass = FitableEntityState.class)
   @Updateable
   private Set<FitableEntityState> state = EnumSet.of(FitableEntityState.Inactive);

ElementCollection can be refactored out into CollectionTable but for Eclipselink 2.6 this works nicely with

<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />

in persistence.xml
Previous Topic:moxy fails to render json, jaxb error thrown
Next Topic:Two Persists within One Transactional Method
Goto Forum:
  


Current Time: Tue Apr 23 10:39:39 GMT 2024

Powered by FUDForum. Page generated in 0.03019 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top