-1

I am trying to migrate my Spring project from Hibernate to ObjectDB. On ObjectDB page, they say that ObjectDB is 100% compatible with JPA. However, I have problem with this JPQL query:

SELECT e FROM Employee e WHERE e.present = false AND NOT EXISTS 
(SELECT c FROM Computer c WHERE c.employeeEntity = e) 
ORDER BY e.name

with Hibernate, there was no problem with this query, but ObjectDB throws exception:

com.objectdb.o.UserException: Unexpected query token 'EXISTS'

Second problem is with Criteria Language. This code:

In<Employee> inExpression = cb.in(root.get(Computer_.employeeEntity));
for (Long id : emplIds) {
    Employee e = new Employee(id);
    inExpression = inExpression.value(e);
}
list.add(inExpression);

was working with Hibernate, with ObjectDB it is throwing:

com.objectdb.o.UserException: Unexpected query token ':l2'
at com.objectdb.o.MSG.d(MSG.java:61)
at com.objectdb.o.TKN.J(TKN.java:765)
at com.objectdb.o.QNF.B(QNF.java:894)
at com.objectdb.o.QNF.I(QNF.java:1294)
at com.objectdb.o.QNF.k(QNF.java:315)
at com.objectdb.o.QNF.H(QNF.java:1270)
at com.objectdb.o.QNF.k(QNF.java:210)
at com.objectdb.o.QNF.t(QNF.java:611)
at com.objectdb.o.QNF.t(QNF.java:605)
at com.objectdb.o.QNF.k(QNF.java:218)
at com.objectdb.o.QNF.j(QNF.java:135)
at com.objectdb.o.QRC.z(QRC.java:321)
at com.objectdb.o.QRC.v(QRC.java:212)
at com.objectdb.o.QRC.u(QRC.java:166)
at com.objectdb.o.QRM.U6(QRM.java:250)
at com.objectdb.o.MST.U6(MST.java:933)
at com.objectdb.o.WRA.U6(WRA.java:291)
at com.objectdb.o.WSM.U6(WSM.java:113)
at com.objectdb.o.STC.r(STC.java:449)
at com.objectdb.o.SHN.aj(SHN.java:489)
at com.objectdb.o.SHN.K(SHN.java:156)
at com.objectdb.o.HND.run(HND.java:132)
at java.lang.Thread.run(Unknown Source)

Does anybody have any idea how to solve these problems?

Milan

ObjectDB
  • 1,312
  • 8
  • 9
Milan Fabian
  • 154
  • 4
  • 13

1 Answers1

3

com.objectdb.o.UserException: Unexpected query token 'EXISTS'

ObjectDB doesn't know EXISTS. See http://www.objectdb.com/java/jpa/query/jpql/comparison.

Instead you can use IS NOT NULL to validate the existence. Be aware that SELECT c FROM Computer c WHERE c.employeeEntity = e must return a single instance and not a multi row resultset.

This is not an ObjectDB issue, cause it is rooted in SQL / sql dialect.

See https://stackoverflow.com/a/6808503/1549387

com.objectdb.o.UserException: Unexpected query token ':l2'

Can you print the stack trace of this? It looks like a unknown named parameter. Could you send the logging level to FINE or FINEST to view the generated SQL?

Community
  • 1
  • 1
cinhtau
  • 1,002
  • 8
  • 16
  • I already found out that ObjectDB doesn't support subqueries, so first part of the question is kinda solved - I have to filter it in Java code by myself. I posted stack trace of the second problem. I set logging to lowest possible level, but I don't see any ObjectDB messages in there. – Milan Fabian Apr 24 '13 at 13:14
  • No. JPA does support subqueries! You are using EXISTS, that doesn't work. The JPA Provider should print the messages. Therefore you have to modify the persistence.xml. – cinhtau Apr 24 '13 at 13:29
  • JPA does, but ObjectDB doesn't: http://www.objectdb.com/database/issue/10. JPA Provider is ObjectDB in this case (there is no Hibernate etc.) – Milan Fabian Apr 24 '13 at 14:18
  • Well, it is not JPA 2.0. Subqueries do work in Version 2. Since you are using JPA 1.0, it is clear. Why did you tag hibernate in the question, when you are using ObjectDB as JPA Provider? To set the logging in ObjectDB, see http://www.objectdb.com/java/jpa/setting/general – cinhtau Apr 24 '13 at 15:23