openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wanyna <wan...@hotmail.com>
Subject Re: How to write it in JPQL
Date Wed, 10 Jan 2007 10:39:57 GMT

There are two tables A and B, I need to execute sql like 
"insert into A select ... from B".
I use JPQL Constructor Expressions,
select new A(...) from B, got A list then persist.
But some data of A depends on program context, not from B, for simple
example:
select new A(B.column1, 'xxx') from B,
select new A(null, B.column2) from B,
select new A(variable, B.column2) from B

I have to get the result object[] list and constuct A in my code now.
I hope JPQL Constructor Expressions became more powerful, my code will be
more simple then.




Marc Prud wrote:
> 
> 
> On Jan 10, 2007, at 12:12 AM, wanyna wrote:
> 
>>
>> Hi all.
>> I have two questions:
>> 1.
>> Here is my sql string:
>> select 'xxx', TABLE_A.column1 from TABLE_A;
>> there is a string 'xxx' as a constant value,
>> how to translate it to JPQL?
> 
> I don't think it is possible. Why would you need to do that?
> 
>> 2.
>> Another sql used under oracle:
>> select TABLE_A.column1 from TABLE_A where rownum<10;
>> how to limit range of result in JPQL or jpa?
> 
> Query q = em.createQuery("select ...");
> q.setFirstResult(0);
> q.setMaxResults(10);
> List results = q.getResultList();
> 
> 
> 
>> --  
>> View this message in context: http://www.nabble.com/How-to-write-it- 
>> in-JPQL-tf2951160.html#a8253611
>> Sent from the open-jpa-dev mailing list archive at Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-write-it-in-JPQL-tf2951160.html#a8255355
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Mime
View raw message