Dale,
thank for your quick response.
For injecting the userDao I added the following into applicationContext.xml:
<bean id="simplePresenceManager"
class="org.cdtm.collasoa.service.impl.SimplePresenceManagerImpl">
<constructor-arg ref="userDao"/>
SimplePresenceManager the manager which updates the users.
In SimplePresenceManager I changed the constructor to
public SimplePresenceManagerImpl(UserDao dao) throws EventingException {
super();
this.userDao= dao;
}
Is this the correct way of injecting the userDao?
It seems to work so far, but when I actually call the UserDao, I get
exceptions.
I do the following in my Manager:
List users = userDao.getUsers();
Iterator<User> it = users.iterator();
User user = null;
while(it.hasNext()){
user = it.next();
if(user.getUsername().equals(username))
break;
}
if(user != null){
user.setFixedPhoneActive(phoneNumberActive);
user.setHomePhoneActive(homePhoneNumberActive);
user.setMobilePhoneActive(mobilePhoneNumberActive);
user.setSkypeNameActive(skypeNameActive);
userDao.save(user);
}
When saving I get the following exception at userDao.save:
ERROR [JmsSessionDispatcher: 2]
AbstractFlushingEventListener.performExecutions(
301) | Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by
another t
ransaction (or unsaved-value mapping was incorrect):
[org.appfuse.model.User#3]
at
org.hibernate.persister.entity.AbstractEntityPersister.check(Abstract
EntityPersister.java:1714)
at
org.hibernate.persister.entity.AbstractEntityPersister.update(Abstrac
tEntityPersister.java:2357)
at
org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert
(AbstractEntityPersister.java:2257)
at
org.hibernate.persister.entity.AbstractEntityPersister.update(Abstrac
tEntityPersister.java:2557)
at
org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.ja
va:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutio
ns(AbstractFlushingEventListener.java:298)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus
hEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at
org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary
(HibernateAccessor.java:390)
at
org.springframework.orm.hibernate3.HibernateTemplate.execute(Hibernat
eTemplate.java:373)
at
org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(Hib
ernateTemplate.java:686)
at
org.appfuse.dao.hibernate.UserDaoHibernate.saveUser(UserDaoHibernate.
java:40)
at
org.appfuse.dao.hibernate.UserDaoHibernate.save(UserDaoHibernate.java
:53)
at
org.appfuse.dao.hibernate.UserDaoHibernate.save(UserDaoHibernate.java
:1)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
on(AopUtils.java:304)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:198)
at $Proxy20.save(Unknown Source)
at
org.cdtm.collasoa.service.impl.SimplePresenceManagerImpl.onEvent(Simp
lePresenceManagerImpl.java:125)
.......
The code for updating the Users runs in different thread, could that be an
issue?
Any ideas how to resolve this?
Cheers,
Johannes
DNewfield wrote:
>
> cdtm wrote:
>> I have a manager that gets some data from another source (via
>> notification).
>> Upon reception of an event this manager has to update user information.
>
> So tell spring to inject the userDao into your other manager, and make
> calls to it.
>
> Since the manager method boundary is the transaction boundary, one
> manager really shouldn't call another one, but rather all manager
> methods should deal directly with the daos to get their work done. A
> manager can have any number of daos available, as long as the manager
> has the appropriate setters, and tells spring to provide the instances.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Update-User-from-another-Manager-tf4045113s2369.html#a11492039
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]