Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Subselect queries in Hibernate

 
Gobind Singh
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to hibernate. Please can someone tell me what I am doing wrong with the following query. (I am using OracleDialect)

String sql = "select task from Task as task where task.taskName = :tName " + "AND task.taskMessage = :tMessage AND task.dateTime > (select processMonth from lu_process_month)"

Task is a peristence object with getter and setters for the properties mentioned. A hbm.xml file also exists for Task too. lu_process_month is a oracle table.

Do I also need a mapping file and class for lu_process_month table?
This is what I thought, so I changed my query to be:

String queryString = "select task from Task as task where task.taskName = :tName " + "AND task.taskMessage = :tMessage AND task.dateTime > (select pmonth.processMonth from LookupProcessMonth as pmonth)";

Where LookupProcessMonth class maps to the lu_process_month table. LookupProcessMonth class has a property called processMonth.

My question is that does every table involved in a query have to be part of a hbm mapping in order for the query to succeed?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic