Announcement Announcement Module
Collapse
No announcement yet.
1.5 M1 spring-flex & hibernate lazy loading seems to work, but... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 1.5 M1 spring-flex & hibernate lazy loading seems to work, but...

    hi,

    I've updated my project to use spring-flex 1.5 M1, updated blazeds to 4, and updated to spring 3.0.5. I do see a difference with my application in the initial loading of rows in my flex datagrid; it's faster. and my related entities that are 1-1 now show up, but...

    I have a 1-M relationship using ArrayCollection and the child records are not showing up. Is there something I need to do with annotations or configs or call back to the server to get the child records? Here is some code:

    Customer.as:
    Code:
    package my.biz.app.domain
    {
    	import mx.collections.ArrayCollection;
    	
    	[Bindable]
    	[RemoteClass(alias=my.biz.app.domain.Customer")]
    	public class Customer
    	{
    		public var id : String;
    		public var category : String;
    		public var salutation : String;
    		public var firstName : String;
    		public var lastName : String;
    		public var birthDate : Date;
    		public var customerOrders:ArrayCollection = new ArrayCollection();		
    	}
    }
    DO field:
    Code:
    @OneToMany(mappedBy = "customer", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    Set<CustomerOrder> customerOrders;
    I tried the rootunes sample app, but no entities used ArrayCollection. thanks for the help!

    Gerard

  • #2
    We only send back the parts of the object grid that you have actively initialized. If you need the customerOrders, then it is up to you to initialize that collection.

    Comment


    • #3
      Thanks for the response Jeremy!

      im a bit of a flex newbie, so when you say initalize the collection, is that something I should do in the Customer action script object? If no, what's your recommendation?

      thanks!
      Gerard

      Comment


      • #4
        No, I'm specifically talking about on the server-side regarding your use of Hibernate. In order to get that CustomerOrders collection populated on the client, it needs to be loaded on the server first, but you're using lazy fetching on the One-To-Many relationship (which I believe is Hibernate's default setting for one-to-many anyway). You need to either load he CustomerOrders collection in a separate method call (if you really do need it lazily loaded and not sent every time), or you need to eagerly initialize the collection on the server when you first load the Customer object.

        Comment


        • #5
          ok, makes sense. thanks again!

          Comment


          • #6
            Then, if I understand it correctly, the customerOrders won't be initialized if customer.customerOrders is called in my Flex code (I would need a Flex library for that).
            What I would need to do is to create a server side method in my DAO (let's say customerDAO.getCustomerOrdersForCustomer(Customer customer)) and call it as soon as I need my customerOrder populated.
            Is that right?

            Thanks
            Giulio

            Comment


            • #7
              Originally posted by [email protected] View Post
              Then, if I understand it correctly, the customerOrders won't be initialized if customer.customerOrders is called in my Flex code.
              Correct, unless you are eagerly loading the CustomerOrders when you load Customer.

              Originally posted by [email protected] View Post
              What I would need to do is to create a server side method in my DAO (let's say customerDAO.getCustomerOrdersForCustomer(Customer customer)) and call it as soon as I need my customerOrder populated.
              Is that right?
              Yes.

              Comment

              Working...
              X