• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HQL for unary table

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic