Hi Jeff,
I know this thread is little bit old, but i just stumbled upon the same
issue raised here. And the interesting part is that i have a Bean property
set as java.util.Set (we are using Java 5 Generics).
Secondly i do not get java.lang.ClassCastException or any other exception.
It just goes through but could not save the records as it does not get
casted to Set.
e.g :
if (product.getItems().size() > 0) {
LOG.info("Product.getItems().size() is " + product.getItems().size());
// i am getting size as one which is ok
Set entries = product.getItems();
Iterator entriesIter = entries.iterator();
Items items = null;
while (entriesIter.hasNext()) {
// does not enter while loop and thus no records saved for Items
saveOrUpdateAll(product.getItems());
}
}
Any idea why the Items are not getting casted to Set.
Thanks,
Sudhan
--- In [email protected], "Jeff Vroom" <jvr...@...> wrote:
>
> I think the problem is that you define your Bean property as a
> Collection, not a Set. But hibernate is expecting an object which
> implements the Set interface. When FDS deserializes the ActionScript
> Array collection, it needs to know to convert it to a Set on the server
> side so it is compatible with what hibernate expects.
>
>
>
> Make the bean property be a java.util.Set and we'll stuff a HashSet in
> there and hibernate should be happy.
>
>
>
> Jeff
>
>
>
> ________________________________
>
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Alberto Albericio
> Sent: Wednesday, May 23, 2007 1:52 AM
> To: [email protected]
> Subject: [flexcoders] Cast Exception from FDS to Hibernate
>
>
>
> Hi all,
>
> I have an hibernate mapping defined with some properties and a
> relationship:
>
> <set name="items" table="..." lazy="false">
> <key column="..."/>
> <one-to-many class="..."/>
> </set>
>
> This relationship is defined in the java bean as:
>
> private Collection items;
>
> On the Flex side, I'm receiving this relationship as an ArrayCollection.
>
> The serialization from java.util.Collection to Flex ArrayCollection
> works fine but, when I try to save the changes made on the client side (
>
> what, on the server side, gets translated into
> getHibernateTemplate().update ( .. ) ), it just fails throwing this
> error:
>
> java.lang.ClassCastException : flex.messaging.io.ArrayCollection cannot
> be cast to java.util.Set
>
> Im stuck and I dont know what to do. Any ideas?
>
> Thank you!
>
> Alberto
>