Ok.
Here's clarifying the situation once again.
Apparently no other module was using the MyObject class and hence it was not crashing during Tomcat deployment. So i was mistaken here.
But nevertheless i found a solution to the problem
When hbm2dll had been turned on, hibernate went and created 2 foreign key associations on "DEF_ID" to the 2 parents that would associate with it. So if one parent would insert into MyObject.class table, it would start crying by saying that there has been a foreign key violation. (because the other parent does not have an Id that matches that of the first parent. )
So the solution was to turn off hbm2ddl and not have any foreign key constraint on the JoinColumn and also to make the column "nullable" so that it would trick hibernate to believe that even though 2 or more parents join on the same column, the parents would insert a null value into the "DEF_ID" column whereby "supposedly existent multiple foreign key constraints" would not throw exceptions.
Code:
@Entity
class Parent{
OneToMany(target = MyObject.class)
JoinColumn(name = "DEF_ID", nullable = true) ----- CHANGE
List<MyObject> listObjects
OneToMany(target = Child.class)
JoinColumn(name = "FK", nullable = false)
List<Child> listChilds
}
@Entity
class Child{
OneToMany(target = MyObject.class)
JoinColumn(name = "DEF_ID", nullable = true) --------- CHANGE
List<MyObject> listObjects
}
@Entity
class MyObject{
}