• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

join query through id without mapping.

 
ambar patil
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always do this with an SQLQuery object instead of trying it in HQL.

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

Something like that.

Mark
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic