1

We are implementing a web application based on the Liferay. The database is handled by JPA 2.0 and Entity Manager.

When the system is idle for a long period (e.g. 8 hours), the Session in the Persistance Context will be lost and the database will be out of the access. Is there any configuration which can fix this problem?

john_science
  • 6,325
  • 6
  • 43
  • 60
Babak Behzadi
  • 1,236
  • 2
  • 16
  • 33
  • I bet it is the database connection getting disconnected due to idle? Depending on how you manage database connections, normally data source in containers, or connection pools you used, may have features of keep alive polling. You may see if it is available – Adrian Shum Sep 05 '12 at 03:45
  • Thanks, May the firewall refuse the connection?? – Babak Behzadi Sep 05 '12 at 07:12

1 Answers1

0

Maybe you can set this property:

<property name="minIdle" value="1"/>

When you declare your DataSource bean

UPDATE: If you use persistence.xml of hibernate, You should set the property: hibernate.c3p0.min_size: the minimum number of JDBC connections that C3P0 keeps ready at all times

<property name="hibernate.c3p0.min_size" value="1"/>
Khue Vu
  • 3,112
  • 4
  • 37
  • 40
  • I use persistence unit. should I insert this property in my PU.xml? – Babak Behzadi Sep 05 '12 at 08:16
  • I updated my answer. You could refer to this question as well: http://stackoverflow.com/questions/475893/what-are-the-required-c3p0-settings-for-hibernate-in-order-to-avoid-deadlocks – Khue Vu Sep 05 '12 at 08:48