openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dusausoy <>
Subject Join fetch not working properly
Date Thu, 29 Mar 2012 17:24:20 GMT

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 :

@Table(name = "PDrawingMapItems")
public class DrawingMapItem {

     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "Id")
     private Long id;

     @ManyToOne(fetch = FetchType.LAZY)
     @JoinColumn(name = "OperationId")
     private Operation operation;

     @ManyToMany(fetch = FetchType.EAGER)
             name = "PDrawingMapItemMarkingLevels",
             joinColumns = {@JoinColumn(name = "ItemId")},
             inverseJoinColumns = {@JoinColumn(name = "MarkingId")}
     private List<MarkingLevel> markingLevels;

     private TraceabilityType traceabilityType;

     @JoinColumn(name = "DrawingMapId")
     private DrawingMap drawingMap;

     // Getters and setters omitted

And here's what I'm trying to execute :

private List<DrawingMapItem> 
getDrawingMapItemsWithOperationsByDrawingMapId(Long mapId) {
         final String queryString = "select dmi from DrawingMapItem dmi 
join fetch dmi.operation where = :mapId order by";
         List<DrawingMapItem> mapItems =
DrawingMapItem.class).setParameter("mapId", mapId).getResultList();
         return mapItems;

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.

View raw message