-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problems with sub table criteria
PostPosted: Mon Jun 29, 2009 9:17 am 
Newbie

Joined: Mon Jun 29, 2009 8:59 am
Posts: 1
Hi,

I have a problem with a query which filters a oneToMany entity but don't take that in Select clause. I use Criteria API to do that.

I have 2 entities:


class Category {
@Id
@Column(name = "ID")
Long id;

@Column(name = "NAME")
String name;

@OneToMany (fetch = FetchType.LAZY)
@JoinColumn(name = "CAT_ID")
Set<SubCategory> subcats;
}



class SubCategory {
@Id
@Column(name = "ID")
Long id;

@Column(name = "CAT_ID")
Long categoryId;

@Column(name = "SUB_NAME")
String subName;
}


Generated query by Hibernate:

select
this_.NAME as NAME1_1_,
this_.ID as ID1_1_,
subcat1_.SUB_NAME as NAME2_2_ ,
subcat1_.ID as NAME2_3_
from
CATEGORY this_,
SUB_CATEGORY subcat1_
where subcat1_.CAT_ID = this_.ID AND subcat1_.subName = 'test'

BUT I WANT:

select
this_.NAME as NAME1_1_,
this_.ID as ID1_1_
from
CATEGORY this_,
SUB_CATEGORY subcat1_
where subcat1_.CAT_ID = this_.ID AND subcat1_.subName = 'test'

Any ideas?

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.