ObjectDB ObjectDB

Issue #943: Update query bug

Type: Bug ReoprtVersion: 2.4.4Priority: NormalStatus: FixedReplies: 1
#1

Some code. Problem in UPDATE query.

TypedQuery<List<Transport>> query = (TypedQuery<List<Transport>>) em.createQuery("SELECT t FROM Person p JOIN p.transports t WHERE p.personalCode = :code");

   query.setParameter("code", personalCode);
   List<List<Transport>> list = query.getResultList();
   List<Transport> temp = new Vector<Transport>();
   temp.add((Transport) attributeValue);
   list.add(temp);
   TypedQuery<Person> query2 = (TypedQuery<Person>) em.createQuery("UPDATE Person p SET p.transports = :list WHERE p.personalCode = :code", Person.class);
   query2.setParameter("list", list);
   query2.setParameter("code", personalCode);
   query2.executeUpdate();

----------------------------------------

Exception in thread "main" [ObjectDB 2.4.3] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) Client VM 1.7.0_07 (on Windows 7 6.1).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: java.lang.NullPointerException: null
java.lang.NullPointerException
at com.objectdb.o.UPR$e._b(UPR.java:178)
at com.objectdb.o.UPR.b(UPR.java:82)
at com.objectdb.o.PRG.aj(PRG.java:872)
at com.objectdb.o.PRG.ag(PRG.java:651)
at com.objectdb.o.PRG.af(PRG.java:553)
at com.objectdb.o.QRM.U5(QRM.java:262)
at com.objectdb.o.MST.U5(MST.java:959)
at com.objectdb.o.WRA.U5(WRA.java:290)
at com.objectdb.o.WSM.U5(WSM.java:113)
at com.objectdb.o.QRR.g(QRR.java:239)
at com.objectdb.o.QRR.b(QRR.java:151)
at com.objectdb.jpa.JpaQuery.executeUpdate(JpaQuery.java:743)
at services.PersonService.updatePerson(PersonService.java:90)
at ui.CmdUI.updatePerson(CmdUI.java:262)
at ui.CmdUI.start(CmdUI.java:79)
at main.Main.main(Main.java:22)

 

edit
delete
#2

This UPDATE query is invalid because JPQL UPDATE queries are limited to setting values not collections.

Following your report the exception in this case was fixed with a meaningful error message.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.