0 Replies Latest reply on Apr 29, 2008 3:39 PM by James Kelly

    Entity relationships across persistence-units

    James Kelly Newbie

      Hi all,

      I'm looking for recommendations, patterns, or examples for setting up relationships between entity beans that span persistence units. For example, I have a single value unidirectional relationship from class Foo to Bar:


      @Entity
      class Foo{
       private Bar bar;
      
       @ManyToOne(fetch=FetchType.LAZY)
       @JoinColumn(name="BAR_ID")
       public Bar getBar();
      }
      


      Foo is managed by persistence-unit A, Bar is managed by persistence-unit B. My current solution foregos the object relationship and just stores a Long barId in Foo.

      I've read through the ejb3_persist spec for guidance, but there are no examples or indications saying, "Don't do this." If these types of relationships are verboten, what patterns are people using to resolve these types of entity associations?