Expand my Community achievements bar.

Managed Associations (Flex 3 \\ CF 8 \\ LCDS 2.5 \\ MySQL 5)

Avatar

Former Community Member
I have two tables 'jdbcuser' and 'jdbcrole' in database 'jdbcauthdwo'.<br />In have added the database as a DataSource in CF8 named 'jdbcauthdwo'.<br />In Flexbuilder I have generated the CFC's and AS files for both tables.<br />I can extract data form both tables so the CFC's and the AS files work.<br />I have setup a one-to-many relationship between the destinations of the two tables.<br />I created a flex app that has a dataservice that calls the parent destination and I recieve the data from that OK. But I recieve 'null' for the object of the child.<br />I have read through every piece of cocumentation that I can find but I can't find what I do wrong so I have posted my code below. I hope some can point out to me what's wrong.<br /><br />The channel:<br /><br /> <channel-definition id="cf-rtmp" class="mx.messaging.channels.RTMPChannel"><br /> <endpoint uri="rtmp://{server.name}:2048" class="flex.messaging.endpoints.RTMPEndpoint"/><br /> <properties><br /> <idle-timeout-minutes>20</idle-timeout-minutes><br /> <serialization><br /> <instantiate-types>false</instantiate-types><br /> </serialization><br /> </properties><br /> </channel-definition><br /><br />The destinations:<br /><br /> <destination id="jdbcuser"><br /> <adapter ref="coldfusion-dao" /><br /> <channels><br /> <channel ref="cf-rtmp" /><br /> </channels><br /> <properties><br /> <component>dto.jdbcuserAssembler</component><br /> <scope>application</scope><br /> <metadata><br /> <identity property = "username" /><br /> <one-to-many property="roles" destination="jdbcrole" lazy="false" /><br /> </metadata><br /> </properties><br /> </destination><br /> <br /> <destination id="jdbcrole"><br /> <adapter ref="coldfusion-dao" /><br /> <channels><br /> <channel ref="cf-rtmp" /><br /> </channels><br /> <properties><br /> <component>dto.jdbcroleAssembler</component><br /> <scope>application</scope><br /> <metadata><br /> <identity property = "username" /><br /> </metadata><br /> </properties><br /> </destination><br /><br />The AS scripts:<br /><br />PARENT<br /><br />package dto.auth<br />{<br /> [Managed]<br /> [RemoteClass(alias="dto.jdbcuser")]<br /><br /> public class jdbcuser<br /> {<br /><br /> public var username:String = "";<br /> public var password:String = "";<br /> public var roles:jdbcrole;<br /><br /> public function jdbcuser()<br /> {<br /> }<br /><br /> }<br />}<br /><br />CHILD<br /><br />package dto.auth<br />{<br /> [Managed]<br /> [RemoteClass(alias="dto.jdbcrole")]<br /><br /> public class jdbcrole<br /> {<br /><br /> public var username:String = "";<br /> public var role:String = "";<br /><br /> public function jdbcrole()<br /> {<br /> }<br /><br /> }<br />}<br /><br />The Flex app:<br /><br /><?xml version="1.0" encoding="utf-8"?><br /><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"<br /> creationComplete="{DS.fill(AC)}"><br /> <br /> <mx:Script><br /> <br /> import dto.auth.jdbcuser;<br /> import dto.auth.jdbcrole;<br /> <br /> import mx.collections.ArrayCollection;<br /> import mx.rpc.events.ResultEvent;<br /> <br /> [Bindable]<br /> private var AC:ArrayCollection = new ArrayCollection;<br /> <br /> private function DSResultHandler(event:ResultEvent){<br /> var e:ResultEvent = event;<br /> }<br /> <br /> <br /> </mx:Script><br /> <br /> <mx:DataService id="DS" destination="jdbcuser" result="DSResultHandler(event)"/><br /> <mx:DataGrid id="DG" dataProvider="{AC}"/><br /> <br /></mx:Application><br /><br />I fill a datagrid and I have an resulthandler in place so that I can put a breakpoitn there and see what is coming out of the dataservice.<br /><br />I get this as a result:<br /><br />result Array (@3b8c511) <br /> [0] Object (@3bb0309) <br /> [1] Object (@3bb0359) <br /> password "vanburk1234" <br /> roles mx.collections.ArrayCollection (@3b13f01) <br /> [inherited] <br /> source null <br /> username "jim" <br /> [2] Object (@3bb03a9) <br /> length 3 <br /><br />As you can see source is null.<br />When I don't instanciate the jdbcuser object in my app I don't even get an arraucollection for roles but I get 'undefined'.<br /><br />Remeber I am not using java but coldfusion for Assemblers.<br />I want to use the managed approache so I should be fine without any extra sql code. But maybe I'm wrong or I read the docs wrong.<br /><br />Any help would be welcome.<br />Thanks in adva
2 Replies

Avatar

Former Community Member
I get this as a result:



result Array (@3b8c511)

[0] Object (@3bb0309)

[1] Object (@3bb0359)

password "vanburk1234"

roles mx.collections.ArrayCollection (@3b13f01)

[inherited]

source null

username "jim"

[2] Object (@3bb03a9)

length 3



As you can see source is null.

When I don't instanciate the jdbcuser object in my app I don't even get an arraucollection for roles but I get 'undefined'.



Remeber I am not using java but coldfusion for Assemblers.

I want to use the managed approache so I should be fine without any extra sql code. But maybe I'm wrong or I read the docs wrong.



Any help would be welcome.

Thanks in advance,



Alexandro

Avatar

Former Community Member
The first message was clipped.
The AS code in teh app is:

import dto.auth.jdbcuser;
import dto.auth.jdbcrole;

import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

[Bindable]
private var AC:ArrayCollection = new ArrayCollection;

private function DSResultHandler(event:ResultEvent){
var e:ResultEvent = event;
}

The MXML code is:




On creationcomplete is does DS.fill(AC)