Cayenne and EJB 3.0

From: Jone Lura (Jon..cc.as)
Date: Fri Jun 20 2008 - 12:53:25 EDT

  • Next message: Scott Anderson: "RE: weakly referenced paged queries"

    Hi,

    I am trying to use the Cayenne instead of Toplink JPA (Glassfish v2), while I wait for Cayenne JPA, but I have run into a small problem.

    I have created a class that extends the generated Cayenne class, and passing this between client/web and ejb with a SessionBean.

    public class User extends _User implements Serializable { ..}

    In my session bean I have a method for creating a new user and get all users.

    public User createUser(User user) {
            User newUser = context.newObject(User.class);

            newUser.setUserEmail(user.getUserEmail());
            newUser.setUserName(user.getUserName());

            context.commitChanges();

            return newUser;
    }

    this is working, but the values returned are all null.

    The same is for getting all users.
    public List<User> getAllUser() {
            SelectQuery query = new SelectQuery(User.class);

            List<EccUser> users = context.performQuery(query);

          return users;
    }

    In my webapplication the result of users.size() is as expected. But when trying to list the user values it all returns null.

    Does anyone have any experience with similar problems?

    I was thinking of creating a wrapper class like

    public class UserWrap implements Serializable {
        ..
        the same attributes as in User
        ..

        public UserWrap(User user) {
       ..
        this.attribute = user.getAttribute();
        ..
     }

    But I would like not to do this as the may be many changes in the entities, and then I manually have to enter the new field in the wrapping.

    Best regards
    Jone Lura



    This archive was generated by hypermail 2.0.0 : Fri Jun 20 2008 - 12:54:21 EDT