-->
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.  [ 3 posts ] 
Author Message
 Post subject: Need to avoid commas in your SQL formula properties
PostPosted: Tue Oct 18, 2005 1:59 pm 
Newbie

Joined: Tue Oct 11, 2005 3:18 pm
Posts: 16
If your mapping contains a SQL formula property, make sure to write the SQL without the use of commas, otherwise the syntax will become corrupted just after the first comma, and an error will be thrown.

i.e. this formula with joins....

type="long" formula="( select p.facility_key from facility_association fa, pipeline_facility pf, facility p WHERE fa.facility_key = facility_key and pf.pipeline_facility_key = fa.related_facility_key and fa.active_flag = 'Y' and p.facility_key = pf.pipeline_facility_key) "

must be re-written with subselects just to avoid commas...

type="long" formula="( select p.facility_key from facility p where p.facility_key in (select pf.pipeline_facility_key from pipeline_facility pf where pf.pipeline_facility_key in (select fa.related_facility_key from facility_association fa where fa.facility_key = facility_key and fa.active_flag = 'Y')) ) "

BTW... it would be great if a formula could return a mapped class instead of a type... i.e...
class="Facility" formula="( select p.* from...."


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 3:25 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, the formula code in H2.1 has lots of limitations, so NH has all of them too.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:58 am 
Regular
Regular

Joined: Fri Jun 11, 2004 6:27 am
Posts: 81
Location: Yaroslavl, Russia
dmcmullan, your formula query is also not perfect. If you'd write it using inner joins there will be no commas in it. It would look approximately like this:
Code:
select p.facility_key
from facility_association fa
  inner join pipeline_facility pf
    on pf.pipeline_facility_key = fa.related_facility_key
  inner join facility p
    on p.facility_key = pf.pipeline_facility_key
WHERE
  fa.facility_key = facility_key
  and fa.active_flag = 'Y'

The SQL syntax you've used is a bit outdated.

_________________
Best,
Andrew Mayorov // BYTE-force


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.