Question

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

I have a method that checks the object with his copy from secured table. If the object has been changed it will be replaced with the object from secured table. But when I call save ebean does not update it: [debug] c.a.e.s.p.DefaultPersister - Update skipped as bean is unchanged

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 entire object ?

Was it helpful?

Solution

I might be wrong but Ebean did not mark the entity as dirty since you did not called any setter on it. Maybe using Ebean.markAsDirty(entity) could solve your issue (I know this is a pretty old question but since I stumbled upon it, maybe my answer could help somebody)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top