Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » TENEO Session Controller(TENEO Session Controller keeping it open for long time)
TENEO Session Controller [message #1152703] Thu, 24 October 2013 05:55 Go to next message
Chandre Gowda is currently offline Chandre GowdaFriend
Messages: 56
Registered: April 2013
Member
Iam trying to persist EMF model using TENEO framework. So i have used sessionController to get the session and start the transaction.
sessionController = new SessionController();
sessionController.setHbDataStore(hbdataStore);

after creating the controller, iam doing following steps to persist emfobject.

sessionController.getSessionWrapper().beginTransaction()
sessionController.getSessionWrapper().saveOrUpdate(emfObject)
sessionController.getSessionWrapper().commitTransaction().

I have deployed the above bundles on Virgo Server.
After leaving the Virgo server on for long time,Iam getting below error whenever i try to access any database operation.

No operations allowed after connection closed.
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)

How do we keep the hibernate connection open as long as server is on.

Thanks
Chandru
Re: TENEO Session Controller [message #1153172 is a reply to message #1152703] Thu, 24 October 2013 12:30 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Chandre,
You can also get a session from the DataStore's sessionFactory. That I thinks brings you closer to standard hibernate.

I think there is probably some mysql timeout which hurts you here. Not sure which one do, maybe mysql has a connection
idle timeout (you need to check).

Or maybe you close the connection/session in a separate thread somehow (if you share sessions between threads which you
shouldn't do if you do).

In any case, in the web applications I develop the sessions (and their connections) are normally much more short lived.
I keep the session open for a request and close it at the end of a request. With connection pooling this is not less
efficient then keeping a session open.
Keeping a session open has as disadvantage that the data in the session cache can be stale, that it has changed already
in the database.
I don't know your specific case, but I don't know many use cases for keeping a session open during the lifetime of a
server, but that's just me :-).

If the session cache is unfamiliar to you, then it is best to read up hibernate's first and second level caches. See the
hibernate documentation on the net.

gr. Martin

On 10/24/2013 07:55 AM, Chandre Gowda wrote:
> Iam trying to persist EMF model using TENEO framework. So i have used sessionController to get the session and start the
> transaction. sessionController = new SessionController();
> sessionController.setHbDataStore(hbdataStore);
>
> after creating the controller, iam doing following steps to persist emfobject.
>
> sessionController.getSessionWrapper().beginTransaction()
> sessionController.getSessionWrapper().saveOrUpdate(emfObject)
> sessionController.getSessionWrapper().commitTransaction().
>
> I have deployed the above bundles on Virgo Server.
> After leaving the Virgo server on for long time,Iam getting below error whenever i try to access any database operation.
>
> No operations allowed after connection closed. at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:150)
> at java.net.SocketInputStream.read(SocketInputStream.java:121)
> at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
> at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
> at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
>
> How do we keep the hibernate connection open as long as server is on.
>
> Thanks
> Chandru


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: TENEO Session Controller [message #1158921 is a reply to message #1153172] Mon, 28 October 2013 07:18 Go to previous messageGo to next message
Chandre Gowda is currently offline Chandre GowdaFriend
Messages: 56
Registered: April 2013
Member
Thanks Martin.
We have a situation where EMF Model A references B which in turn references C. So whenever we try to persist A,B and C require same session to persist the changes. But we have separate calls from UI to persist A,B and C. if I don't manage single session then I cannot commit model B and Model c after committing Model A. please suggest if I could use SessionController to have single session across the application to persist the models Or is there any other way in TENEO-HIBERNATE to persist referenced models separately. Also our model has lot of not containment references and if i use sessionfactory.openSession then, get lazy initialization failed, session closed error. So please suggest a way to persist EMF models which have referenced models and non containement models.
Re: TENEO Session Controller [message #1159172 is a reply to message #1158921] Mon, 28 October 2013 10:43 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Chandre,
Okay, even if you have one session for the whole application (I guess you mean per user), even then persisting A, B and
C separately is difficult, if a user first persists A then that's not possible as it references B which references C. Or
is a certain order enforced?
In general it is much (much) easier to send all the related changes/additions in one request. So if possible I would
research that approach further. But maybe in your case it is different.

You don't session controller, you can also directly get a hibernate session and manage it yourselve in some
User/Application context.

So not sure how I can help other than providing some larger architectural advice. But not sure if that's suited for this
forum...

gr. Martin

On 10/28/2013 08:18 AM, Chandre Gowda wrote:
> Thanks Martin.
> We have a situation where EMF Model A references B which in turn references C. So whenever we try to persist A,B and
> C require same session to persist the changes. But we have separate calls from UI to persist A,B and C. if I don't
> manage single session then I cannot commit model B and Model c after committing Model A. please suggest if I could use
> SessionController to have single session across the application to persist the models Or is there any other way in
> TENEO-HIBERNATE to persist referenced models separately. Also our model has lot of not containment references and if i
> use sessionfactory.openSession then, get lazy initialization failed, session closed error. So please suggest a way to
> persist EMF models which have referenced models and non containement models.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:[EMF Store] update project programatically
Next Topic:[Teneo] How to use real text datatypes in database?
Goto Forum:
  


Current Time: Wed Apr 24 23:47:52 GMT 2024

Powered by FUDForum. Page generated in 0.03160 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top