CriteriaBuilder and ManyToOne Entity [message #637147] |
Thu, 04 November 2010 07:43  |
Eclipse User |
|
|
|
Hello,
I am new on this forum and developing with eclipseLink.
Can I somehow access the field without having to create such a class field?
The code developed is like this
@IdClass(CabDecsalEntityPK.class)
public class CabDecsalEntity implements Serializable {
...
@JoinColumns({
@JoinColumn(name = "ALMDESTINO", referencedColumnName = "ALMACEN"),
@JoinColumn(name = "PASDESTINO", referencedColumnName = "PASILLO"),
@JoinColumn(name = "ESTDESTINO", referencedColumnName = "ESTANTERIA"),
@JoinColumn(name = "TRSDESTINO", referencedColumnName = "TRASLACION"),
@JoinColumn(name = "ELVDESTINO", referencedColumnName = "ELEVACION"),
@JoinColumn(name = "PRFDESTINO", referencedColumnName = "PROFUNDIDAD")})
@ManyToOne
private CabMapalmEntity cabMapalmDestinoEntity;
...
}
public class EntityFacade<T> implements EntityFacadeLocal<T> {
...
public List<T> findAll(Class<T> clazz, QueryFilterList filters, QueryOrder order) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(clazz);
Root<T> mapa = cq.from(clazz);
Predicate restriction = cb.conjunction();
restriction = cb.and(restriction, filters.applyToPredicate(cb, mapa));
cq.where(restriction);
if (order != null)
cq.orderBy(order.getOrderBy(cb, mapa));
return em.createQuery(cq).getResultList();
}
...
}
QueryFilterList is a list of fields and comparisons to add to the query
If the filter contains the field "ALMDESTINO" the EJB returns next error:
java.lang.IllegalArgumentException: The attribute [almdestino] from the managed type [EntityTypeImpl@1801682842:CabDecsalEntity [ javaType: class com.felguerati.entity.sga.CabDecsalEntity descriptor: RelationalDescriptor(com.felguerati.entity.sga.CabDecsalEnti ty --> [DatabaseTable(CAB_DECSAL)]), mappings: 35]] is not present.
Thanks in advance
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.23505 seconds