I have 2 tables datasource and ds_restriction and relationship is many to one. I want to select all datasources regardless they are restricted or not. Here is mapped classes:
Code:
@Entity
@Table(name="datasource")
public class DatasourceDom implements Serializable {
@Id
@Column(name = "id")
private int id;
@Column(name = "alias")
private String alias;
@Column(name = "url")
private String url;
@Entity
@Table(name = "ds_restriction")
public class DsRestrictionDom implements Serializable {
@Id
@Column(name = "datasource_id")
private int datasourceId;
@Id
@Column(name = "principal")
private String principal;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "datasource_id")
private DatasourceDom datasource;
And here is my code to get datasources:
Code:
public List<DsRestrictionDom> getDatasorcesRestictions() {
Session session = getCurrentSession();
Criteria criteria = session.createCriteria(DsRestrictionDom.class);
criteria.createCriteria("datasource","ds",JoinType.RIGHT_OUTER_JOIN);
List<DsRestrictionDom> dsList = criteria.list();
return dsList;
}
The result is:
Code:
[
null,
null,
null,
null,
null,
null,
null,
{
"datasourceId": 1,
"principal": "PUBLIC",
"datasource": {
"id": 1,
"alias": "alias1",
"url": "some url"
}
},
null,
null
]
What is incorrect ?