JSF/JPA/CDI: Problems when binding managed entities to a bean
-
18-10-2022 - |
Pergunta
I am using a @ConversationScoped CDI
to manage my form. Now, when loading a page, the entity is searched using JPA
. I bind this entity directly onto my bean and accessing is like:
<h:inputText value=#{myForm.myEntity.name}/>
The problem is that it seems to be managed all the time, even if I do a
em.detach(myEntity);
myForm.myEntity = myEntity;
when binding the entity to my bean. Without a merge, the entity is updated in the underlying database.
What's going on there? Do I really need a deep copy of my object?
Is this probably an erroneous way to use CDI
beans?
Nenhuma solução correta
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow