Expand my Community achievements bar.

Using an Object as the identity property for a destination


Level 2
I am using the DataServices and Java Assemblers in my
application but there seems to be a problem with one of my Java
POJOs. First let me explain about my application, the java-side is
using Hibernate, so my POJOs are mapped to a database's entities. I
know there is a Hibernate Assembler but i can't use it because
besides Hibernate I am using EJB and Spring on the java-side, so
that's why i am using the Java Assembler instead of the Hibernate

Ok so now moving along, there's a POJO that has a composite
ID, in Hibernate in order to do this you need an Object which will
be the composite ID. Here's the example:

Class GroupRole {

public GroupRoleID id;


Class GroupRoleID {

public Integer rolId;

public Integer groupId;


On Flex i did the same:

Class GroupRole {

public var id : GroupRoleID;


Class GroupRoleID {

public var rolId : Number;

public var groupId : Number;


Now on my data-management.xml i have the folowing

<destination id="groupsRoles">

<adapter ref="java-dao" />





<identity property="id " type="GroupRoleID"/>






Now when i call the fill method on the assembler to get a
list of GroupRole objects, something weird happens on the Datagrid,
it shows the registers but only one of them can be selected, for
example, if the fill returns 4 registers the DataGrid shows 4
registers that look EXACTLY THE SAME and when i try to select one
of them, only the last one can be selected, the other 3 can't as if
they were not there.

So what's wrong with this? Like i said it happens when you
declare an object as the identify property in the destination. I am
assuming that this is not supported and if it is does anyone know
how do make it work? What is needed in order to work with objects
which identity property is an object?

4 Replies


Level 2
A few things to check:

1. make sure your AS GroupRoleID class has RemoteClass
metadata like so:


public class PlayerID extends Object {

2. make sure your AS GroupRoleID class is used in your mxml
file by declaring at least one variable of that type (even if you
don't instantiate or use it)

3. make sure your AS GroupRoleID class has a toString()
method that includes the roleId and groupId values to ensure each
instance returns a unique value.

When records appear to have matching identities this can
happen. Sometimes it can be because of an incorrect identity in
your destination but also if the object's toString() always returns
the same value (default being [object Type]).

I'm writing up a bug to look for a better way of ensuring
this uniqueness in the future.


Level 2
I will check the third one to see if it works, so is this a
bug after all?


Level 2
Well, yes and no. It was an intentional design choice and
works as such so that's the 'no' part. But IMHO it's not intuitive
and could/should be done in a better way.


Level 2
I noticed in your solution number 1 that you extend from
Object, why is that?

Do all AS classes that are used for RemoteClass purposes need
to extend from Object?

Also i wanted to ask about the toString() method you mention,
you mean to override it right?

You mentioned you were writing up a bug for this issue, was
it solved on Flex 2.0.1? which bug number is it?

Thanks again