astafev wrote:
Please, write SQL-query, that you want to get.
I think, you need this:
Code:
c.createAlias("position", "p");
c.add(Restrictions.not(Restrictions.eq("p.id", 100)))
(deleted first restriction and added "not" to last)
The problem is so interesting, that the code just work once time correctly, now it can only get result which equals
Restrictions.eq("p.id", 100)but Restrictions.not() looks like no function anymore.
Any ideas?
Here is the SQL I need to query:
SELECT * FROM `content` WHERE `content`.id not in (select content_id from `position_has_content` where position_id = 62)
but I think
Criteria c = sessionFactory.getCurrentSession().createCriteria(Content.class);
c.createAlias("position", "p");
c.add(Restrictions.not(Restrictions.eq("p.id", 62)));
results:
SELECT * FROM `
position_has_content` WHERE content_id not in (select content_id from `position_has_content` where position_id = 62)
it is quite different.