You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Jone Lura <Jo...@ecc.as> on 2008/06/20 18:53:25 UTC

Cayenne and EJB 3.0

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