diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-02-18 16:07:40 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-02-18 16:09:47 +0100 |
commit | 71e0f5c99ce17f4f9313689f8b2bb299f22e78fb (patch) | |
tree | ab056aa95dae4f32922beb548fef031e71ddda93 /sonar-plugin-api | |
parent | 6900f586ea8f30c0a5a35b299f7461bd1bc867ae (diff) | |
download | sonarqube-71e0f5c99ce17f4f9313689f8b2bb299f22e78fb.tar.gz sonarqube-71e0f5c99ce17f4f9313689f8b2bb299f22e78fb.zip |
SONAR-2965 Provide a way to close JPA session to avoid DB timeout
Session will now be closed before running maven goals and before sensors.
A new session will automatically be opened on next try to access DB.
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java index 634538b7a27..7e78c150103 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java @@ -46,6 +46,13 @@ public abstract class DatabaseSession implements BatchComponent { public abstract void commit(); + /** + * This method should be called before a long period were database will not be accessed + * in order to close database connection and avoid timeout. Next use of the + * database will automatically open a new connection. + */ + public abstract void commitAndClose(); + public abstract void rollback(); public abstract <T> T save(T entity); @@ -65,7 +72,7 @@ public abstract class DatabaseSession implements BatchComponent { public abstract <T> T reattach(Class<T> entityClass, Object primaryKey); public abstract Query createQuery(String hql); - + public abstract Query createNativeQuery(String sql); public abstract <T> T getSingleResult(Query query, T defaultValue); |