Your right as far as the doc is concerned. Unfortunately I cannot help you 
there but if your offer to contribute is deeply welcome.

 

Fortunately I can easily answer your other question.

Here's how it works:

 

  DBCommandExpr union = cmd1.union(cmd2);

  String sql = union.getSelect();

 

Regards

Rainer

 

Von: M Louasse [mailto:[email protected]] 
Gesendet: Samstag, 9. Januar 2010 01:15
An: [email protected]
Betreff: UNION SQL Command

 

Hi,

Could the javadoc of empire-db win a price?
I do not know, but the doc is realy poor! It does not motivate... But I like 
you project, so I want to contribute in order to help you.

Anyway, I'm comming with a real issue: The SQL keyword UNION.

I'm using Mysql 5.1 and lets see bellow:

cmd.select(db.album.id <http://db.album.id> 
,db.album.title,db.album.index,db.album.serieId, db.serie.title);
DBCommand cmdUnion = db.createCommand();
cmdUnion.select(db.album.id,db.album.title,db.album.index,db.album.serieId,db.album.title);
cmd.union(cmdUnion);
cmd.orderBy(db.serie.title);

generates:

SELECT t1.alb_id, t1.alb_title, t1.alb_index, t1.alb_ser_id, t4.ser_title
FROM album t1, serie t4
ORDER BY t4.ser_title

Whereas expected:

SELECT alb_id, alb_title, alb_index, alb_ser_id, ser_title FROM Album, Serie 
WHERE alb_ser_id = ser_id
UNION (SELECT alb_id, alb_title, alb_index, alb_ser_id, alb_title FROM Album 
WHERE alb_ser_id IS NULL)
ORDER BY ser_title;

When I read (I try) your "javadoc" about addSQL() at DBCommendExpr.java

----------------------
addSQL()

public void addSQL(java.lang.StringBuilder buf,
                   long context)

    Creates the SQL-Command.

    Specified by:
        addSQL in class DBExpr

    Parameters:
        buf - the SQL-Command
        context - the current SQL-Command context

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

Doh! Please advise!

Thank you.

 

Reply via email to