littypreethkr wrote:
I don't really get your problem. Why will you insert data into a table just because it is referenced by a different table.
Lets say A.fid references B.id
But if you think that for a row in A its not related to any rows of B then in A just keep the foreign key column null.
Also its not required that each row in A should have a corresponding row in B. If the relation is many to one then one row in B can be referenced by all the rows in A. So if you want to insert 1 million rec in A then you dont have to insert 1 million records in B.
Hi littypreethkr,
I think you are not understanding my problem.
I am not trying to insert the record in both primary and foreign key table.
my problem is like this:
for example:
my TblB pojo is like this:
public String name;
public date sDate;
public com.example.TblA tblA;
Public TblB(com.example.TblA tblA,String name,String sDate){
this.tblA = tblA;
this.name = name;
this.sDate = sDate;
}
now in HibernateDao Class....
TblA tblA = (TblA) hibernateTemplate.get(bean.getId());
TblB tblB = new TblB(tblA,"Information", new Date());
hibernateTemplate.save(tblB);
now here TblA has a primary key named as 'Id'.
TblB has a foreign key name 'id' with many to one relationship.
now if i want to insert 1 million record in TblB, for that i should first create the object of TblA.
so that the object of TblA is also created 1 million times.
So Is there any way so that i can remove that dependency?