title: hibernate and DB triggers
body: <p>I am using hibernate and pre-insert triggers in database. Let me explain the scenario.
  I have two tables say A and B. In both the tables Primary keys are inserted through pre-insert triggers. Primary key from A is foreign key in B. So when I insert into these tables the foreign key column in B should get populated with triggered value of A (the primary key value). But its not happening as I am expecting. Primary keys in both tables are inserted properly but the foreign key column keeps getting value 0 instead of the triggered value which it should actually get.
  Table have one-to-many relationship.</p>
  
  <p>The two tables are like -</p>
  
  <pre><code>class Employee {
     private int RECORDID;
     @OneToMany(cascade=cascadeType.ALL)
     @JoinColumn(name="MASTERRECORDID" , referencedColumnName="RECORDID")
     private Collection&lt;EmployeeDetails&gt; employeeDetails = new ArrayList&lt;EmployeeDetails&gt;();
  }
  
  class EmployeeDetails{
     private int RECORDID;
     private int MASTERRECORDID;
  }
  </code></pre>
  
  <p>Thanks</p>