Re: [T5] A Hibernate question?

2007-11-23 Thread lasitha
On Nov 23, 2007 1:18 PM, Donyee [EMAIL PROTECTED] wrote:

 when i submit the editpage, i got a error:
 Illegal attempt to associate a collection with two open sessions
 ...

Donyee, i don't have time to look over you specific scenarion right
now, but you might be running into this:
https://issues.apache.org/jira/browse/TAPESTRY-1850

Related discussion:
http://article.gmane.org/gmane.comp.java.tapestry.user/53095

You can test the theory by overriding and aliasing the HSM in your AppModule:

@Scope(PERTHREAD_SCOPE)
public HibernateSessionManager buildPatchedSessionManager(
HibernateSessionSource sessionSource,
ThreadCleanupHub threadCleanupHub) {

HibernateSessionManagerImpl manager =
new HibernateSessionManagerImpl(sessionSource) {
@Override public void threadDidCleanup() {
super.threadDidCleanup();
getSession().close();
}
};

threadCleanupHub.addThreadCleanupListener(manager);
return manager;
}

public void contributeAlias(
ConfigurationAliasContribution? configuration,
@InjectService(PatchedSessionManager)
HibernateSessionManager extendedManager) {

configuration.add(
AliasContribution.create(
HibernateSessionManager.class, extendedManager));
}

Cheers,
lasitha.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5] A Hibernate question?

2007-11-23 Thread sun58224
不要用session.saveOrUpdate(page);如果没记错,用merge()。




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5] A Hibernate question?

2007-11-23 Thread Angelo Chen

Hi Lasitha,

I don't know if the thread you pointed out is applicable to this topic, I
started that one, the problem was due to the pesisted object, I finally
solve that problem by removing the @Persist, now I'm trying to persist
everything in the client side to avoid this problem(only the object id,
reload in onActivate), and program has been working well. the persisted
object seems causing problems from time to time, I made the following rule
in my coding: use @Persist only when an object is @InjectPage to another
page and some instances have to be set, otheriwse all @Persist free, the
rule does work well, but I don't know if this is a correct conclusion:

You need @Persist only when the page will be injected?

Thanks,

A.C.


lasitha wrote:
 
 On Nov 23, 2007 1:57 PM, lasitha [EMAIL PROTECTED] wrote:
 
 I guess i should also point out the following thread which proposes an
 alternate solution, though i personally don't agree with it :)
 http://www.nabble.com/T5%3A-how-to-use-a-detached-hibernate-object-in-a-form--tf4669657.html#a13339389
 Cheers, lasitha.
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-T5--A-Hibernate-question--tf4860162.html#a13909796
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[T5] A Hibernate question?

2007-11-22 Thread Donyee
I use tapestry-hibernate in my apps,
in one page:
t:grid source=pageList row=page2
t:parameter name=pageIdcell
t:actionLink id=pageDelete context=${page2.pageId}删除/t:actionLink
t:pageLink page=sysadm/editpage context=${page2.pageId}更新/t:pageLink
/t:parameter
/t:grid

in editpage.java
void onActivate(String id) {

page = (Page) session.createCriteria(Page.class).add(
Restrictions.eq(pageId, id)).uniqueResult();
}

void onSuccess() {
session.saveOrUpdate(page);
}


when i submit the editpage, i got a error:
Illegal attempt to associate a collection with two open sessions
...

anyone helps?