I've been using Eclipseelink in my project for a long time, but today I came across a problem, and I can not solve it.
The problem is this: at first I search my "Function" object in an instance of my program, after that in another instance I look for and change that same record (changed the "Interval" and "Date" column) and saved in the database, after that in the first instance I only change the "Interval", but in the database the "Date" field was changed even if I did not change, Eclipselink (in the first instance) generates in the UPDATE field change "Date" only because the "Function" of the first instance is outdated with the database, since changes were made to the registry in the meantime, between searching the object and saving it. When I parse the querys generated in the database, I noticed that Eclipselink generates a SELECT before each UPDATE, but in my case I would not need it, I only need it to put in the UPDATE only the fields that I changed, not the ones that are different from the bank.How can I make Eclipselink only add fields in UPDATE that have changed? And not those that differ from the database.
Eclipselink configuration:
"javax.persistence.jdbc.driver", "com.mysql.cj.jdbc.Driver"
"javax.persistence.jdbc.url", "jdbc:mysql://{IP}:3306/{USER}?useTimezone=true&serverTimezone=America/Sao_Paulo&autoReconnect=true&zeroDateTimeBehavior=convertToNull"
"javax.persistence.jdbc.user", user
"javax.persistence.jdbc.password", password
"eclipselink.cache.shared.default", "false"
"eclipselink.logging.level", "WARNING"
"eclipselink.query-results-cache", "false"
"eclipselink.refresh", "true"
"eclipselink.weaving", "static"
"connection.autoReconnectForPools", "true"
"connection.autoReconnect", "true"
Code:
Function function = FunctionDAO.getFunctionByName("A");
function.setInterval(0);
...
EntityManager manager = {config};
manager.getTransaction().begin();
manager.merge(function);
manager.getTransaction().commit();
manager.close();