Thanks for the suggestion. I was able to figure this out. Running JUnit tests on the User entity gave me this exception trace:
org.jasypt.hibernate4.type.EncryptedStringType.nullSafeGet(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SharedSessionContractImplementor;Ljava/lang/Object;)Ljava/lang/Object;
java.lang.AbstractMethodError: org.jasypt.hibernate4.type.EncryptedStringType.nullSafeGet(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SharedSessionContractImplementor;Ljava/lang/Object;)Ljava/lang/Object;
at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:119)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:82)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2854)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1747)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1673)
at org.hibernate.loader.Loader.getRow(Loader.java:1562)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:732)
at org.hibernate.loader.Loader.processResultSet(Loader.java:991)
at org.hibernate.loader.Loader.doQuery(Loader.java:949)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
at org.hibernate.loader.Loader.doList(Loader.java:2692)
at org.hibernate.loader.Loader.doList(Loader.java:2675)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507)
at org.hibernate.loader.Loader.list(Loader.java:2502)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1489)
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1463)
The problem is with the org.jasypt.hibernate4.type.EncryptedStringType.nullSafeGet() method. We use EncryptedStringType for password encryption. For some reason, this class/method information didn’t show up in the earlier exception traces, so I was completely left in the dark. I assumed that this was the problem with the query itself. From Hibernate 5.2.X onwards, the nullSafeSet() and nullSafeGet() method signatures have changed. The jasypt-hibernate4-1.9.0.jar that we use, implements the earlier method signatures, which is why it worked with Hibernate 5.1.0.Final.
This leads us to another problem. Jasypt has not released a version for Hibernate 5.2.X. The last one they have is for Hibernate 4.X and this is the one we use - http://www.jasypt.org/hibernate.html. I did some digging and came across this project - https://github.com/grelland/jasypt-hibernate5. It appears that this user has ported the Jasypt source code and implemented it for Hibernate 5.2.X. So, I checked out this project and built the ‘jasypt-hibernate5-1.9.3-SNAPSHOT.jar’ myself, after resolving some of the conflicts. I used this jar in my project along with Hibernate 5.2.15.Final jars, and now the query works correctly!
Thank you, for your time. Apologies for any confusion caused!