aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate many-to-many error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate many-to-many error" Watch "Hibernate many-to-many error" New topic
Author

Hibernate many-to-many error

Wagner Danda Da Silva Filho
Ranch Hand

Joined: Mar 21, 2003
Posts: 80
Hi All,

I'm having trouble to query a many-to-many association with Hibernate. Here are the envolved hbm files:



Here are the classes:



Here is the Criteria I'm trying to create:



Here is the output:



I could see that Hibernate is doing a SELECT in the wrong table! The many-to-many table is "PACP_PACOTE_PLANO", and the select is reading from "PACM_PACOTE_MINUTOS"...

What am I doing wrong?
[ September 09, 2005: Message edited by: Wagner da Silva ]

SCJP, SCWCD
Wagner Danda Da Silva Filho
Ranch Hand

Joined: Mar 21, 2003
Posts: 80
Hey, I found a stupid yet simple solution:

First I get a "PlanoFaturamento" object loaded from my DAO, e.g.:



Then I can simply call:



This executes the correct query and gives me a Collection of "PacoteMinutos".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate many-to-many error