Dear Allen and Craig,
Thanks a million! I've followed the instructions below and it works now.
Allen Gilliland wrote:
Ahhh, this is an excellent example of why it's important to impose tight
restrictions on some code to prevent inappropriate use. It *should* be
hard (if not impossible) for someone to do 2 of the things below ... 1)
construct a specific persistence strategy class and 2) directly
instantiate a manager impl class :/
Jm,
the simple answer to your question is that you need to flush your
changes to the database by calling the flush() method on the active
Roller instance being used by the system. Normally you would do this
via RollerFactory.getRoller().flush();
on a secondary note, you are actually doing the 2 things that I
mentioned above incorrectly. you do not want to instantiate the
HibernateUserManagerImpl yourself, that will certainly cause problems.
Instead what you want to do is this ...
UserManager usersMan = RollerFactory.getRoller.getUserManager();
So, in pseudo code what you should be doing is this ...
umgr = roller.getUserManager() (as detailed above)
newUser = new UserData()
... set user data ...
umgr.addUser(newUser)
roller.flush() // changes now go to DB
-- Allen
Jm Seigneur wrote:
Hello,
I've been trying to create new roller users with
HibernateUserManagerImpl as follows:
...
HibernatePersistenceStrategy strat = new HibernatePersistenceStrategy();
HibernateUserManagerImpl usersMan = new HibernateUserManagerImpl(strat);
UserData jm = usersMan.getUserByUserName("Jm"); //This works and I
retrieve my roller account information
log.debug("Jm's email address is " + jm.getEmailAddress());
UserData newRollerUser = new UserData();
newRollerUser.setUserName(onlineUser.getMemberName());
newRollerUser.setPassword(memberPassword);
newRollerUser.setFullName(memberFirstname + " " + memberLastname);
newRollerUser.setEmailAddress(memberFirstEmail);
newRollerUser.setLocale(jm.getLocale());
newRollerUser.setTimeZone(jm.getTimeZone());
newRollerUser.setDateCreated(memberCreationDate);
newRollerUser.setEnabled(true);
usersMan.addUser(newRollerUser); //It seems to work, there is no
exception but the new user is not created in the database
...
Any idea why I can read the content of the database but I cannot write
in the database ?
Thanks,
Jm