wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate many-to-many error" Watch "Hibernate many-to-many error" New topic

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 ]

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".
jQuery in Action, 2nd edition
subject: Hibernate many-to-many error
Similar Threads
joined-subclass problem
Error in Oracle LONG mapping
Incorrect joins on composite ID
Hibernate Select - Criteria with a Date
Hibernate one-to-many inner join?