| When creating joins on an entity via an embeddable using string attribute names, the join creation from the embeddable fails with an exception:
@Entity class User {
@Id @GeneratedValue Long id;
@Embedded Finances finances = new Finances();
}
@Embeddable class Finances {
@OneToOne Account selectedAccount;
}
@Entity class Account {
@Id @GeneratedValue Long id;
}
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Object> query = builder.createQuery();
Root<User> root = query.from(User.class);
root.join("finances").join("selectedAmount"); root.join(User_.finances).join(Finances_.selectedAccount);
I've created a reproducing example here. Just run mvn clean test on the project and see the test method using the metamodel succeed and the one using simple string names fail with above-documented exception. |