{
Criteria criteria = new Criteria();
criteria.addEqualTo("name", name);
criteria.addEqualTo("type", type);
criteria.addEqualTo("domainId", domainId);
ReportQueryByCriteria query = QueryFactory.newReportQuery(PersistentJetspeedPrincipal.class, criteria);
query.setAttributes(new String[]{"id"});
// need to force OJB to return a Long, otherwise it'll return a Integer causing a CCE
query.setJdbcTypes(new int[]{Types.BIGINT});
for (Iterator<Object[]> iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(query); iter.hasNext(); )
{
return (Long)iter.next()[0];
}
throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(type, name));