File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes join query through id without mapping. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "join query through id without mapping." Watch "join query through id without mapping." New topic
Author

join query through id without mapping.

ambar patil
Ranch Hand

Joined: Nov 29, 2005
Posts: 226
Can I join one object through another by id where mapping form one object to another does not exist.
For example :

class A{
int b_id;
}

class B{
int id;
}
select myA from A as myA inner join B as myB where myB.id = myA.b_id;
it is not working I am gettting :
java.lang.NullPointerException
at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16624

You can always do this with an SQLQuery object instead of trying it in HQL.

SQLQuery query = session.createSQLQuery("blahblah");

Something like that.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 366
This is called a Theta-style joins. If you don't use inner join it should work



// Mathias
[ August 13, 2007: Message edited by: Mathias Nilsson ]

SCJP1.4
 
 
subject: join query through id without mapping.
 
Threads others viewed
Prop-ref not working????????
Garbage Collection question
composite-id, one-to-one, formula, and an outer join
n+1 selects in birectional one to one association
Making Line in java
developer file tools