Hello,
I have a problem in an HQL query. I'm trying to get an ordered list of "Connection" objects using the following query :
Code:
FROM Connection AS connection ORDER BY connection.message.status ASC
When I look at the generated query, it seems that Hibernate adds a JOIN clause like this :
Code:
select [...] from CONNECTION connection0_, MESSAGE message1_ where connection0_.ID_MESSAGE=message1_.SID_MESSAGE order by message1_.ID_STATUS ASC
It's cool, but unfortunately it adds an INNER JOIN by default. So, my result list contains only the Connections that have a reference to a message. The connections without message aren't listed.
How can I tell Hibernate to add a left outer join instead ?Here is the mapping between Connection and Message.
Code:
public class Connection {
...
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="ID_MESSAGE", nullable=true)
@ForeignKey(name = "FK_MESSAGE_CONNECTION")
private Message message;
...
}
I tried to add "optional=true" to the ManyToOne annotation, but it doesn't change anything.
I tried adding manually a left outer join, but the result list contains raw data and not persistent objects.