criteria withen criteria
Hello frnds,
i have 2 table , i want to write sub query using criteria,
my query just like below
select col1,col2,col3 from table1 where col1=....and col2=... and col3 in (select col1,col2,.... from table 2 where .....)
i try to write like....
Criteria c1 = s.cre...(table2.class);
list list = c1.list();
Criteria c2 = s.cre....(table1.class);
c2.add(Re...like(...))
c2.add(Re...in("col from table1",list));
list l2 = c2.list();
Ite.. it = l2.it..()
while(it.has...())
{
table1 t1 = (table1)it.next();
t1....
}
but it not work...
so anyone has solution to my problem than please help me...
thanx in advance...
regards,
pandev84
[760 byte] By [
pandev84a] at [2007-11-27 6:19:51]

# 1
Don't miss out vital information (e.g. this is a Hibernate problem), don't abbreviate code, post code that compiles even if it doesn't work. Post errors for the code that doesn't work.I can't work out what you're trying to do, let alone what the problem is.
# 2
your problem may well lie in the where condition:
col3 in (
select col1, col2, ...
from table 2
where .....
)
as this part will be a single value on the left, and double values on the right. IE, you need to make it:
and col3 in (select col1
from table 2
where ....)
and col3 in (select col2
from table 2
where ....)
etc etc.
Hope this helps.
If not, I agree with the other poster that you should try being a little clearer and using code that compiles, giving us the error messages etc.