Hello everyone!
Hope you guys could help me with this issue. I'm starting using DetachedCriteria and Example and I'm trying to get all the elements from a table where one of their fields from the composite primary key is equals any value.
Here is the picture: ____________________ Class Entity:
public class Entity implements java.io.Serializable { private EntityId id; private String nombre; private String objetivo; ... } _________________ Class EntityId:
public class EntityId implements java.io.Serializable {
private Integer idEntity; private Integer anyoVigencia; ... }
Then, in the DAO of Entity, I have a method that try to do this, but it retrieves all the elements from the table. It doesn't filter the results, and when I see at the query that creates, at the where clause just shows "where 1=1".
Entity entity= new Entity(); EntityId id = new EntityId();
id.setIdEntity(10001); entity.setId(id);
DetachedCriteria criteria = DetachedCriteria.forClass(Entity.class); Example example = Example.create(entity); criteria.add(example); List list = hibernateTemplate.findByCriteria(criteria);
Any idea what's wrong with it?
Thanks in advance and sorry for my english!
|