In short: A user has many “not clients” (these are the clients the user cannot serve). User is associated to multiple clients through a join table.
User class: https://gist.github.com/dd99690fcaaba2c834d6
Client class: https://gist.github.com/10de71bcd1914ded5fb9
DAO: https://gist.github.com/dd4a369d60a05460d0c0
the “notClients” attribute in User is always null, can anyone help me understand why?
In short, because you’re not including it in your select query. Not sure why you’re writing out SQL queries and using the bean transformer? That’s a very strange way to use hibernate. In the end it means what you’re getting back is not a hibernate managed entity. It’s just an object with the specific stuff that you selected mapped onto it.
The “normal”/”correct” way to use hibernate would be something like this:
Then what you get back is an Hibernate entity that will have all its mapped properties populated.
(would not personally use uniqueResult in that way either, but I am willing to admit that is largely a style preference.)