我用findByExample方法时传的实体中包含一个id属性的值,但是生成的sql里边却不包含这个属性。就像传了一个空的实体一样。本来应该查到一个结果的,现在却是把所有的记录到查了出来。但是我用其他属性时都没有问题。
看hibernate文档如下:
The class org.hibernate.criterion.Example allows you to construct a query criterion from a given instance.
Cat cat = new Cat();
cat.setSex('F');
cat.setColor(Color.BLACK);
List results = session.createCriteria(Cat.class)
.add( Example.create(cat) )
.list();
Version properties, identifiers and associations are ignored. By default, null valued properties are excluded.
标志符被忽略了。还有many-to-one,set,版本属性均被忽略