I'm looping through a collection of 'RSVP' objects and printing out the value of each one's 'Name' property like this
<p:dataTable id="rsvpDataTable" var="rsvp" value="#{eventController.event.rsvps}"...
<h:outputText value="#{rsvp.name}" />
</p:dataTable>
But I get the error: The class 'org.hibernate.collection.internal.PersistentSet' does not have the property 'name'
If instead, I print out 'rsvp.class.name' to see what type it is, it is indeed a PersistentSet.
But why? It should be single RSVP instance from the collection.
If I debug the code and stop at getRsvps(), I can see that it's returning a PersistentSet containing my RSVP objects. RSVP has a bidirectional relationship back to Event. Would that be causing this?
I'm a bit suspicious about it being a PersistentSet too actually, I would have thought it would have been converted back to a normal 'Java' set by now, but maybe not.
Thanks
You can't iterate over a Set, and that's a JSF restriction for now. JSF 2.2 will be able to do it.
That said, you can convert it yourself or, what I would do, you can use OmniFaces #{of:setToList} EL function. You don't have to reinvent the wheel. :)
See also this answer by BalusC.
As to the fact that Hibernate is returning a PersistentSet, that is just the way it works. Hibernate has it's own implementation of Set, so it can implement features like Lazy-Loading, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With