4 Replies Latest reply on Feb 10, 2010 11:40 PM by venkateshk

    Flex and Java and Hibernate

    venkateshk Level 1

      I am using Flex as my Frontend and Java as the MiddleTier and also Hibernate to interact with the database

      Moreover the framework is Seam

      I wrote the services-config.xml for destination java classes which are actually entities refering to Database tables

      In flex I provided the destination as my Java class which actually referring to my database table

      <mx:RemoteObject id="cargo" destination="itCargoPositionAction">
              <mx:method name="getCargoPos" result="resultHandler(event);" fault="Alert.show(event.fault.faultString)"/>

      getCargoPos() returns a list of rows in a Database table

      private function resultHandler(e:ResultEvent):void
                      for each(var dbObj:Object in e.result)


      This is giving the alert with nothing.

      Actually 'icStorageNameDetailByStorageName' is one of the columns in the table,this column holds the references to someother table in the database

      I want to get the values from that table using the reference available in this table

      Here the relation ship b/w these tables is Master/Detail relation

      Please help........... me

      I am suffering from this issue alot from long time

        • 1. Re: Flex and Java and Hibernate
          Ansury Level 3
          1. Send a simple test String object back first (instead of db search results) to confirm that your remoting setup is working correctly (use the Flex Builder debugger to see what's coming back in the ResultEvent!)
          2. Confirm that you're actually getting something from your Hibernate query to send back to Flex, this simple check escapes my "Hibernate guy's" attention all the time.   If this is a Hibernate/query issue, you're probably asking in the wrong place.
          3. If you're sure that the Flex-Java connection is functioning and Hibernate is returning results, what type of object are you returning from Java?  This will determine the type of object you're getting in the Flex client.  A HashMap is an Object to Flex - it appears that you're trying to access the data as if it was a Java HashMap (likely a single result, then), but it's probably an ArrayList of results. (yes?)  If it is, e.result will be an ArrayCollection (use a debugger breakpoint to verify).  So:
          4. (If you're sending an ArrayList) var list:ArrayCollection = e.result as ArrayCollection; (access each object in list as needed)



          Also (not that this matters for certain), are you using BlazeDS or Granite Data Services (Seam makes me think Granite since they integrate w/Seam and Hibernate specifically)?

          • 2. Re: Flex and Java and Hibernate
            venkateshk Level 1

            I am using FlamingoDS I am getting the result which include direct values

            and reference to the master table of calling table I want to access the

            master details

            I tried to show wht that reference is printing with alert.It shows nothing

            in the alert

            I am getting the direct values without any problem but i don't know how to

            get the values by using the master reference




            • 3. Re: Flex and Java and Hibernate
              Ansury Level 3

              I'm having trouble understanding the problem.  To "get the values by using the master reference" if I understand correctly, e.result is correct.


              The easiest way to figure out what's going on is to just set a breakpoint in that code, and use the debugger.  If you're just having trouble accessing the data in the result you can see via the debugger what type of object(s) are coming across and what the properties for those values are.

              • 4. Re: Flex and Java and Hibernate
                venkateshk Level 1

                e.result is giving the values it's fine

                but out of these values 2 are the references to it's master table

                I am calling like this

                e.result.masterreference.membervariable but it's not giving the member variable of master

                The detail table has a String field

                I am calling like this

                e.result.stringfield it's giving the value as I expected from the database

                but I am not getting the values of master table by using the reference available in detail table

                If possible send me an example which is related to master/detail relation

                please help.............. me