-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Query on different subtype attributes
PostPosted: Fri Oct 31, 2003 8:46 pm 
Newbie

Joined: Thu Oct 30, 2003 5:38 pm
Posts: 9
Location: CA
I have an abstract class Event with 2 subclasses AlarmEvent and ManageEvent.
AlarmEvent has a boolean acknowledged
ManageEvent has a boolean confirmed

I would like to query
for Event
where AlarmEvent.acknowledged (true|false)
(or|and)
ManageEvent.confirmed (true|false)

But using a simple case my queries don't provide results that match the database.
So, obviously I am missing something in how to set up the query.

Here is one sample query:
select event from Event event, AlarmEvent alarm, ManageEvent manage
where alarm.acknowledged = false or manage.confirmed = false

However, with a DB having 2 entries:
Alarm acknowledged true and
Manage confirmed false
the result set included both events

Any hints on how to make this kind of query using HSQ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2003 9:09 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
It is hard to guess what mapping you are using. Why don't you just paste it here?

I'm not a HQL guru, but for me your query does not care about AlarmEvent and ManagedEvent at all, because it just says "select event from Event". The rest does not matter bacause there is no restriction on event's properties


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2003 9:12 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Try something like

select event from Event event,
AlarmEvent alarm,
ManageEvent manage
where (event = alarm and alarm.acknowledged = false) or
(event = manage and manage.confirmed = false)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2003 9:18 pm 
Newbie

Joined: Thu Oct 30, 2003 5:38 pm
Posts: 9
Location: CA
That does it - thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.