aspose file tools*
The moose likes Object Relational Mapping and the fly likes Join In HSQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Join In HSQL" Watch "Join In HSQL" New topic
Author

Join In HSQL

Kalpesh Rawal
Greenhorn

Joined: Aug 08, 2006
Posts: 19
Hi I would like to join 2 tables using HSQL,but there is no relationship betyween 2 tables.I mean there is no foriegn key relationship between 2 tables?How can i do this?
saranga rao
Ranch Hand

Joined: Apr 24, 2007
Posts: 49
hi,

Can You give the table name ... if possible

its like this,

session.createCriteria(A.class)
.createAlias("B","tm")
.add(Expression.gt("tm.number", 2))
.list();

or

session.createCriteria(A.class)
.createCriteria("B","tm")
.add(Expression.gt("tm.number", 2))
.list();

You can also write same as in SQL queries using createQuery() method
Kalpesh Rawal
Greenhorn

Joined: Aug 08, 2006
Posts: 19
i have 2 tables ivtxn & atlog.
create table ivtxn(id varchar2(10),idate date);
create table atlog(alogid number(2),atid varchar2(10),atdate date,aturl vachar2(20),atinsinv number(1));

there is no relationship between 2 tables.But you can say like that id and idate of ivtxn is same as atid,atdate of atlog.

My master table is ivtxn.i want all the records of master table and aturl of atlog along with the records for which atisinv=1 and not equal to 1.
saranga rao
Ranch Hand

Joined: Apr 24, 2007
Posts: 49
Hi rawal,

I don't thing this is require an join

here it is simple query...

select ivtxn , atlog.aturl from ivtxn as ivt , atlog as tlog where
tlog.atinsinv like '1' or tlog not like '1'


in Hibernate

it is like this

String sqlquery = "select ivtxn , atlog.aturl from ivtxn as ivt , atlog as tlog where tlog.atinsinv like '1' or tlog not like '1'";


List lst = createSQLQuery(sqlquery+";").addScalar().list();


Regards
saranga
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Join In HSQL