-->
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: Native SQL UNION sample code please
PostPosted: Wed Jul 27, 2005 10:03 am 
Newbie

Joined: Wed Jul 27, 2005 9:50 am
Posts: 3
Hibernate version: 2.1.8

Name and version of the database you are using: Oracle 9i

Can someone please forward a link to sample code that demonstrates using a native SQL UNION? I've read Hibernate in Action (the best) and two other Hibernate books, the reference manual, scanned this forum, reviewed Caveat Emptor, and Google'd but have yet to find any examples.

Thanks for any help you can provide.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 10:37 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
session.createSQLQuery("...union...").etc.etc.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 11:34 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
SQL query
Code:
SELECT ename, job, deptno
FROM   emp
UNION
SELECT name, job, dept_id
FROM   ex_emp;


table: emp
Code:
Name               Null?     Typ
------------------ --------- ----------------------
EMPNO              NOT NULL  NUMBER(4)
ENAME                        VARCHAR2(10)
JOB                          VARCHAR2(9)
DEPTNO                       NUMBER(4)


table: ex_emp
Code:
Name               Null?     Typ
------------------ --------- ----------------------
EMPNO              NOT NULL  NUMBER(7)
NAME                         VARCHAR2(25)
DEPT_ID                      NUMBER(4)
JOB                          VARCHAR2(25)


In Hibernate you can use such a query the way Christian described.

Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 12:07 pm 
Newbie

Joined: Wed Jul 27, 2005 9:50 am
Posts: 3
Christian and Sven, 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.