Hi,
I’m trying to do an import using the import add-on provided by @mario.
For this, I’m using a groovy pre-commit script like this:
import com.company.app.entities.Order
entity.relatedOrder = dataManager.load(Order.class)
.query("select o from app$Order o inner join o.company c where c.name = 'Company X' and o.reference = '" + dataRow[0] + "'")
.view("_minimal")
.one()
return true
The script tries to find an order that has the same reference as being imported for a specific (fixed) company. As it is a combined search I cannot use the standard association function as provided by the add-on (order references may have duplicates but are unique in combination with the company).
When running the import, everything works as expected except that the query is somehow altered such that it generates the error below:
16:24:27.980 ERROR d.d.c.d.s.GenericDataImporterServiceBean - Pre commit script execution failed with: Errors found for input jpql:[select o from baseclass com.company.app.entities.Order o inner join o.company c where c.name = 'Company X' and o.reference = '18.2.3']
CommonErrorNode [<mismatched token: [@9,27:27='.',<68>,1:27], resync=select o from baseclass com.company.app.entities.Order o inner join o.company c where c.name = 'Company X' and o.reference = '18.2.3'>]
com.haulmont.cuba.core.sys.jpql.JpqlSyntaxException: Errors found for input jpql:[select o from baseclass com.company.app.entities.Order o inner join o.company c where c.name = 'Company X' and o.reference = '18.2.3']
CommonErrorNode [<mismatched token: [@9,27:27='.',<68>,1:27], resync=select o from baseclass com.company.app.entities.Order o inner join o.company c where c.name = 'Company X' and o.reference = '18.2.3'>]
at com.haulmont.cuba.core.sys.jpql.Parser.checkTreeForExceptions(Parser.java:113)
at com.haulmont.cuba.core.sys.jpql.Parser.parse(Parser.java:41)
at com.haulmont.cuba.core.sys.jpql.QueryTree.<init>(QueryTree.java:51)
at com.haulmont.cuba.core.sys.jpql.QueryTree.<init>(QueryTree.java:41)
at com.haulmont.cuba.core.global.QueryParserAstBased.getTree(QueryParserAstBased.java:69)
at com.haulmont.cuba.core.global.QueryParserAstBased.getAnalyzer(QueryParserAstBased.java:83)
at com.haulmont.cuba.core.global.QueryParserAstBased.getEntityName(QueryParserAstBased.java:100)
at com.haulmont.cuba.core.sys.PersistenceSecurityImpl.applyConstraints(PersistenceSecurityImpl.java:76)
....
From what I understand the dots in com.company.app...
etc. are a problem for JPQL (which I see confirmed when looking it up in the documentation / internet). However, I don’t see how to prevent the dot from appearing in the query as they are ‘constructed’ by the platform it seems.
Any ideas what is happening or what I am doing wrong?
Regards,
-b