Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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?
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!