class ParameterRepositoryServiceImpl implements ParameterRepositoryService {

    @Override
    @Transactional
    public Parameter createParameter(Parameter parameter) {
        if (parameter == null) {
            throw new RiceIllegalArgumentException("parameter is null");
        }

        final ParameterKey key = ParameterKey.create(parameter.getApplicationId(), parameter.getNamespaceCode(), parameter.getComponentCode(), parameter.getName());
        final Parameter existing = getParameter(key);
        if (existing != null && existing.getApplicationId().equals(parameter.getApplicationId())) {
            throw new RiceIllegalStateException("the parameter to create already exists: " + parameter);
        }
        //Parameter flush needed here to accomodate the fact that the version number is not set until flush
        //and the immediate transform of the object loses its JPA context
        ParameterBo parameterBo = getDataObjectService().save(ParameterBo.from(parameter), PersistenceOption.FLUSH);
        return ParameterBo.to(parameterBo);
    }

}