Solved

tricky hql where clause

Posted on 2007-04-05
3
393 Views
Last Modified: 2008-02-01
Hi,

I am trying perform select hql, but where clause is a bit tricky. I have two classes like this:
+++++++

public class Project extends ActionForm implements java.io.Serializable {

private Long projectId;
private Demographics demographics;
...
...

+++++++++++++

public class Demographics extends ActionForm implements java.io.Serializable {

    private Long demographicsId;//pk
    private Set projects = new HashSet(0);
...
...

+++++++++++

and it is 1 - N relastionship. I tried this in HQL editor, but didn't return anything.

FROM Project as project where project.demographics.demographicsId='1234'

What hql is going to look like in this case?

thx
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Accepted Solution

by:
bglodde earned 250 total points
ID: 18970947
FROM Project as project where project.demographics.demographicsId='1234'

"demographicsId" is undoubtedly a numeric datatype of some sort, so you won't need single quotes
FROM Project as project where project.demographics.demographicsId=1234

If that doesn't set it straight, check your capitalizations and turn on the option:
<prop key="hibernate.show_sql">true</prop>
so you can see what Hibernate is generating for the actual query.

0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question