/** * We need to make sure that we account for failed upgrades - the QA-EACJ migration showed that * the table may linger but the sequence ids go * * @param entityName * @param nextId * @throws GenericEntityException */ private void setNextId(String entityName, Long nextId) throws GenericEntityException { final GenericDelegator delegator = getDelegator(); // First ensure we have an entry in SequenecValueItem table delegator.getNextSeqId(entityName); // Now set it to nextId GenericValue sequenceItem = EntityUtil.getOnly( delegator.findByAnd("SequenceValueItem", ImmutableMap.of("seqName", entityName))); if (sequenceItem != null) { sequenceItem.set("seqId", nextId); sequenceItem.store(); delegator.refreshSequencer(); } }
/** * Creates a reward type * * @param rt the type of the reward, e.g. 'Beer' * @return the reward type, created */ @Override public RewardType addRewardType(RewardType rt) { try { long id = delegator.getNextSeqId(ENTITY); rt.setId(id); delegator.create(toGenericValue(rt)); return rt; } catch (GenericEntityException e) { String msg = String.format( "Could not create reward type ('%s', '%s') ?!?", rt.getName(), rt.getDescription()); LOG.error(msg); throw new OfbizDataException(msg, e); } }