Saturday, May 2, 2009

parse me again blues

Having the DB entity "Message" with ID and text, i was returning with the entity manager a collection of the form Set<Message> . After obtaining this set i needed to line these messages in a forum thread i was building. The problem isn't that i couldn't get the messages but the message list was not sorted by id (which i recon is by default because that's how result sets go), so everytime i refreshed my forum page, i got those messsages in a different order.
My solution? Altough redneck-ish, i've manually sorted the Set<Message> collection before returning it :p
 

No comments: