Hello. I'm using Hibernate 3.5.1 and I have been stuck in a problem for a couple days. Help Please. Thanks in advance.
I have a entity called Request, and the Request can target multiple Facility, and multiple ServiceGroup. And the Facility and ServiceGroup could be targeted by multiple Requests. This is essentially a manyToMany relationship. Due to the multiple bags problem with unordered collection, I added a index to the joint table of Request_Facility and Request_ServiceGroup.
Now the database tables look like the following:
Table Request:
(
ID int(generated by IDENTITY),
TITLE,
etc.
)
Table Facility:
(
ID int(generated by IDENTITY),
NAME.
)
Table ServiceGroup:
(
ID int(generated by IDENTITY),
NAME.
)
Table Request_Facility:
(
ID int (generated by IDENTITY),
REQUEST int (FK referencing Request),
FACILITY int (FK referencing Facility)
)
Table Request_ServiceGroup:
(
ID int (generated by IDENTITY),
REQUEST int (FK referencing Request),
SERVICEGROUP int (FK referencing ServiceGroup)
)
Thus, in the Request.java class , i have the following implementation to specify the manyToMany relationships to Facility and ServiceGroups.
but when I tried to persist a new Request targeting some facilities and serviceGroups, the following exception were thrown:
Could anybody please give me some hint? Thanks a lot in advance for your time and patience. This totally drove me nuts after spending the whole day on it,