Hi team,

I suspect you'll be able to answer this right off the top of your head, as
this error occurs in response to what I imagine is a very routine code
assignment: set a newly created user's company to be the same company as
that of the user doing the creating.


Code snippet from 'pages/user/CreateUser.java'...

    User user = new User(firstName, lastName, userName, email,
authenticator.encryptPassword(password));

    //Set the new user's company to the same as the creator's company
    user.setCompany(authenticator.getLoggedUser().getCompany());

    crudServiceDAO.create(user);


The User>>Company relationship, as defined in the User entity class...

    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="COMPANY_ID")
    private Company company;


The Company>>User relationship, as defined in the Company entity class...

    @OneToMany(mappedBy="company", cascade=CascadeType.ALL)
    private Collection<User> users = new ArrayList<User>();


The USER table has a COMPANY_ID field, so I'd be expecting Hibernate to
create a new user with the same company ID as the user I have logged in
as.  Instead, Tapestry gives the following error...

    org.apache.tapestry5.runtime.ComponentEventException

    detached entity passed to persist: com.example.harbour.entities.Company


Why is this?  Appreciate your help.

Thanks,

Chris.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to