0 Replies Latest reply on Feb 1, 2011 2:56 PM by Michal Frackowiak

    Can't use Entity directly in the view

    Michal Frackowiak Newbie

      Hi again,

      I described my problem with not working auto flush few days ago, but I've already found a solution, however it's rather workaround. I still don't get what exactly the problem is and how to handle this properly. I use more than one Entity Managers (with XA datasources) and extended Persistence Context managed by Seam (SMPC). The problem is that changes to managed entity are not flush if they occur outside a transaction that was used to get the entity. For example, I want to have conversation-scoped User entity and this shouldn't be a problem with conversation-scoped, Seam-managed Entity Manager. But basically when I try to access it like this:

      <h:inputText value="#{user.name}" />

      it doesn't work. However, using generated UserHome works:

      <h:inputText value="#{userHome.instance.name}" />

      Basically I don't understand why first approach doesn't work. Can you help me? My current workaround-like solution is to use manager pattern, so the implementation is similar to this:

      public class UserManager {
          private Long userId; // goes from the HTTP session
          private UserHome userHome;
          public User getUser() {
              return userHome.getInstance();