Return-Path: Delivered-To: apmail-camel-dev-archive@www.apache.org Received: (qmail 42961 invoked from network); 9 Dec 2009 14:52:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Dec 2009 14:52:54 -0000 Received: (qmail 36437 invoked by uid 500); 9 Dec 2009 14:52:53 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 36410 invoked by uid 500); 9 Dec 2009 14:52:53 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 36400 invoked by uid 99); 9 Dec 2009 14:52:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Dec 2009 14:52:53 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cmoulliard@gmail.com designates 209.85.210.203 as permitted sender) Received: from [209.85.210.203] (HELO mail-yx0-f203.google.com) (209.85.210.203) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Dec 2009 14:52:51 +0000 Received: by yxe41 with SMTP id 41so17185305yxe.30 for ; Wed, 09 Dec 2009 06:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=JHtStUcpHRt/QcvfbNHyMuGgdModpuVy2Kr58MmUN/Y=; b=IMVJTqkeMtlP0lwjzQujnjNm1lWgv2W2sl+cyE8dGm22mbCffa1KAP4gnLTRqUIJUO 5o/yv7yHaZIBvHPltz2sT4jonI1qctY0QoyeLT6bOHIw/2nw7Z3lvmgea+IdWfkyRhS6 kZVDMCnQuIj6zpvzJUCeRaTKeEcsEBuoNZFok= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=qkflbF/cD+0tcqaEzxP4NJadTlw3EcxMhvceYLLpaf8LBHwTHJS/7QTzWqY5l3+RuA ZSY0Zh5JWlIR5Y8cmmqWpYxdPiPGevXHPCbPSpgEwUZOLO75kkdzA213HBigsO/Bjw6U TCLSNZ8ufco4cnIzdRRqL732/rqcfUEqyJM04= MIME-Version: 1.0 Received: by 10.101.132.5 with SMTP id j5mr7732807ann.108.1260370350104; Wed, 09 Dec 2009 06:52:30 -0800 (PST) In-Reply-To: <4B1FB917.4080606@gmail.com> References: <5380c69c0912090559u11afce2yffd9ab6cb2ced454@mail.gmail.com> <4B1FB2C1.6000803@gmail.com> <5380c69c0912090637r6b8bd263t338a8998d3277905@mail.gmail.com> <4B1FB917.4080606@gmail.com> Date: Wed, 9 Dec 2009 15:52:30 +0100 Message-ID: Subject: Re: camel-bam, camel-jpa, camel-example-etl, ...& JPA fully qualified names From: Charles Moulliard To: dev@camel.apache.org Content-Type: multipart/alternative; boundary=0016e68ea0d500e2b4047a4cd74a --0016e68ea0d500e2b4047a4cd74a Content-Type: text/plain; charset=ISO-8859-1 Here is what I have changed in camel-jpa protected QueryFactory createQueryFactory() { if (query != null) { return QueryBuilder.query(query); } else if (namedQuery != null) { return QueryBuilder.namedQuery(namedQuery); } else if (nativeQuery != null) { return QueryBuilder.nativeQuery(nativeQuery); } else { Class entityType = endpoint.getEntityType(); if (entityType == null) { return null; } else { // Check if we have a property name on the @Entity annotation String name = getEntityName(entityType); if ( name != null ) { return QueryBuilder.query("select x from " + name + " x"); } else { // Remove package name of the entity to be conform with JPA 1.0 spec return QueryBuilder.query("select x from " + entityType.getSimpleName() + " x"); } } } } protected String getEntityName(Class clazz) { Entity entity = clazz.getAnnotation(Entity.class); // Check if the property name has been defined for Entity annotation if ( ! entity.name().equals("") ) { return entity.name(); } else { return null; } } Charles Moulliard Senior Enterprise Architect Apache Camel Committer ***************************** blog : http://cmoulliard.blogspot.com twitter : http://twitter.com/cmoulliard Linkedlin : http://www.linkedin.com/in/charlesmoulliard Apache Camel Group : http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm On Wed, Dec 9, 2009 at 3:49 PM, Willem Jiang wrote: > > > Claus Ibsen wrote: > >> On Wed, Dec 9, 2009 at 3:26 PM, Charles Moulliard >> wrote: >> >>> Not really >>> >>> The following part of the JPA consumer code by example will use the >>> entityType defined at the endpoint and in consequence will generate the >>> wrong sql query. >>> >>> protected QueryFactory createQueryFactory() { >>> if (query != null) { >>> return QueryBuilder.query(query); >>> } else if (namedQuery != null) { >>> return QueryBuilder.namedQuery(namedQuery); >>> } else if (nativeQuery != null) { >>> return QueryBuilder.nativeQuery(nativeQuery); >>> } else { >>> Class entityType = endpoint.getEntityType(); >>> if (entityType == null) { >>> return null; >>> } else { >>> return QueryBuilder.query("select x from " + >>> entityType.getName() + " x"); >>> } >>> } >>> } >>> >>> >> Try replacing entityType.getName() with entityType.getSimpleName() and >> add those annotations that willem suggested with the same simple name. >> Then I think it would NOT use the fully qual name. >> >> >> > +1, I just have the same idea as claus said when I was try to get my > daughter sleep :) > > > > Regards, >>> >>> Charles Moulliard >>> Senior Enterprise Architect >>> Apache Camel Committer >>> >>> ***************************** >>> blog : http://cmoulliard.blogspot.com >>> twitter : http://twitter.com/cmoulliard >>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard >>> >>> Apache Camel Group : >>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm >>> >>> >>> On Wed, Dec 9, 2009 at 3:22 PM, Willem Jiang >>> wrote: >>> >>> Hi Charles, >>>> >>>> Does the Entity annotation do the trick ? >>>> eg. >>>> >>>> @Entity(name="AtivityDefinitin") >>>> public class ActivityDefinition { >>>> ... >>>> } >>>> >>>> Willem >>>> >>>> >>>> Charles Moulliard wrote: >>>> >>>> done : https://issues.apache.org/activemq/browse/CAMEL-2273 >>>>> >>>>> >>>>> Charles Moulliard >>>>> Senior Enterprise Architect >>>>> Apache Camel Committer >>>>> >>>>> ***************************** >>>>> blog : http://cmoulliard.blogspot.com >>>>> twitter : http://twitter.com/cmoulliard >>>>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard >>>>> >>>>> Apache Camel Group : >>>>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm >>>>> >>>>> >>>>> On Wed, Dec 9, 2009 at 2:59 PM, Claus Ibsen >>>>> wrote: >>>>> >>>>> Hi Charles >>>>> >>>>>> You are welcome to create a JIRA ticket and try to fix that issue. >>>>>> >>>>>> I guess you can find out how to change those JPA queries to NOT use >>>>>> fully qual names but just the local name. >>>>>> >>>>>> >>>>>> On Wed, Dec 9, 2009 at 2:49 PM, Charles Moulliard < >>>>>> cmoulliard@gmail.com> >>>>>> wrote: >>>>>> >>>>>> Hi, >>>>>>> >>>>>>> I'm stuck with the following problem. The following components : >>>>>>> - camel-bam, >>>>>>> - camel-jpa, >>>>>>> - camel-example-etl, >>>>>>> - ... >>>>>>> >>>>>>> have been designed with JPA specification 1.0 but our implementation >>>>>>> uses >>>>>>> Hibernate JPA. Unfortunately, Hibernate has added some extensions. >>>>>>> >>>>>>> A good example is the fully qualified name which is used by camel jpa >>>>>>> consumer/producer or in all our select c from >>>>>>> Customer.getClass.getName. >>>>>>> >>>>>>> The JPA specification does not support this >>>>>>> >>>>>>> ******* >>>>>>> 4.3.1 Naming >>>>>>> >>>>>>> Entities are designated in query strings by their entity names. The >>>>>>> entity name is defined by the name >>>>>>> element of the Entity annotation (or the entity-name XML descriptor >>>>>>> element), and defaults to >>>>>>> the unqualified name of the entity class. Entity names are scoped >>>>>>> within the persistence unit and must be >>>>>>> unique within the persistence unit. >>>>>>> ****** >>>>>>> >>>>>>> and in consequence, switching from Hibernate to EclipseLink JPA, >>>>>>> OpenJPA, >>>>>>> ... is not possible today. >>>>>>> >>>>>>> Any suggestion are welcome to identify the best approach to improve >>>>>>> our >>>>>>> components ? >>>>>>> >>>>>>> Regards, >>>>>>> >>>>>>> Charles Moulliard >>>>>>> Senior Enterprise Architect >>>>>>> Apache Camel Committer >>>>>>> >>>>>>> ***************************** >>>>>>> blog : http://cmoulliard.blogspot.com >>>>>>> twitter : http://twitter.com/cmoulliard >>>>>>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard >>>>>>> >>>>>>> Apache Camel Group : >>>>>>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm >>>>>>> >>>>>>> >>>>>>> -- >>>>>> Claus Ibsen >>>>>> Apache Camel Committer >>>>>> >>>>>> Author of Camel in Action: http://www.manning.com/ibsen/ >>>>>> Open Source Integration: http://fusesource.com >>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>> Twitter: http://twitter.com/davsclaus >>>>>> >>>>>> >>>>>> >> >> >> > --0016e68ea0d500e2b4047a4cd74a--