Hi,
I tried to find an answer in the forums, but had no luck.
I'm trying to use a negative integer for my primary keys (for data enter manually)
It works well eveywhere except when I have many-to-many associations. The code works fine since I hav ebeen using postive keys for a while and everything is fine
I'm using the annotations with EJB3/JPA.
When I run with a negative primary key, I get an index out of bounds because it looks like it's using the key to go into the list to build the objects.
Why does it use the ID/primary as the key for storing stuff in the list?
Here are my mappings:
Code:
@ManyToMany(fetch = FetchType.EAGER,
targetEntity=Role.class)
@JoinTable(name="user_role_mapping",
joinColumns={@JoinColumn(name="user_id")},
inverseJoinColumns={@JoinColumn(name="role_id")})
private List<Role> userRoles;
Code:
@ManyToMany(fetch = FetchType.EAGER,
mappedBy="userRoles",
targetEntity=User.class)
@IndexColumn(name="mapping_id")
private List<User> users = new ArrayList<User>(0);