-->
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.  [ 1 post ] 
Author Message
 Post subject: Collection returning inaccurate results.
PostPosted: Mon Oct 27, 2008 2:27 pm 
Newbie

Joined: Thu Aug 07, 2008 4:35 pm
Posts: 9
I have an image embeddable object.
Code:
public ImageEmb(String title, String location, String comment) {
   this.title= title;
   this.location = location;
   this.dateAdded = Calendar.getInstance().getTime();
   this.comment = comment;
}


In my entity object i have a collection of these images.
Code:
private Collection<ImageEmb> images = new ArrayList<ImageEmb>();

@org.hibernate.annotations.CollectionOfElements(fetch=FetchType.EAGER)
@org.hibernate.annotations.CollectionId(columns = @Column(name = "ENTITY_IMAGES_ID"),type = @org.hibernate.annotations.Type(type = "long"),   generator = "ids_generator")
public Collection<ImageEmb> getImages() {
   return images;
}


Now i have 1 image for 1 entity object currently. I see this on the table. When i run this loop in a jsp page (and yes i know i shouldn't use java in jsp).. i get incorrect # of images.

Code:
<% for (ImageEmb i : entity.getImages()) { %>
       <li class="images"><a rel="group1" href='images<%=i.getLocation()%>'><img src='images<%=i.getLocation()%>' width='131' height='88' title='Click to enlarge' alt="<%=i.getComment()%>"/></a></li> <%
} %>


Anyone know why this is happening? If i restart the server, i get a different # of images. Its the same image just repeating too many times. If i do a entity.getImages().size() i also get an incorrect value. Sometimes all the way up to 265 or so.

Thanks


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

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.