This content has been marked as final.
Show 2 replies
-
1. Re: Create annotation persist object problem.
vdweij Jul 22, 2008 8:54 AM (in response to bashan)Guy,
The create annotation is simply called after your component (containing the annotation) has been instantiated. It doesn't tell the EntityManager to persist some newly created object.
If you post relevant part of your code it should provide more information to solve your problem. My best bet at this moment is that you have to explicitly persist the user account.
-
2. Re: Create annotation persist object problem.
bashan Jul 22, 2008 10:04 AM (in response to bashan)I do persist the object, maybe the transaction is not committed? In other screens, when I persist object inside an action it seems to be working fine.
this is my bean:
@Name("activation") public class ActivationAction { @In private User user; private FacesMessages facesMessages; @In Session myDatabase; @Logger private Log log; @In private UserDAO userDAO; @RequestParameter("confirmationCode") private String confirmationCode; private String status; @Create public void activateAccount() { User user = userDAO.getUserByActivationCode(confirmationCode); if (user != null) { if (user.getStatus() == UserStatus.NEW) { log.info("Activating account for new user: #{user.email} (#{user.userId}), activation code: #{param['confirmationCode']}"); user = (User)myDatabase.merge(user); user.setStatus(UserStatus.ACTIVE); myDatabase.persist(user); status = "activated"; } else { log.info("Account was already activated for user: #{user.email} (#{user.userId}), activation code: #{param['confirmationCode']}"); status = "alreadyActive"; } } else { log.info("No user was found for activation code: #{param['confirmationCode']}"); status = "notFound"; } } public String getStatus() { return status; } }