Hello,
I think the problem is simpler than that. Your Order By is on a.user.name - but you are trying to get results where a.user=null. The query is ordering on the name field on a potentially null entity. When the query is generated, the a.user.name join critera for the orderby will force user to not be null, filtering out null user results.
I haven't tested it, but you will probably need to do an outer join
"SELECT a FROM AlarmaH a LEFT JOIN a.user user WHERE a.user = ?1 or a.user = ?2 ORDER BY user.name ASC"
if that doesn't work, can you try a diffferent orderby clause?
The string provided is the JPQL, which gets translated into SQL. You can get the actual SQL issued to the database by turning on TopLink logging to fine - please see Wonseok's blog:
http://weblogs.java.net/blog/guruwons/archive/2007/07/_toplink_essent.html
Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]
http://forums.java.net/jive/thread.jspa?messageID=269281