my dog learned polymorphism
The moose likes Object Relational Mapping and the fly likes OneToMany not by ID Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OneToMany not by ID" Watch "OneToMany not by ID" New topic

OneToMany not by ID

Alex Armenteros
Ranch Hand

Joined: May 05, 2010
Posts: 75
I'm having problems with the OneToMany side of a relation.

2 models (with the appropiate getters and setters)

If I make the query from City table, I have no problem.

But I'm trying this.

and Hibernate (with Oracle) makes a Query like this.

select * from ( select this_.Serial as Serial2_0_, this_.CodeRegion as CodeRe2_2_0_, this_.DescRegion as DescRe3_2_0_ from region this_ where exists (select 1 from city where this_.Serial=CodeRegion) ) where rownum <= ?

I noted that part in Black as is using Serial column not using the CodeRegion

Any way to substitute the black part from this_.Serial to this_.CodeRegion?

Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

I do not know if this will help but,

try this:

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Alex Armenteros
Ranch Hand

Joined: May 05, 2010
Posts: 75
I've tried with no result but...

if I use something like this.

It works my way and your way [Not using mappedBy or using it] so... I suppose there is some kind of bug in "isNotEmpty" function.

Thank you for your time answering me.
I agree. Here's the link:
subject: OneToMany not by ID
It's not a secret anymore!