Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EBF2A909B for ; Thu, 29 Mar 2012 17:24:48 +0000 (UTC) Received: (qmail 25089 invoked by uid 500); 29 Mar 2012 17:24:48 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 25017 invoked by uid 500); 29 Mar 2012 17:24:48 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 25008 invoked by uid 99); 29 Mar 2012 17:24:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2012 17:24:47 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bdusausoy@yp5.be designates 91.121.85.197 as permitted sender) Received: from [91.121.85.197] (HELO jumper.yp5.be) (91.121.85.197) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2012 17:24:40 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by jumper.yp5.be (Postfix) with ESMTP id 0A7C0175B2 for ; Thu, 29 Mar 2012 19:24:20 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at jumper.yp5.be Received: from jumper.yp5.be ([127.0.0.1]) by localhost (asgard.yp5.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Ucieq9MxGVo for ; Thu, 29 Mar 2012 19:24:19 +0200 (CEST) Received: by jumper.yp5.be (Postfix, from userid 5000) id 5DFE218864; Thu, 29 Mar 2012 19:24:19 +0200 (CEST) Received: from [192.168.1.102] (unknown [78.129.53.253]) by jumper.yp5.be (Postfix) with ESMTPSA id 39A88175B2 for ; Thu, 29 Mar 2012 19:24:19 +0200 (CEST) Message-ID: <4F749AC4.5040708@yp5.be> Date: Thu, 29 Mar 2012 19:24:20 +0200 From: Bruno Dusausoy User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: OpenJPA Users Subject: Join fetch not working properly Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Copyrighted-Material: Please visit http://www.yp5.be Hi, I have a problem with the "join fetch" JPQL clause (OpenJPA 2.1.1). The SQL executed underneath is ok, the "joins" are done and if I copy/paste the generated SQL request in SQL Server 2005, it returns the right results : right number of records, right number of columns, ... But it seems there's a problem with the "mapping"; OpenJPA forgets somehow to map the Operation columns back to an entity. My operation are always null. Do I have to specify something to OpenJPA in order to force it to map the Operation entity ? Here's the snippet for my entity : @Entity @Table(name = "PDrawingMapItems") public class DrawingMapItem { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "Id") private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "OperationId") private Operation operation; @ManyToMany(fetch = FetchType.EAGER) @JoinTable( name = "PDrawingMapItemMarkingLevels", joinColumns = {@JoinColumn(name = "ItemId")}, inverseJoinColumns = {@JoinColumn(name = "MarkingId")} ) private List markingLevels; @Enumerated(EnumType.STRING) private TraceabilityType traceabilityType; @ManyToOne @JoinColumn(name = "DrawingMapId") private DrawingMap drawingMap; // Getters and setters omitted } And here's what I'm trying to execute : private List getDrawingMapItemsWithOperationsByDrawingMapId(Long mapId) { final String queryString = "select dmi from DrawingMapItem dmi join fetch dmi.operation where dmi.drawingMap.id = :mapId order by dmi.id"; List mapItems = entityManager.createQuery(queryString, DrawingMapItem.class).setParameter("mapId", mapId).getResultList(); return mapItems; } Regards. -- Bruno Dusausoy Software engineer YP5 Software -- Pensez environnement : limitez l'impression de ce mail. Please don't print this e-mail unless you really need to.