When I persist an object with a foreign key, I see in the logs that eclipselink goes off and does a verification query, like this: I also see that eclipselink finds this object and binds it. I don't want it to do either of these things.
Basically I am trying to save object A, and A has a relationship with object B. When I go to insert a new A, all I have is the ID for B, not an instance of class B, and I am not interested in obtaining an instance of B in this case.
Something like this:
String b_id = "12345";
A a = new A();
B b = new B();
b.setId(b_id);
a.setB(b);
//begin tran
try {
em.persist(a);
//commit
} catch (Exception e) {
e.printStackTrace();
//rollback
}
which causes this in the logs:
Execute query DoesExistQuery(referenceClass=B)
SELECT ID FROM B WHERE (ID = ?)
bind => [12345]
Now I want to insert A without Eclipselink going to verify if there exists a B with this Id, and I don't want it to bind this B to the field of A which is an instance of B.
I don't want Eclipselink adding this overhead to the insert, because the database is going to be doing this validation before the insert anyways, and I don't need an actual instance of B in this case.
Any reply is appreciated, thanks!