Strony

2017-01-16

Centos6 - add and remove User

Add User

sudo adduser newuser
sudo passwd newuser

Delete User

sudo userdel -r newuser
You can add the flag “-r” to the command if you would like to simultaneously remove the users’s home directory and files.

2017-01-11

EntityManager - find list of objects with handled NoResultException

public List findAllElements(Task task) {
        logger.info("Try to find elements - task: {}", task.getId());

        try {
            return em.createNamedQuery(Element.FIND_ALL_BY_TASK, Element.class)
                    .setParameter("task", task)
                    .getResultList();
        } catch (NoResultException e) {
            logger.info(ELEMENT_NOT_FOUND_MSG);

            return Collections.emptyList();
        }
}