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<MarkingLevel> 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<DrawingMapItem>
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<DrawingMapItem> 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.