0 Replies Latest reply on Sep 23, 2005 11:34 PM by Baba Booey

    Could not deserialize

    Baba Booey Newbie

      Hi All,

      I can't figure why I am getting the following errors:

      javax.ejb.EJBException: null; CausedByException is:
       could not deserialize
      ...
      ...
      org.hibernate.type.SerializationException: could not deserialize
      ...
      ...
      


      Here is the code:

      User.java
      @Entity
      @Inheritance(strategy=InheritanceType.JOINED)
      @Table(name="USERS")
      public abstract class User implements Serializable {
       private String userName, group;
      
       public User() {
       userName = new String();
       group = new String();
       }
      
       @Id
       @Column(name="USERNAME")
       public String getUserName() {
       return this.userName;
       }
      
       public void setUserName(String userName) {
       this.userName = userName;
       }
      
       @Column(name="GROUP")
       public String getGroup() {
       return this.group;
       }
      
       public void setGroup(String group) {
       this.group = group;
       }
      }
      


      PreferenceAction.java
      public class PreferenceAction extends BaseDispatchAction {
       public ActionForward view(ActionMapping mapping,
       ActionForm form,
       HttpServletRequest request,
       HttpServletResponse response)
       throws Exception
       {
       doView(form, request);
       return mapping.findForward(IConstants.SUCCESS_KEY);
       }
      
       private void doView(ActionForm form, HttpServletRequest request)
       throws Exception
       {
       Preference preference = factory.getApplicationBean().getPreference((User)getUser());
       ...
       ...
       }
      }
      


      Preference.java
      @Entity
      @Table(name="PREFERENCES")
      public class Preference implements Serializable {
       private User user;
       private String first, ...;
      
       public Preference() {
       user = null;
       first = new String();
       ...
       ...
       }
      
       @Id
       @OneToOne
       @JoinColumn(name="USERNAME")
       public User getUser() {
       return this.user;
       }
      
       public void setUser(User user) {
       this.user = user;
       }
      
       @Column(name="FIRST")
       public String getFirst() {
       return this.first;
       }
      
       public void setFirst(String first) {
       this.first = first;
       }
      
       ...
       ...
      }
      


      ApplicationBean.java
      @Stateless
      public class ApplicationBean implements Application {
       @PersistenceContext(unitName="db")
       EntityManager em;
      
       public Preference getPreference(User user) {
       return (Preference) em.createQuery("from Preference p where p.user = :user")
       .setParameter ("user", user)
       .getSingleResult();
       }
      }
      


      Thanks!!