This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HQL for unary table

 
Sumer Selvaraj
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm new to the Hibernate I have the following database design,

user_info(user_id,user_name,.....,supervisor)

The supervisor is referred the own table's user_id column

I have created the hibernate mapping files and pojo using the automated feature of Netbean. The Codes are here

UserInfo.java


I don't see any option to get the supervisor's as I want to do get the supervisor's name by joining. I know how to get it done using the SQL . This is the SQL code I wish to execute. But I don't know how to write it in HQL.

Can anyone help me out of this?
 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

HQL is very similar to sql. The difference is that in HQL you use entity names instead of table names and entity properties names instead of columns names.
 
Sumer Selvaraj
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Volodymyr Levytskyi wrote:Hello!

HQL is very similar to sql. The difference is that in HQL you use entity names instead of table names and entity properties names instead of columns names.


Hi,

The problem is, how can able to write the condition as there is no method about the supervisor in the UserInfo class
 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every column should be mapped to entity property.

You can't write hql that uses non-existent properties or nonexistent corresponding columns in database
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic