Force update for an object

I have a Play Framework 2 application.
I am using play 2.2.2, built using Scala 2.10.3 (with Java 1.7.0_25 running).

I have a method that validates an object with its copy from a protected table. If the object was modified, it will be replaced by the object from the protected table. But when I call save ebean, it does not update it: [debug] caespDefaultPersister - update is skipped as the bean does not change

public static <T> T findAndRestore(Class<T> clazz, Long id) throws Exception {
    T securedObject = SecuredEntityUtils.getObjectFromSecuredTable(clazz, id);
    T entity = Ebean.find(clazz, id);
    if (securedObject != null) {
        if (entity == null) {
            Ebean.save(securedObject);
        } else if (!entity.equals(securedObject)) {
            Ebean.update(securedObject);
        }
    } else {
        logger.warn("Not found securedObject for entity : " + entity.getClass());
    }
    return securedObject ;
}

Is there a way to force ebean to save / update the whole object?

+4
source share

Source: https://habr.com/ru/post/1534374/


All Articles