File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes SpringMVC and Hibernate Mapping Many-to-Many Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "SpringMVC and Hibernate Mapping Many-to-Many" Watch "SpringMVC and Hibernate Mapping Many-to-Many" New topic
Author

SpringMVC and Hibernate Mapping Many-to-Many

Rendi Artha
Greenhorn

Joined: Jan 20, 2010
Posts: 29
I have a 'interesting' problem, hopefully someone in javaranch could be switch my light ON.

Here the problem :
- I have two entities with a many-to-many association, the join table isn’t being populated when an association is made.
How can the join table is not updated after saving the entities with many-to-many associations between them?


some solution on net as describe in SOLUTION , shorted that we need to call session.flush() before commit the session between them.

My question, is it posible since I already define OSIV Listener and set session.setFlushMode(flushMode.AUTO).Is there any way to do manually flushing session on DAO? since I use HibernateDaoSupport.

Need advice from all of you.
Thank you.
Rendi Artha
Greenhorn

Joined: Jan 20, 2010
Posts: 29
still need advice please. ...anythings, is there any difficulties to dechiper my message, please provide me some question .

Rgds,
Rendi Arta
Rendi Artha
Greenhorn

Joined: Jan 20, 2010
Posts: 29
noone reply...ok maybe leader please "Nathan Pruett" or "Mark Spritzler" .
Rendi Artha
Greenhorn

Joined: Jan 20, 2010
Posts: 29
rendy arta wrote:noone reply...ok maybe leader please "Nathan Pruett" or "Mark Spritzler" .


Here my scenario :
- 2 entity : Transaksi dan TransDetail
- 3 table : TRANSAKSI,TRANSDETAIL & TRANSAKSI_TRANSDETAIL
- Framework : Spring + Hibernate + OSIV Filter

Here is the mapping hbm.xml

Transaksi.hbm.xml


TransDetail.hbm.xml


DAO :


OSIV Filter
-setting : session.setFlushMode(flushMode.AUTO);

Transaction mapping


Executable program at least like this :


any suggestion ? maybe " David Newton "... or else javaranch members
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

So - any exceptions in the logs?



How are you getting all the ID's to set on these objects? Hibernate should be generating them for you when the object is saved...


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SpringMVC and Hibernate Mapping Many-to-Many