I have this entity with its ID defined in Identifiable class.
InventoryLoad has InventoryLoadID as its PK
public class InventoryLoad extends AbstractIdentifiable<InventoryLoadId> implements Auditable {
@OneToMany(mappedBy = "inventoryLoad")
private Set<InventorySubLoad> inventorySubLoads = Sets.newLinkedHashSet();
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumns({
@JoinColumn(name = "stoloc", referencedColumnName = "stoloc"),
@JoinColumn(name = "wh_id", referencedColumnName = "wh_id")
})
private Location location;
@Column(name = "lodwgt")
private Double loadWeight;
@Column(name = "prmflg")
private Boolean permanentLoadSubFlag;
}
This is the ID for above class
@Embeddable
public class InventoryLoadId extends AbstractIdentifiableId {
private static final long serialVersionUID = 1L;
@Column(name = "lodnum")
private String loadNumber;
// some another code below
}
I am using Criteria builder to get to the column of ID class.
To get this using Path to get the path of inventoryid that is PK.
Session session = new HibernateTools().getSession();
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
Root<InventoryLoad> inventoryLoadRoot = criteriaQuery.from(InventoryLoad.class);
Path<InventoryLoadId> inventoryLoadIdPath = inventoryLoadRoot.get("id");
criteriaQuery.multiselect(inventoryLoadIdPath.get("loadNumber"),
Getting this error
Unable to locate Attribute with the the given name [loadNumber] on this ManagedType [unknown]