Well, it depends. If it has regular old properties then it should
work fine e.g.
Public class soldier extends Object {
Private String name;
Private String rank;
}
Should be fine.
If it contains collections of other objects though e.g.
Public class platoon extends Object {
Private String name;
Private Set soldiers;
}
Then you'll have a problem. Hibernate is *very* lazy about
initializing collections of subobjects so it'll fetch the platoon object but
not actually load the soldiers until you ask for them. So if you load the
platoon on Session 1, close session 1, and then do:
Set s = myPlatoon.getSoldiers();
You'll throw an error because hibernate will try to initialize the
platoon collection, but no longer have access to a session.
--- Pat
-----Original Message-----
From: Patrick Yip [mailto:[EMAIL PROTECTED]
Sent: Friday, May 06, 2005 10:50 AM
To: Tapestry users
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)
The object that created from the Hibernate session is a plain POJO.
Does it mean that once the hibernate session is closed, the object
became an "ophan" and would cause synchronization problem if I use it?
-----Original Message-----
From: Patrick Casey [mailto:[EMAIL PROTECTED]
Sent: Friday, May 06, 2005 10:42 AM
To: 'Tapestry users'
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)
Does the object in question have uninitialized collections
and/or
proxies references on it? If so it'll try to use the (closed) session to
resolve these references if it needs to.
You can potentially work around this.
Given an "orphan" object foo (an object whose session has been
closed)
Session newSession = ConfigurationFactory.createSession();
newSession.lock(orphan, LockMode.NONE);
The above will associate the object with the new "fresh" session
and
let it resolve proxies or lazy collections again.
--- Pat
-----Original Message-----
From: Patrick Yip [mailto:[EMAIL PROTECTED]
Sent: Friday, May 06, 2005 10:27 AM
To: Tapestry users
Subject: Error: JTATransaction Could not register Synchronization
(Tapestry
+Hibernate)
I keep getting this error: JTATransaction Could not register
Synchronization.
And I can't find the cause of it.
Question: will this cause the problem?
I created an object from a hibernate session and then set it as a
property on the next page
The hibernate session is closed immediately in the current page before
activating the next page.
When I continue on the next page and start using the object reference I
set earlier, would this cause the above error?
Any comment is greatly appreciated.
-Patrick
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]