Hi!
I'm trying to map a Collection correctly, but somehow can't do it.
Here's my main entity.
I have a collection here constructed as a map. I'd like the map key to be a String, the stringId property of Directory, which is a property of Entry.
But it doesn't work
Code:
@Entity
public class EntryOwner {
@OneToMany(mappedBy = "entryOwner")
@MapKey(name = "directory.stringId")
private Map<String, Entry> entries = new HashMap<String, Entry>();
}
Code:
@Entity
public class Entry {
@NotNull
@ManyToOne
private Directory directory;
@OneToOne
private EntryOwner entryOwner;
}
Code:
@Entity
public class Directory implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "directory")
private List<Entry> entries;
private String stringId;
}
But, as stated at the beginning of my post, it doesn't work, as I got this error:
Code:
Map key property not found: com.lrb.modules.directory.Entry.directory.stringId
How to map that correctly?