Bug 430 : Error thrown when using OneToMany with MapKey
Priority 
High
Reported Version 
 
Logged By 
Sean Brady
Status 
Fixed
Fixed Version 
3.2.6
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
29/10/2012
Updated 
29/10/2012
Type 
Bug
 
Attachments 
No attachments

I have an entity called User with the following property:

@OneToMany(cascade = CascadeType.ALL)
@MapKey(name = "id")
public Map roles = new HashMap();

Role is also an entity. When I add a Role to the roles map and then save the User, I get the following:

models.Role cannot be cast to java.util.Map$Entry
[error] at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveAssocManyDetails(DefaultPersister.java:877)
[error] at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveMany(DefaultPersister.java:799)
[error] at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveAssocMany(DefaultPersister.java:704)
[error] at com.avaje.ebeaninternal.server.persist.DefaultPersister.update(DefaultPersister.java:442)
[error] at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveEnhanced(DefaultPersister.java:343)
[error] at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:315)
[error] at com.avaje.ebeaninternal.server.persist.DefaultPersister.save(DefaultPersister.java:282)
[error] at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1577)
[error] at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1567)
[error] at com.avaje.ebean.Ebean.save(Ebean.java:538)

Sample app here: https://github.com/jtjames/ebean-onetomany-map-module

 
woResponse

Upload a file