0

I have the following entity which fails to create:

 @OneToMany( fetch = FetchType.LAZY, orphanRemoval=true, mappedBy="itemA" )
 @Cascade( { CascadeType.ALL } ) 
 @MapKey( name="id.customKey" )
 private Map<String, ItemB> bMap;

It gives me a:

Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property

The ManyToOne class attribute is the following:

@ManyToOne( optional=false )
@NotFound( action=NotFoundAction.EXCEPTION )
@JoinColumn( name="ID_ITEM_B", nullable=false, updatable=true, insertable=true  )
private ItemA itemA;

This code seems working fine with a List of ItemB, problem comes when I put a Map in play...how come?

Phate
  • 6,066
  • 15
  • 73
  • 138

1 Answers1

0

When you use Map, just add @MapKey( name="id.customKey" ), do not use mappedBy. see an answer here: How do you map a "Map" in hibernate using annotations?

Community
  • 1
  • 1
XLi
  • 164
  • 1
  • 3