JPQL Query List Parameter Exception [message #871691] |
Mon, 14 May 2012 13:27  |
Eclipse User |
|
|
|
If I call findWritableAclEntry and pass it a list of valid SIDs I get the following exception:
Exception Description: Object comparisons can only use the equal() or notEqual() operators. Other comparisons must be done through query keys or direct attribute level comparisons.
Expression: [
Relation operator [ IN ]
Query Key aclSid
Base com.test.security.domain.AclEntry
Constant [
Parameter sids]]
I'm using EclipseLink 2.3.2.
This seems like it should be easy to do, but nothing I have found has been explicit in stating why I can't do this. Any suggestions?
@RooJavaBean
@NamedQueries(value = { @NamedQuery(name = AclEntry.NAME_QUERY_FIND_BY_MASK_AND_SID, query = "SELECT o FROM AclEntry AS o WHERE o.mask =:mask AND o.aclSid IN(:sids)")})
@RooEntity(table = "acl_entry")
public class AclEntry {
private static final transient Logger logger = Logger.getLogger(AclEntry.class);
public static final String NAME_QUERY_FIND_BY_MASK_AND_SID = "";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@ManyToOne(targetEntity = AclObjectIdentity.class)
@JoinColumn(name = "acl_object_identity")
private AclObjectIdentity aclObjectIdentity;
@Column(name = "ace_order")
private Integer aceOrder;
@ManyToOne(targetEntity = AclSid.class)
@JoinColumn(name = "sid")
private AclSid aclSid;
@Column(name = "mask")
private Integer mask;
@Column(name = "granting")
private boolean granting;
@Column(name = "audit_success")
private boolean auditSuccess;
@Column(name = "audit_failure")
private boolean auditFailure;
public static List<AclEntry> findWritableAclEntryBySid(List<AclSid> sids) {
List<AclEntry> results = new ArrayList<AclEntry>();
EntityManager em = AclEntry.entityManager();
TypedQuery<AclEntry> query = em.createNamedQuery(NAME_QUERY_FIND_BY_MASK_AND_SID, AclEntry.class);
query.setParameter("mask", 2);
query.setParameter("sids", sids);
try {
results.addAll(query.getResultList());
} catch(Exception e) {
logger.debug(e);
}
return results;
}
}
@RooJavaBean
@RooEntity(table = "acl_sid")
public class AclSid {
private static final transient Logger logger = Logger.getLogger(AclSid.class);
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "principal")
private boolean principal;
@Column(name = "sid")
private String email;
public static List<AclSid> findAclSidsByEmailEquals(String email) {
if (email == null || email.length() == 0) throw new IllegalArgumentException("The email argument is required");
if(logger.isTraceEnabled()) {
logger.trace("findAclSidsByEmailEquals() -- email[" + email + "]");
}
List<AclSid> results = new ArrayList<AclSid>();
EntityManager em = AclSid.entityManager();
TypedQuery<AclSid> q = em.createQuery("SELECT o FROM AclSid AS o WHERE o.email = :email", AclSid.class);
q.setParameter("email", email);
try {
results.addAll(q.getResultList());
} catch(Exception e) {
if(logger.isTraceEnabled()) {
logger.trace(e);
}
}
return results;
}
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05043 seconds