Proper way to dig into Embedded with ManyToOne

5 views
Skip to first unread message

firstname lastname

unread,
Sep 16, 2025, 1:09:43 PM (3 days ago) Sep 16
to Ebean ORM
I have this scenario
@Entity
public class Entity1 {
  @Id
  private Long id;
  private String str;
}

@Embeddable
public class Embed {
  private String field1;
  @ManyToOne
   private Entity1 field2;
}

@Entity
public class Entity2 {
  @Id
  private Long id;
  @Embedded
  private Embed emb;
}

when I try to search like this:

DB.find(Entity2.class).where().eq("emb.field2.str", "foo")

I get an error that `field2` doesn't contain `str"

Do I miss something?

Rob Bygrave

unread,
Sep 17, 2025, 4:52:35 PM (2 days ago) Sep 17
to Ebean ORM
Ebean does not support @Embeddable that contain @ManyToOne.

So yeah, that isn't going to work. Ideally ebean detects this case and throws a nice exception saying that the mapping isn't supported - that the @ManyToOne Entity1 field2; isn't supported.

Cheers, Rob.
Reply all
Reply to author
Forward
0 new messages