2 Replies Latest reply on Aug 24, 2007 2:00 PM by -=Wintermute=-

    Flex runtime error: IManaged

      Need some help with fill() and named querys:

      1) As long as I use the dataservice.fill() mehod to populate an arraycollection with the results from a simple named query like "SELECT * FROM Book WHERE..." I have no problems and the arraycollection gets populated correctly. But as soon as I use a more complex query like "SELECT l.id, b.title, c.surname, c.telephone, c.email FROM Loan l, Book b, Customer c WHERE..." I get a Flex runtime error that says:

      ArgumentError: Items must support IManaged. See [Managed] for more information: object: (Array)#0
      [0] "2003100099"
      [1] "Da Vinci code"
      [2] "Jackson"
      [3] "024982363"
      [4] "m.jackson@hotmail.com"
      at mx.data::ConcreteDataService/ http://www.adobe.com/2006/flex/mx/internal::normalize()
      at mx.data::DataList/ http://www.adobe.com/2006/flex/mx/internal::processSequence()
      at mx.data::DataList/ http://www.adobe.com/2006/flex/mx/internal::processSequenceResult()
      at ::DataListRequestResponder/result()
      at mx.rpc::AsyncRequest/acknowledge()
      at ::NetConnectionMessageResponder/NetConnectionChannel.as$40:NetConnectionMessageResponder: :resultHandler()
      at mx.messaging::MessageResponder/result()

      This I think means that the query is executed correctly ( and it retrieves the correct results array i.e. [0] "2003100099" [1] "Da Vinci code" [2] "Jackson" [3] "024982363" [4] "m.jackson@hotmail.com" ) but Flex can't use it to populate the arraycollection: the reason is probably that it gets the data from various sources (Loan, Book, Customer) and so the instance returned is not one of my standard remotely managed pojos.

        • 1. Re: Flex runtime error: IManaged
          Level 7
          Wouldn't the rows returned from the query need to have column names that
          would ultimately map to property names on an Object? Can you provide aliases
          for the columns selected in your query using the SQL "as" keyword?

          • 2. Re: Flex runtime error: IManaged
            -=Wintermute=- Level 1
            I'm currently using Hibernate 3 with POJOS to map the database.

            This is all the code involved:

            <query name="unreturned.loans"><![CDATA[
            select l.id, b.title, c.surname, c.telephone, c.email
            from Loan l, Book b, Customer c
            where c.id = l.card and b.id = l.book and l.returndate > current_timestamp]]></query>


            <mx:DataService id="hibernateloan" destination="loan.hibernate" fault="handleFault(event)" autoCommit="true" />
            <mx:ArrayCollection id="loanArray" />

            <mx:DataGrid id="loandg" dataProvider="{loanArray}" editable="false" width="340" height="212" x="10" y="10" fontSize="11">
            <mx:DataGridColumn headerText="Id" dataField="id"/>
            <mx:DataGridColumn headerText="Titolo" dataField="title"/>
            <mx:DataGridColumn headerText="Cognome" dataField="surname"/>
            <mx:DataGridColumn headerText="Telefono" dataField="telephone" width="72"/>
            <mx:DataGridColumn headerText="Email" dataField="email"/>

            I want to specify that the process actually WORKS as long as I populate an arraycollection with fields returned from a single entity ("SELECT * FROM Book" for example) and map them to the relative fields in the datagrid.