Im having an object that contains a list of replys. as long as the replys were not sorted anything went fine. but as soon as i added the sort attribute as shown bolow I got an ClassCastExcption when trying to load the object.
Mapping (extract)
<set
name="historyReplies"
lazy="false"
inverse="false"
cascade="all-delete-orphan"
>
<key>
<column name="NOTIF_ID" />
</key>
<one-to-many
class="de.gedas.fraport.sms.server.model.HistoryReply"
/>
</set>
(I'm working with middle out and regenerated the Pojos, which relly changed fronm set to sortedset)
I've red in many forums that unfortunatelly all said the same thing:
I get a ClassCastException when I specify a collection sort attribute.
When you first instantiate a sorted collection, it must be an instance of SortedSet, or SortedMap. Use a TreeSet or TreeMap, for example.
this does not help at all because: I do not instantiate the set this does hibernate (at least hibernate tries to) as you can see in my DAO)-method:
public NotifEvent findById(java.lang.Long id) throws SmsBusinessException
{
Session session = HibernateUtil.currentSession();
try
{
NotifEvent instance = (NotifEvent) session.get(
"de.gedas.fraport.sms.server.model.NotifEvent", id);
if(LOGGER.isDebugEnabled())
{
if (instance == null)
{
LOGGER.debug("get successful, no instance found");
} else
{
LOGGER.debug("get successful, instance found");
}
}
return instance;
} catch (RuntimeException e)
{
if (LOGGER.isEnabledFor(Priority.ERROR))
{
LOGGER.error("NotifEventDAO.findById(...) failed " +
"for id: " + id);
LOGGER.error(e.getMessage(), e);
}
throw new SmsBusinessException("notif.event.load.failed.internal");
} finally
{
HibernateUtil.closeSession();
}
}
DOES ANYBODY HAVE ANY WHAT I HAVE TO DO TIO GET A SORTED COLLECTION???
Thanx in adavanced
Micha
|