Hi
I have problem when i use join queries let me state with simple example
i have something like this in my database
Table1 which has columns as : id,name
Table2 which has columns as : id,address
values in Table1 are as follows: 1001 Hibernate
values in Table2 are as follows: 1001 Gavin King
k
normally when i need to query joins i will do this way in native SQL
select t1.name,t2.address from Table1 as t1,Table2 as t2 where t1.id=t2.id
i will get the rowset using jdbc code okay
now when i use HQL query
select t1.name,t2.address from Table1 t1,Table2 t2 where t1.id=t2.id
I do get an object but iam not able to type cast it reason being i do not have a bean which i can type cast it into it will come out as a javabean which i do not have right in this case
how can i get the values out of the object...
i tried an alternative solution too like this
select distinct new com.Join(t1.name,t2.address) from Table1 t1,Table2 t2 where t1.id = t2.id
Join is a java bean that takes name and address as paramter in its constructor usign this i get the values its useful surely ..
1.I need to know how can i do a join query apart from this technique without using distinct and wat will be the object that i will get when i apply a joined query.
2. How to use Native SQL queries ur api shows me three parameters where as Hibernate 3.0 has only one paramter to the method
api
createSQLQuery(String query,String alias,Class name)
but hibernate 3.0 jar has somehting like this
createSQLQuery(String query alone)'
Your documentation in pdf along with hibernate download also says it takes 3 parameters but your api shows me that method takes only one parameter that is native sql query alone
Am i doing something worng or something needs to be changed at api and at documentation
can anyone in hibernate team help me out with this problem
I would appreciate if anyone can explain me how a join query can be executed and the type of object that will come when i do a join query
Thanks
Karthik
_________________ Regards
Karthik
|