java.lang.StringIndexOutOfBoundsException: String index out of range: -1
Query query = entitymanager.createQuery("SELECT e.title FROM Event e WHERE e.id.id=:id");
query.setParameter("id",2046229248L);
List results = query.getResultList();
It works if I query for a plain string field like title .
It doesn’t if I query using the id of the compound index (I need a compound index).
I get the error java.lang.StringIndexOutOfBoundsException: String index out of range: -1 even if I query for a non existent title …I should simply get null results, why an exception is thrown?
Would you be able to create a test case using these classes as a base? I tried to add a field called id of type long and see if it’s throw an exception but it didn’t.
still stuck with this problem…I guess it’s an Hibernate bug with a compound index which contains a Long field. Somewhere there is a conversion problem between a Java Long type and the BSON Long type inside the document saved in mongodb
Hi, sorry about the delay with this answer. I was on holiday.
I’m checking the test case you provided but in the meanwhile it should work if you use a native query.