Hi,
I'm trying to implement some reporting logic in my application and got nasty exception when using query with join.
The query code is:
TypedQuery<InspirationsPerSupplierResult> inspirationQuery = em.createQuery( "select new InspirationsPerSupplierResult(insp.id, insp.name, p.id, p.name) from Inspiration insp join insp.products p where (p.supplier = ?1)", InspirationsPerSupplierResult.class); inspirationQuery.setParameter(1, sup);
Nothing special here. InspirationsPerSupplierResult is defined like this:
public class InspirationsPerSupplierResult implements Serializable { private static final long serialVersionUID = 1L; private long inspID; private String inspName; private long productID; private String productName; public InspirationsPerSupplierResult( long inspId, String inspName, long productId, String productName) { super(); this.inspID = inspId; this.inspName = inspName; this.productID = productId; this.productName = productName; }
getters and setters below constructor. Inspiration entity (it's quite big, so let me skip some fields:
@Entity public class Inspiration extends BaseEntity implements Serializable, Convertable { @GeneratedValue(strategy = GenerationType.AUTO) @Id private long id; @Index private String name; (...) @ManyToMany(targetEntity = Product.class, fetch = FetchType.LAZY) private List<Product> products;
Product entity (the same as inspiration, it's quite big, so only important parts):
@Entity public class Product extends BaseEntity implements Serializable, Convertable { @GeneratedValue(strategy = GenerationType.AUTO) @Id private long id; @Column(nullable = false) @Index private String name = ""; }
After executing above statement, there is exception:
2011-07-05 06:40:34.781 ["http-bio-8080"-exec-3] DEBUG p.h.dao.impl.InspirationDAOImpl - getPerSupplier. supplier id: 52 2011-07-05 06:40:34.847 ["http-bio-8080"-exec-3] DEBUG o.s.orm.jpa.JpaTransactionManager - Should roll back transaction but cannot - no transaction available 2011-07-05 06:40:34.847 ["http-bio-8080"-exec-3] DEBUG o.s.orm.jpa.JpaTransactionManager - Should roll back transaction but cannot - no transaction available 2011-07-05 06:40:34.872 ["http-bio-8080"-exec-3] ERROR Click - handleException: com.objectdb.o.InternalException: null at com.objectdb.o.InternalException.f(InternalException.java:236) ~[objectdb.jar:na] at com.objectdb.o.REG.P(REG.java:728) ~[objectdb.jar:na] at com.objectdb.o.REG.M(REG.java:608) ~[objectdb.jar:na] at com.objectdb.o.REG.N(REG.java:629) ~[objectdb.jar:na] at com.objectdb.o.REG.K(REG.java:567) ~[objectdb.jar:na] at com.objectdb.o.REG.f(REG.java:532) ~[objectdb.jar:na] at com.objectdb.o.VOB.j(VOB.java:188) ~[objectdb.jar:na] at com.objectdb.o.TAI.N(TAI.java:271) ~[objectdb.jar:na] at com.objectdb.o.TAI.j(TAI.java:234) ~[objectdb.jar:na] at com.objectdb.o.RTT.F(RTT.java:263) ~[objectdb.jar:na] at com.objectdb.o.RTT.E(RTT.java:235) ~[objectdb.jar:na] at com.objectdb.o.RST.B(RST.java:169) ~[objectdb.jar:na] at com.objectdb.o.RTT.l(RTT.java:134) ~[objectdb.jar:na] at com.objectdb.o.RST.l(RST.java:24) ~[objectdb.jar:na] at com.objectdb.o.RTT.C(RTT.java:179) ~[objectdb.jar:na] at com.objectdb.o.RST.r(RST.java:110) ~[objectdb.jar:na] at com.objectdb.o.PGT.q(PGT.java:109) ~[objectdb.jar:na] at com.objectdb.o.RST.A(RST.java:93) ~[objectdb.jar:na] at com.objectdb.o.RTT.l(RTT.java:132) ~[objectdb.jar:na] at com.objectdb.o.RST.l(RST.java:24) ~[objectdb.jar:na] at com.objectdb.o.RTT.C(RTT.java:179) ~[objectdb.jar:na] at com.objectdb.o.RST.r(RST.java:110) ~[objectdb.jar:na] at com.objectdb.o.PGT.q(PGT.java:109) ~[objectdb.jar:na] at com.objectdb.o.RST.A(RST.java:93) ~[objectdb.jar:na] at com.objectdb.o.RTT.l(RTT.java:132) ~[objectdb.jar:na] at com.objectdb.o.RST.l(RST.java:24) ~[objectdb.jar:na] at com.objectdb.o.TSK.i(TSK.java:146) ~[objectdb.jar:na] at com.objectdb.o.TSK.f(TSK.java:95) ~[objectdb.jar:na] at com.objectdb.o.MST.UQ(MST.java:531) ~[objectdb.jar:na] at com.objectdb.o.PLN.UQ(PLN.java:481) ~[objectdb.jar:na] at com.objectdb.o.TAI.M(TAI.java:200) ~[objectdb.jar:na] at com.objectdb.o.TAI.Ut(TAI.java:134) ~[objectdb.jar:na] at com.objectdb.o.MQI.Ut(MQI.java:96) ~[objectdb.jar:na] at com.objectdb.o.PRG.ab(PRG.java:601) ~[objectdb.jar:na] at com.objectdb.o.QRM.US(QRM.java:259) ~[objectdb.jar:na] at com.objectdb.o.MST.US(MST.java:884) ~[objectdb.jar:na] at com.objectdb.o.WRA.US(WRA.java:286) ~[objectdb.jar:na] at com.objectdb.o.WSM.US(WSM.java:113) ~[objectdb.jar:na] at com.objectdb.o.STC.r(STC.java:421) ~[objectdb.jar:na] at com.objectdb.o.SHN.ah(SHN.java:468) ~[objectdb.jar:na] at com.objectdb.o.SHN.J(SHN.java:146) ~[objectdb.jar:na] at com.objectdb.o.HND.run(HND.java:133) ~[objectdb.jar:na] at java.lang.Thread.run(Thread.java:636) ~[na:1.6.0_26]
Am I missing something here? Or is it some kind of bug?