| How to use native queries with EJB 3.0 ? |
| Written by F.Marchioni | |||||
|
JBoss recipe of the day
Query q = em.createNativeQuery("SELECT p1.last_name, t1.title_name, t2.title_name
FROM person p1 INNER JOIN title t1 ON p1.title_1 = t1.title_abbrev,
person p2 INNER JOIN title t2 ON p2.title_2 = t2.title_abbrev",
sample.Person.User.class);
return q.getResultList();
At first we define the mapping: @SqlResultSetMapping(name = "MyMapping", then we can specify the mapping in the Query as follows:
Query q = em.createNativeQuery("SELECT p1.last_name, t1.title_name, t2.title_name
FROM person p1 INNER JOIN title t1 ON p1.title_1 = t1.title_abbrev,
person p2 INNER JOIN title t2 ON p2.title_2 = t2.title_abbrev",
"MyMapping");
JBoss.org Search
Custom Search
Only registered users can write comments!
Powered by !JoomlaComment 3.26
3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |


