How to manage association entities in Hibernate / BlazeDS
I'Ive been working on Java/Hibernate/BlazeDS integrations - but am getting stuck with sending the child entities in a one-to-many relationship across BlazeDS...
For starters I have a Client and ClientLinks table in MS Sql 开发者_Go百科Server
Now java-side in Client the property defining the ClientLinks entity is
private Set clientLinks = new HashSet(0);
On the AS3 side the property setter is
public function set clientProfiles(value:mx.collections.ICollectionView):void {
const oldValue:mx.collections.ICollectionView = this._clientProfiles;
if (oldValue != value) {
this._clientProfiles = value;
dispatchUpdateEvent("clientProfiles", oldValue, value);
}
}
I'm using a farrata systems plugin to generate the AS3 based on java counterparts (could be my problem) I'd like to know if there's an old school way to do this.
What happens now is when I invoke a method Java side from a flex client I recieve a strongly typed Client (great!) but the ClientLinks are represented by a mx.collections::ArrayCollection
. I'd like the ClientLinks to map to my as3 ClientLinks and access them like client.clientLinks[0].linkname
etc.. etc..
Can anyone set me straight about the best way to set this up?
Java Collections will always be mapped as ArrayCollection
. If you want strongly typed AS3 Collections you should use a wrapper class:
public class ClientLinkCollection implements IList, ICollectionView
{
private var _source: ArrayCollection = null;
public function ClientLinks(source: ArrayCollection): void
{
if (source is ArrayCollection)
_source = ArrayCollection(source);
else
throw new TypeError("Invalid argument type!");
}
public function getClientLinkItem(index: int): ClientLink
{
return ClientLink(_source.getItemAt(index));
}
...
}
精彩评论