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