title: Hibernate: Get Parent for OneToMany-Child Entity Without Bidirectional Relation
body: <p>how can i check if an entity has a parent entity which maps this entity over <strong>@OneToMany</strong> annotation.
  The mapping is unidirectional defined on the parent</p>
  
  <pre><code>@Entity
  public class ParentEntity {
  
      ...
  
      @OneToMany(cascade=CascadeType.ALL)
      private Collection&lt;ChildEntity&gt; childEntities;
  
      ...
  </code></pre>
  
  <p>Hibernate automagically creates a mapping table, or if used <strong>@JoinColumn</strong> a column with the parent-id in the child table.
  When the child gets persisted, hibernate adds the corresponding parent id to the db-table.</p>
  
  <p>I do not want to define a bidirectional relation since i do not need this "feature" in my application-logic and there are already loads of entities which would need a change. I just need the parent for replication issues. This means i have to export some data to another DB schema (has different table structure).</p>
  
  <p>I use an interceptor to trigger the replication action in the <strong>"onSave"</strong> method defined by the <strong>Interceptor interface</strong>. If a parent gets a new child, there is just the persist action of the child triggering. I do not know the parent it belongs to.</p>
  
  <p>I really appreciate any help!</p>
  
  <p>Thanks!</p>