cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: How to create a EJBLQuery with a named parameterized query stored in the mapping?
Date Wed, 27 Jun 2012 06:51:09 GMT
Actually NamedQuery should hide the underlying query implementation be it SQLTemplate, SelectQuery,
EJBQLQuery. So you'd just create a NamedQuery instance and execute it without wrapping in
EJBQL. Is there a problem passing parameters to it? That might be a bug then. Please confirm.

Thanks,
Andrus




On Jun 26, 2012, at 11:40 PM, gilbertoca wrote:
> Hi,
> 
> How to create a EJBLQuery with a named parameterized query stored in the
> mapping?
> 
> I've not found any example[1].
> 
> 
>> 	<query name="LegalEntity.deleteById"
>> factory="org.apache.cayenne.map.EjbqlBuilder">
>> 		<ejbql></ejbql>
>> 	</query>	
>> 
> 
> Code:
> 
> 
>>    @Test
>>    public void NamedDeleteById() {
>>        System.out.println("\nDeleting Legal Entity by ID.\n");
>>        //JPA-->Query query =
>> em.createNamedQuery("LegalEntity.deleteById");
>>        //JPA-->query.setParameter("id", 1010L);
>>        //JPA-->int del = 0;
>>        //JPA-->del = query.executeUpdate();
>> 
>>        ObjectContext context = runtime.getContext();
>>        EJBQLQuery query = new EJBQLQuery("LegalEntity.deleteById");
>>        query.setParameter("id", 1010L);
>>        QueryResponse result = context.performGenericQuery(query);
>> 
>>        int[] count = result.firstUpdateCount();
>>        assertTrue(count.length > 0);
>>    }
>> 
> Any chance to have something like this: 
> EJBQLQuery query = new EJBQLQuery(new NamedQuery("LegalEntity.deleteById"));
> 
> Regards,
> 
> Gilberto
> [1] http://massapi.com/class/org/apache/cayenne/query/NamedQuery.java.html
> 
> --
> View this message in context: http://cayenne.195.n3.nabble.com/How-to-create-a-EJBLQuery-with-a-named-parameterized-query-stored-in-the-mapping-tp4024333.html
> Sent from the Cayenne - User mailing list archive at Nabble.com.
> 


Mime
View raw message