Kudos for finding a way to do this Its ugly (sorry), but as I have mentioned I am not sure what else you could do given how Hibernate currently generates SQL.