Re: rawJoin

Anthony Berglas <[email protected]>
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Hello Franck,

Your join code failed on Oracle because DEPT_ID 
on the select list is ambiguous, which it 
is.   I'm surprised that neither PostgreSQL nor 
HSQL picked it up.  So I trivialized the 
prefixTableName test in SDriver.selectSQL, which 
produces ugly but correct queries.  Please fix it.

(Oracle does have a strange rule that if you 
provide any alias then you must always use it, 
never the table name, so we cannot just poke an 
alias into the FROM clause without also fixing 
the Select clause which requires proper handing of aliasing in general.)

I then changed your example to
         SQuery<Employee> rawJoinQ = new SQuery<Employee>(Employee.EMPLOYEE)
             .rawJoin("LEFT OUTER JOIN 
XX_DEPARTMENT  D ON D.DEPT_ID = XX_EMPLOYEE.DEPT_ID")
             .rawPredicate("D.DNAME = 'F100'");
LEFT OUTER  will cause three rows to be returned 
if D.DNAME is put in the ON clause, which is probably not what you wanted.


But what are you trying to achieve by rawJoin?  I 
can understand rawSelect, but poking something 
into the join clause without also adding to the 
Select list seems rather pointless.  Remember 
that subselects can always be used in WHERE 
clauses, and they do not have any outer join 
ambiguity.   I assume that you want to unify 
rawJoins with table joins, there should only be one list.


I also saw you reinstated 
SValidatorConstant.  This is essentially just a 
special case of SValidatorEnumeratedValues, with 
one value.  But if it is useful enough to you to 
add then you MUST include a test case.  Otherwise 
please remove it.  The cost of adding code is 
much higher than just the cost of the code that you add.

Let us know how you are going with your port.

Anthony


At 09:38 PM 11/08/2008, Franck Routier wrote:

>Anthony,
>
>note I also added query.rawJoin(String sqlJoin) about one hour ago...
>
>I'll test both.
>
>Thanks
>Franck
>
>Le lundi 11 août 2008 à 20:46 +1000, Anthony & Melissa Berglas a écrit :
> > Added SQuery.setRawSql, see query tests.
> >
> > Anthony
> >
> > At 07:14 PM 10/08/2008, Anthony & Melissa Berglas wrote:
> > >SQuery already has rawClause. But it should also have rawSql. And
> > >maybe other options. Add them if you like, but be sure to also
> > >include a test case.
> > >
> > >Anthony
> > >
> > >At 11:10 PM 9/08/2008, Franck Routier wrote:
> > >
> > >>[Repost - didn't seem to make its way to the list ..?]
> > >>
> > >>Hi Anthony,
> > >>
> > >>I am in the process of porting my app to the latest SOrm.
> > >>
> > >>In several places, we used the SRecordMeta.select(joinStr, whereStr,
> > >>orderStr) method to get a SResultSet of records.
> > >>
> > >>How am I supposed to do it now ?:
> > >>
> > >>- ses.rawXXXX never return records
> > >>- SQuery won't let me use raw sql
> > >>- I can't find any other place...
> > >>
> > >>I can certainly go the jdbc way, but it would have been cool of SOrm
> > had
> > >>build the records for me :)
> > >>
> > >>Am I missing some point, or what way would you suggest to go ?
> > >>
> > >>Franck
> > >>
> > >>
> > >
> > >
> > >Spreadsheet Detective,
> > >Southern Cross Software Queensland Pty Limited
> > >54 Gerler Street
> > >Bardon, Queensland 4065, Australia.
> > >
> > >Email: 
> <mailto:berglas%40spreadsheetdetective.com>[email protected]
> > >www.SpreadsheetDetective.com
> > >Ph: +61 427 830248 (Australian Eastern Standard Time)
> > >
> > >"If the model seems correct only because the numbers look right,
> > >then why build the model in the first place?"
> >
> > Spreadsheet Detective,
> > Southern Cross Software Queensland Pty Limited
> > 54 Gerler Street
> > Bardon, Queensland 4065, Australia.
> >
> > Email: 
> <mailto:berglas%40spreadsheetdetective.com>[email protected]
> > www.SpreadsheetDetective.com
> > Ph: +61 427 830248 (Australian Eastern Standard Time)
> >
> > "If the model seems correct only because the numbers look right,
> > then why build the model in the first place?"
> >
> >
> >
> >
> >
>
>

Dr Anthony Berglas, [email protected]       Mobile: +61 4 4838 8874
Just because it is possible to push twigs along the ground with ones nose
does not necessarily mean that is the best way to collect firewood.


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/SimpleORM/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.