Hi all,
I'm having some trouble with a custom query with LIKE operator when I deploy the BDM to portal. Here the details.
- I use Bonita studio 7.9.4 community on my PC with standard configuration and h2 database.
- I've deployed a Tomcat Server with Bonita webapp which use Postgres sql server as database engine
All works well when I develop a process on studio and deploy it on the Bonita server. The only difference I see is that when I define a BD object that contain a TEXT attribute, in the h2 database the attribute content is fully displayed, instead on postgres database the attribute content is replaced by a long number. Here I imagine that the real text is stored somewhere in another table where the long number is the ID of the row containing the data (still don't know where). Really not a problem because when I access data with REST API, the data is correctly read from database. Until now. But.
If I define a custom query that has LIKE operator on such TEXT attribute, I've problem when I deploy such query. For example the custom query is:
SELECT s FROM Segnalazione s WHERE s.registro LIKE :utente AND NOT (s.utenteInserimento= :segnalatore OR s.destinatario= :segnalatore) ORDER BY s.dataInserimento DESC
registro is the TEXT attribute of Segnalazione. Parameters utente and segnalatore are java.lang.String
When I call the REST API from an application page on the local webserver on h2 database:
../API/bdm/businessData/com.company.model.Segnalazione?q=findByCoinvolto&p=0&c=100&f=utente=%25antonio.bianchi%25&f=segnalatore=antonio.bianchi
The API give me the correct JSON object that correspond to such query. Instead when I deploy the BDM and the application page on the remote Bonita Server, when I call the same API, the server reply me:
{"exception":"class org.bonitasoft.engine.exception.BonitaRuntimeException","message":"USERNAME=massimiliano.donno | org.bonitasoft.engine.commons.exceptions.SRetryableException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet"}
If I see server logs I can see:
... javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet ... Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet ... Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: text ~~ bigint Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 1287
It seems that when I query the BDM with REST API, the engine knows well how to retrieve data in TEXT fields, but when I use the LIKE operators on such TEXT fields, the engine forget that the field contain a long that is an id that has to be used to retrieve the data somewhere in the database.
I'm forgetting something or I'm doing something wrong here? There is something I can do to bypass the problem?
Thank You all.