hello on mysql i've seen;
INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6) ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);
This query , inserts data or updates if its already available and this will reduce finding same object again.
On jpa :
User obj2 = ...; User usr2 = entityManager.find(User.class,user.getGid()); if(usr2 != null) { entityManager.refresh(obj2); } else { entityManager.persist(obj2); }
We need to first find the object available then update if its available, if not add new object to db.
This will make more cycle then on mysql on top.
Is there any shortcut persists object if its not available , if its available just update the object.
Without calling find , can we do this ?