When 

1. I fetch an entity from database via a stateless service,
2. then modify it in another bean and
3. then want to save it to database via the stateless service,

I notice the entity has been detached. I think because the stateless service's persistence context, the entity came from seized to exist.
But should one use a stateful service?  

Now when saving I use `EntityManager#find(ClassOfDetachedEntity,PrimaryKeyOfDetachedEntity)` to get a reference to the entity in database and then assign the detached entity to it.  

But is this the way?  

Before I was only persisting copies to database, although I just wanted to modify the existing entry.

UPDATE (quick example to show where "detached"-problem occurs):

```
@Stateless
@Log
public class DatabaseService implements Serializable {

    @PersistenceContext
    EntityManager em;

    public List<Category> getCategories() {
        return em.createQuery("SELECT c FROM Category c").getResultList();
    }

    public void checkIfDetached(Object o){
        log.info("is detached: " + String.valueOf(!em.contains(o)));
    }
}  

```

the beans log-statement will tell me, object is detached:

```
 @ManagedBean
    @ViewScoped
    public class CategoriesBean implements Serializable {
        private Category testCategory;

        @PostConstruct
        public void init(){
            testCategory = dbs.getCategories().get(0);
            dbs.checkIfDetached(testCategory);
        }
    }

```