I am new to hibernate but I have a rough idea on what usually to do, this case, I can't say that is working out. I'm trying to create a filtering system which allows you to sort out different clients in this case with users. My SQL query is working correctly:
SELECT * FROM [de_user_site] WHERE [deactivation_time] = '9999-12-31 00:00:00.000' AND [user_id] IN (SELECT [user_id] FROM [de_users] WHERE [client_id] = 1)
And I've tried to turn that into a java query:
queryStr = "SELECT e FROM DeSiteUser e " + queryStr;
String queryStr = " WHERE e.deactivationTime = '9999-12-31 00:00:00.000' ";
if (clientId != null) {
queryStr += String.format("AND e.userId IN (SELECT id FROM DeUser u WHERE ");
if (clientId != null) {
queryStr += String.format("u.clientId = %d ", clientId);
}
}
However, I am having an issue with this:
Internal Server Error [#500]: org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found 'null' near line 1, column 214 [SELECT e FROM com.velatt.dartentitlements.domain.DeSiteUser e WHERE e.deactivationTime = '9999-12-31 00:00:00.000' AND e.userId IN (SELECT id FROM com.velatt.dartentitlements.domain.DeUser u WHERE u.clientId = 6 ]
Does anyone know what I am forgetting, my SQL query is correct but I don't understand why it hasn't worked out for the java query?