/** * Find a DSO by its "legacy ID". Former versions of DSpace used integer * record IDs, and these may still be found in external records such as AIPs. * All DSOs now have UUID primary keys, and those should be used when available. * Each type derived from DSpaceObject had its own stream of record IDs, so * it is also necessary to know the specific type. * @param context current DSpace context. * @param legacyId the old integer record identifier. * @param clazz DSO subtype of record identified by {@link legacyId}. * @return * @throws SQLException */ public T findByLegacyId(Context context, int legacyId, Class<T> clazz) throws SQLException { CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, clazz); Root<T> root = criteriaQuery.from(clazz); criteriaQuery.where(criteriaBuilder.equal(root.get("legacyId"), legacyId)); return uniqueResult(context, criteriaQuery, false, clazz, -1, -1); }