File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes problem with using idbags in Hibernate, which gives persistenceException etc. Help please. Thanks! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "problem with using idbags in Hibernate, which gives persistenceException etc. Help please. Thanks!" Watch "problem with using idbags in Hibernate, which gives persistenceException etc. Help please. Thanks!" New topic
Author

problem with using idbags in Hibernate, which gives persistenceException etc. Help please. Thanks!

alice zhu
Greenhorn

Joined: Jan 27, 2010
Posts: 5
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,
alice zhu
Greenhorn

Joined: Jan 27, 2010
Posts: 5
by the way, I have a parent class called Wokflow which has a corresponding WORKFLOW data table with ID generated by IDENTITY. The Request class extends the Workflow Class. Since both the parent class and child class have their own data tables, I used the ID of workflow and request as the join column to map them together.

The following is the implementation of the Workflow class:
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

If you resolved this, can you please tell what was wrong?

Thanks!


True person is moral, false is right!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with using idbags in Hibernate, which gives persistenceException etc. Help please. Thanks!