需要在加入表的条件中等同于一个以上 属性
Need to equate more than one property in criteria on joining the tables
我需要使用条件实现以下代码。
left join A a ON a.id = o.id
and a.rules_id = b.id
and a.global_id = gd.id
WHERE m.org_name = 'PQR'
但是当我添加这样的条件时
criteria = criteria.createAlias("a", "a", JoinType.LEFT_OUTER_JOIN,
Restrictions.eqProperty("a.id", "b.id")).add(Restrictions.eqProperty("a.rules_id", "b.id")).add(Restrictions.eqProperty("a.global_id", "gd.id"));
它在查询的where子句中如下:
left join A a ON a.id = o.id
WHERE m.org_name = 'PQR' and a.rules_id = b.id
and a.global_id = gd.id
任何人都可以用正确的代码帮助我怎样做才能使连接条件正确?
我试过这个:
criteria = criteria.createAlias("a", "a", JoinType.LEFT_OUTER_JOIN,
Restrictions.eqProperty("a.id", "b.id")).add(Restrictions.eqProperty("a.rules_id", "b.id")).add(Restrictions.eqProperty("a.global_id", "gd.id"));
需要这样的查询:
left join A a ON a.id = o.id
and a.rules_id = b.id
and a.global_id = gd.id
where m.org_name = 'PQR'
在这种情况下我们需要使用限制连词。
criteria = criteria.createAlias("a", "a", JoinType.LEFT_OUTER_JOIN,
Restrictions.conjunction(
Restrictions.eqProperty("a.id","o.id"),
Restrictions.eqProperty("a.rules_id", "b.id")));
我需要使用条件实现以下代码。
left join A a ON a.id = o.id
and a.rules_id = b.id
and a.global_id = gd.id
WHERE m.org_name = 'PQR'
但是当我添加这样的条件时
criteria = criteria.createAlias("a", "a", JoinType.LEFT_OUTER_JOIN,
Restrictions.eqProperty("a.id", "b.id")).add(Restrictions.eqProperty("a.rules_id", "b.id")).add(Restrictions.eqProperty("a.global_id", "gd.id"));
它在查询的where子句中如下:
left join A a ON a.id = o.id
WHERE m.org_name = 'PQR' and a.rules_id = b.id
and a.global_id = gd.id
任何人都可以用正确的代码帮助我怎样做才能使连接条件正确?
我试过这个:
criteria = criteria.createAlias("a", "a", JoinType.LEFT_OUTER_JOIN,
Restrictions.eqProperty("a.id", "b.id")).add(Restrictions.eqProperty("a.rules_id", "b.id")).add(Restrictions.eqProperty("a.global_id", "gd.id"));
需要这样的查询:
left join A a ON a.id = o.id
and a.rules_id = b.id
and a.global_id = gd.id
where m.org_name = 'PQR'
在这种情况下我们需要使用限制连词。
criteria = criteria.createAlias("a", "a", JoinType.LEFT_OUTER_JOIN,
Restrictions.conjunction(
Restrictions.eqProperty("a.id","o.id"),
Restrictions.eqProperty("a.rules_id", "b.id")));