Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate querying two tables using join

 
coder.shiv coder
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys I`m new in hibernate and in posting issues here too.

I used JDBC till now and used to code like

select * from apple as a join banana as b on b.color=a.color;

apple.setAppleId(resultset.getLong("a.apple_id"));
apple.setColor(resultset.getString("a.color"));
banana.setBananaId(resultset.getLong("b.banana_id"));
banana.setColor(resultset.getLong("b.color"));

How to do this in hibernate using annotation mappings?

Please help.

 
vijay jacob
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Annotate the basic hibernate class. any simple hibernate example would do.

Then either you can use hql to do your sql stuff.

I believe apple and banana has no real association (mean to say one2many or many2one o)?

So i believe in that case hql is way out.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic