Menu

Partial replication - keeping reference

Help
2005-12-19
2013-04-25
  • Thomas COUSIN

    Thomas COUSIN - 2005-12-19

    Hi,

    I am having a problem to keep a reference to something I don't want to replicate. For example, I replicate an object A that own an object B due to a foreign key. During the replication process, if I use shouldPopulate in my DetailedBeanPopulatable to filter what I want to keep, I am no able to tell it to just keep the reference.

    Do you know a way to keep a reference to an other object? I know that the only thing I need to do is to not erase the id property in this case but I don't know how ...

    Thanks again

     
    • Thomas COUSIN

      Thomas COUSIN - 2005-12-22

      Hi,

      First of all, I answer my previous question. I extends DetailledBeanPopulatable to get the possibility to initialize a collection of objects for those I want to keep the reference and I don't want to be replicated. Thanks to this collection i am  able to filter object for those i want to keep identifier (i.e the reference).

      But now, I am facing to an other problem. For example, i have an object A which is linked to some objects B. I am able to replicate just A and also just B. When i try to save A with Bs inside, I get a classic error :

      object references an unsaved transient instance - save the transient instance
      before flushing : NameOfObjectB

      However, i use transitive persistence to tell hibernate to save B when i save A with an attribut cascade="save-update".
      I am not sure this problem is in relation with beanlib so I will also post this question to hibernate forum.

      Thanks

       
    • Joe D. Velopar

      Joe D. Velopar - 2005-12-22

      First, the basic idea of using beanlib with Hibernate is that once you do the replication, you should have a graph of pure value objects.  There should be no reference to any persistence instances from Hibernate.  The idea is to isolate the Hibernate instances from the application, which just needs to deal with normal data transfer objects, stays Hibernate agnostic, and without you writing yet another DTO class.  The same class is used as a persistence class by Hibernate, and as a pure DTO class by the application after the beanlib replication.

      Second, yes you can completely override the population decision of each bean property via DetailedBeanPopulatable.

      Third, if you use transitive persistence, you may need to have the corresponding transitive object graph replicated via beanlib instead of just copying some references to the Hibernate instances.    Alternatively, you may consider reducing the use of transitive persistence so you can also reduce the set of objects to be replicated in the object graph.

      (Sorry for the late and spare reply.  I've been sick and overwhelmed by work lately.)

       
    • Thomas COUSIN

      Thomas COUSIN - 2005-12-23

      Shame on me, I missed a persistence transitive cascade (save-update) attribut in one of my mapping file. I was trick by an other subclass association in a huge mapping file ... so again, I'am really sorry.
      By the way, I catch the interrest of using beanlib but you gave me a better understanding of the replication concept.

      Happy Christmas

       

Log in to post a comment.