Hi,
If we have two classes that one contains another like
Public class A{
B
}
what is the best approch for inserting A
B foundedB = findByPk("an id of object b");
a.setB (foundedB)
insert(a)
OR
B b=new B();
b.setId("an id of object b");
a.setB (foundedB)
insert(a)
As you found in first approch we find b object and then set it to a, in second one we new b object set it id property to a an insert it. We think first approch is a real OR approch but needs an extra findByPk from database, second one does not need a lookup from b, but is not an OR approch and is not recomanded.
Are we correct?
Regards,
Alireza Fattahi
|