@Override public <T extends Entity> T findById(final Class<T> entityClass, final Long primaryKey) throws SBusinessDataNotFoundException { if (primaryKey == null) { throw new SBusinessDataNotFoundException("Impossible to get data of type " + entityClass.getName() + " with a null identifier"); } final EntityManager em = getEntityManager(); final T entity; try { entity = em.find(entityClass, primaryKey); } catch (final PersistenceException e) { //wrap in retryable exception because the issue might come from BDR reloading throw new SRetryableException(e); } if (entity == null) { throw new SBusinessDataNotFoundException("Impossible to get data of type " + entityClass.getName() + " with id: " + primaryKey); } return entity; }
@Override public <T extends Entity> T findById(final Class<T> entityClass, final Long primaryKey) throws SBusinessDataNotFoundException { if (primaryKey == null) { throw new SBusinessDataNotFoundException("Impossible to get data of type " + entityClass.getName() + " with a null identifier"); } final EntityManager em = getEntityManager(); final T entity; try { entity = em.find(entityClass, primaryKey); } catch (final PersistenceException e) { //wrap in retryable exception because the issue might come from BDR reloading throw new SRetryableException(e); } if (entity == null) { throw new SBusinessDataNotFoundException("Impossible to get data of type " + entityClass.getName() + " with id: " + primaryKey); } return entity; }
private List<Long> getPrimaryKeys(final List<Entity> entities) throws SBusinessDataNotFoundException { List<Long> primaryKeys; primaryKeys = new ArrayList<>(); for (final Entity entity : entities) { if (entity.getPersistenceId() == null) { throw new SBusinessDataNotFoundException("persistenceId of business data is null"); } primaryKeys.add(entity.getPersistenceId()); } return primaryKeys; }
private List<Long> getPrimaryKeys(final List<Entity> entities) throws SBusinessDataNotFoundException { List<Long> primaryKeys; primaryKeys = new ArrayList<>(); for (final Entity entity : entities) { if (entity.getPersistenceId() == null) { throw new SBusinessDataNotFoundException("persistenceId of business data is null"); } primaryKeys.add(entity.getPersistenceId()); } return primaryKeys; }
@SuppressWarnings("unchecked") @Override public Object callJavaOperation(final Object businessObject, final Object valueToSetObjectWith, final String methodName, final String parameterType) throws SBusinessDataNotFoundException, SBusinessDataRepositoryException { if (businessObject == null) { throw new SBusinessDataNotFoundException("business data is null"); } if (isEntity(businessObject)) { return callJavaOperationOnEntity((Entity) businessObject, valueToSetObjectWith, methodName, parameterType); } if (isListOfEntities(businessObject)) { return callJavaOperationOnEntityList((List<Entity>) businessObject, valueToSetObjectWith, methodName, parameterType); } throw new SBusinessDataRepositoryException("not a business data"); }
@SuppressWarnings("unchecked") @Override public Object callJavaOperation(final Object businessObject, final Object valueToSetObjectWith, final String methodName, final String parameterType) throws SBusinessDataNotFoundException, SBusinessDataRepositoryException { if (businessObject == null) { throw new SBusinessDataNotFoundException("business data is null"); } if (isEntity(businessObject)) { return callJavaOperationOnEntity((Entity) businessObject, valueToSetObjectWith, methodName, parameterType); } if (isListOfEntities(businessObject)) { return callJavaOperationOnEntityList((List<Entity>) businessObject, valueToSetObjectWith, methodName, parameterType); } throw new SBusinessDataRepositoryException("not a business data"); }