?
Solved

tricky hql where clause

Posted on 2007-04-05
3
Medium Priority
?
398 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 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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