ebean-orm / ebean

Ebean ORM
https://ebean.io
Apache License 2.0
1.47k stars 260 forks source link

Softdelete on @OneToMany is ignored after refresh() (since 12.11.5) #2581

Closed RualSepp closed 2 years ago

RualSepp commented 2 years ago

Behavior regression introduced in 12.11.5 via https://github.com/ebean-orm/ebean/issues/2376


Expected behavior

Loading the @OneToMany list after refresh() should result in the same SQL-Query as before.

Actual behavior

After refresh() the deleted field is ignored.

Steps to reproduce

User user = DB.find(User.class,1);
//Before refresh()
user.getGroups().forEach(ug->System.out.println(ug.toString()));
user.refresh();
//After refresh()
user.getGroups().forEach(ug->System.out.println(ug.toString()));
--before refresh()
     select
        t0.User_id,
        t0.id,
        t0.deleted,
        t0.User_id,
        t0.Group_id,
    from
        User_Group t0 
    where
        (
            t0.User_id
        ) in (
            ?
        ) 
        and t0.deleted = 0; 
----------------------------------------------------------------------------------------------------
--after refresh()
     select
        t0.User_id,
        t0.id,
        t0.deleted,
        t0.User_id,
        t0.Group_id,
    from
        User_Group t0 
    where
        (
            t0.User_id
        ) in (
            ?
        ) ; 
rbygrave commented 2 years ago

Reference: https://github.com/ebean-orm/ebean/issues/2376 ... as the issue that introduced this change in behaviour (and the change we need to adjust in order to fix this issue).