With an entity like @Entity public abstract class ComposedEntity { @Embeddable public static abstract class ComposedId implements Serializable { @ManyToOne XEntity x; @ManyToOne YEntity y; } @Id ComposedId id; } a query like session.createCriteria(ComposedEntity.class, "main") .createAlias("main.id.x", "x") .add(Restrictions.eq("x.id", 1)) .list(); generates an invalid SQL select this_.x_id as x_id1_0_0_, this_.y_id as y_id2_0_0_ from ComposedEntity this_ where x1_.id=? referring to x1 which was never defined. See https://github.com/Maaartinus/bug-demo for a running example. |