-->
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.  [ 9 posts ] 
Author Message
 Post subject: how to find the index of an object inside a set?
PostPosted: Wed May 12, 2004 11:21 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
how can I retrieve the position of a certain row/object within a collection of other rows/objects?

right now im just using persons.indexOf(person) to find this but thats not very smart because itll load all of the person objects of persons set


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 11:52 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
If possible i'd like to get this index value using hql, hopefully thats alot faster than loading all the objects


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 12:14 am 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
just to make this clearer, i had converted the Set to a List, Set doesnt have am indexOf method


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 12:37 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Session.filter();

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 1:11 am 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
could you give me another hint as to how I can do this?

i've already looked into the session.filter but not sure what the query would even look like

I just have that Person object loaded and want to know the position of the Person within a List of Person objects, I can already do this using using List.indexOf but that would require me to load all of those Persons and I dont want to do that because i'd be too slow


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 1:14 am 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
my goal is to show at the UI something like "viewing Person 345 of 432543"

and having a url like "showUser.action?personId=5672"


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 4:38 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Person p = (Person)session.filter(persons, "select this where index(this) = ?", ...bind parameter...

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 1:11 am 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
this doesnt work, for one, what I want as a result is an int telling me the position ie, indexOf the Person within the persons collection, not an actual Person object


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 4:31 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Not possible.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.