-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: DetachedCriteria and Example problem with composite-id
PostPosted: Thu Jun 18, 2009 12:39 pm 
Newbie

Joined: Thu Jun 18, 2009 12:12 pm
Posts: 2
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!


Top
 Profile  
 
 Post subject: Re: DetachedCriteria and Example problem with composite-id
PostPosted: Thu Jun 25, 2009 5:24 am 
Newbie

Joined: Thu Jun 18, 2009 12:12 pm
Posts: 2
Well, it would be also useful if you tell me it can't be do it. I know composite-ids are not recommended in hibernate, but it's a requirement, and I am not able to change that.

Thanks anyway!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.