Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge remote-tracking branch 'gekkio/hibernate4'

  • Loading branch information...
commit 0991ae92728d61e35be4970cbb48d1b8185de651 2 parents 2506a1c + f9ddaee
Ville Seppä authored

Showing 66 changed files with 438 additions and 1,320 deletions. Show diff stats Hide diff stats

  1. +0 8 distribution/assembly.xml
  2. +0 48 distribution/doc/Summary_about_used_libraries.txt
  3. +0 8 distribution/doc/dev/Actions.txt
  4. +0 6 distribution/doc/dev/DAOs.txt
  5. +0 68 distribution/doc/dev/README_for_developers.txt
  6. +0 6 distribution/doc/dev/hibernate_DAOs.txt
  7. +0 5 distribution/doc/dev/tags.txt
  8. +0 21 distribution/doc/upgrade/README.txt
  9. +16 49 pom.xml
  10. +0 12 webapp/legacy/database-mysql5.properties
  11. +0 82 webapp/legacy/hibernate.cfg.xml
  12. +10 4 webapp/pom.xml
  13. +21 6 webapp/src/main/java/fi/hut/soberit/agilefant/business/impl/SettingBusinessImpl.java
  14. +3 3 webapp/src/main/java/fi/hut/soberit/agilefant/config/DaoConfiguration.java
  15. +1 1  webapp/src/main/java/fi/hut/soberit/agilefant/config/TransactionConfiguration.java
  16. +1 1  webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/AssignmentDAOHibernate.java
  17. +7 8 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/BacklogDAOHibernate.java
  18. +2 2 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/BacklogHistoryEntryDAOHibernate.java
  19. +4 7 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/BacklogHourEntryDAOHibernate.java
  20. +8 3 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/Email.java
  21. +11 20 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/EmailValidator.java
  22. +0 116 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/EnumUserType.java
  23. +34 27 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/GenericDAOHibernate.java
  24. +1 1  webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/HolidayDAOHibernate.java
  25. +22 34 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/HourEntryDAOHibernate.java
  26. +20 21 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/IterationDAOHibernate.java
  27. +7 8 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/IterationHistoryEntryDAOHibernate.java
  28. +3 3 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/LabelDAOHibernate.java
  29. +7 8 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/ProductDAOHibernate.java
  30. +11 14 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/ProjectDAOHibernate.java
  31. +33 25 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/SettingDAOHibernate.java
  32. +1 1  webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/StoryAccessDAOHibernate.java
  33. +15 15 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/StoryDAOHibernate.java
  34. +23 28 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/StoryHierarchyDAOHibernate.java
  35. +3 3 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/StoryRankDAOHibernate.java
  36. +12 12 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/TaskDAOHibernate.java
  37. +4 8 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/TaskHourEntryDAOHibernate.java
  38. +17 12 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/TextUserType.java
  39. +17 12 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/TruncatedStringUserType.java
  40. +4 4 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/UserDAOHibernate.java
  41. +28 26 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/UserTypeFilter.java
  42. +17 12 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/VarcharUserType.java
  43. +6 6 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/WhatsNextEntryDAOHibernate.java
  44. +1 1  webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/WidgetCollectionDAOHibernate.java
  45. +9 12 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/notification/NotificationEventListener.java
  46. +6 7 webapp/src/main/java/fi/hut/soberit/agilefant/db/history/impl/BacklogHistoryDAOImpl.java
  47. +2 1  webapp/src/main/java/fi/hut/soberit/agilefant/model/BacklogHistoryEntry.java
  48. +2 1  webapp/src/main/java/fi/hut/soberit/agilefant/model/HourEntry.java
  49. +3 2 webapp/src/main/java/fi/hut/soberit/agilefant/model/Iteration.java
  50. +1 1  webapp/src/main/java/fi/hut/soberit/agilefant/model/IterationHistoryEntry.java
  51. +2 1  webapp/src/main/java/fi/hut/soberit/agilefant/model/Label.java
  52. +3 2 webapp/src/main/java/fi/hut/soberit/agilefant/model/Project.java
  53. +2 1  webapp/src/main/java/fi/hut/soberit/agilefant/model/StoryAccess.java
  54. +1 1  webapp/src/main/webapp/WEB-INF/applicationContext-security.xml
  55. +2 47 webapp/src/main/webapp/WEB-INF/hibernate.cfg.xml
  56. +1 1  webapp/src/main/webapp/WEB-INF/web.xml
  57. +26 4 webapp/src/test/java/fi/hut/soberit/agilefant/business/SettingBusinessTest.java
  58. +0 6 webapp/src/test/resources/WEB-INF/configuration.properties
  59. +0 8 webapp/src/test/resources/WEB-INF/database.properties
  60. +0 46 webapp/src/test/resources/WEB-INF/hibernate.cfg.xml
  61. +0 178 webapp/src/test/resources/checkstyle/checkstyle-noframes-sorted.xsl
  62. +0 171 webapp/src/test/resources/checkstyle/sun_checks.xml
  63. +2 3 webapp/src/test/resources/fi/hut/soberit/agilefant/db/GenericDAOTest-context.xml
  64. +2 15 webapp/src/test/resources/testApplicationContext-forDaos.xml
  65. +2 33 webapp/src/test/resources/testApplicationContext-forHistory.xml
  66. +2 14 webapp/src/test/resources/testApplicationContext-forIntegration.xml
8 distribution/assembly.xml
@@ -25,20 +25,12 @@
25 25 <outputDirectory>/</outputDirectory>
26 26 </file>
27 27 <file>
28   - <source>doc/Summary_about_used_libraries.txt</source>
29   - <outputDirectory>/</outputDirectory>
30   - </file>
31   - <file>
32 28 <source>doc/Install.txt</source>
33 29 <outputDirectory>/</outputDirectory>
34 30 </file>
35 31 </files>
36 32 <fileSets>
37 33 <fileSet>
38   - <directory>doc/upgrade</directory>
39   - <outputDirectory>/upgrade</outputDirectory>
40   - </fileSet>
41   - <fileSet>
42 34 <directory>doc/sql/upgrader</directory>
43 35 <outputDirectory>/upgrade</outputDirectory>
44 36 </fileSet>
48 distribution/doc/Summary_about_used_libraries.txt
... ... @@ -1,48 +0,0 @@
1   -Agilefant employs several third party libraries, which are listed below.
2   -Agilefant itself doesn't directly use all these libraries, but their
3   -existence may be required by some other included library (e.g. Spring).
4   -
5   ---------------------------
6   -spring-security: http://static.springframework.org/spring-security/site/
7   -spring-security-tiger:
8   -antlr: http://www.antlr.org/
9   -asm: http://asm.objectweb.org/
10   -asm-attrs: http://asm.objectweb.org/jdiff153to223/changes/pkg_org.objectweb.asm.attrs.html
11   -cglib: http://cglib.sourceforge.net/
12   -commons-beanutils: http://jakarta.apache.org/commons/beanutils/
13   -commons-codec: http://jakarta.apache.org/commons/codec/
14   -commons-collections: http://jakarta.apache.org/commons/collections/
15   -commons-dbcp: http://jakarta.apache.org/commons/dbcp/
16   -commons-lang: http://jakarta.apache.org/commons/lang/
17   -commons-logging: http://jakarta.apache.org/commons/logging/
18   -commons-pool: http://jakarta.apache.org/commons/pool/
19   -displytag: http://displaytag.sourceforge.net/
20   -dom4j: http://www.dom4j.org/
21   -ehcache: http://ehcache.sourceforge.net/
22   -ejb3-persistence:
23   -freemaker: http://freemarker.sourceforge.net/
24   -hibernate3: http://www.hibernate.org/
25   -hibernate-annotations: http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/
26   -javamail: http://java.sun.com/products/javamail/
27   -jcommon: http://www.jfree.org/jcommon/
28   -jfreechart: http://www.jfree.org/jfreechart/index.html
29   -jstl: http://java.sun.com/products/jsp/jstl/
30   -jstree: http://www.jstree.com/
31   -jta: http://java.sun.com/products/jta/
32   -log4j: http://logging.apache.org/log4j/docs/
33   -mysql-connector-java: http://www.mysql.com/products/connector/j/
34   -ognl: http://www.ognl.org/about.html
35   -oro: http://jakarta.apache.org/oro/
36   -oscore: http://www.opensymphony.com/oscore/
37   -postgresql-8.1-407.jdbc3:
38   -rife-continuations: http://rifers.org/wiki/display/RIFECNT/Home
39   -serializer: http://xml.apache.org
40   -spring: http://www.springframework.org/
41   -spring-mock:
42   -standard:
43   -webwork: http://www.opensymphony.com/webwork/
44   -xalan: http://xml.apache.org
45   -xercesimp: http://xml.apache.org
46   -xml-apis: http://xml.apache.org
47   -xwork: powering webwork, http://www.opensymphony.com/xwork/
48   -xwork-tiger: j2s2 5 support for webwork
8 distribution/doc/dev/Actions.txt
... ... @@ -1,8 +0,0 @@
1   -TODO comments ekantola, kheleniu, jmrantal
2   -
3   - -How (for what) are the files in \src\...\agilefant\web\ (XXXAction.java) used?
4   - -Who calls, and what parts of the system are called from here.
5   - -Relating libraries?
6   -
7   - CRUDAction contains basic Actions such as create and delete, which are widely applicable.
8   -
6 distribution/doc/dev/DAOs.txt
... ... @@ -1,6 +0,0 @@
1   -TODO comments kheleniu, tiaijala
2   - How the files in \db\ (XXXDAO.java) are used?
3   - Who calls, and what parts of the system is called from here).
4   - Relating libraries?
5   -
6   - DAO = Data Access Object
68 distribution/doc/dev/README_for_developers.txt
... ... @@ -1,68 +0,0 @@
1   -README for AgilEfant developers
2   --------------------------------
3   -This document is intended for people who are interested in developing
4   -AgilEfant by fixing old bugs or adding new functionality. It mainly
5   -describes where to look for first and which files to put focus on.
6   -
7   -Before starting any development work with AgilEfant, one should familiarize
8   -himself with Cycles Of Control concept, Hibernate, WebWork, Spring and
9   -their configurations and with concepts like dependency injection and
10   -transaction management. Very good knowledge of J2EE is also required for
11   -good results.
12   -
13   -Directory structure
14   ----
15   -Directory structure is self explaining enough for any experienced developer
16   -so there's no need to go it through here.
17   -
18   -Important configuration files
19   ----
20   -- Hibernate
21   -When adding classes for Hibernate to be persisted, remember to add your class
22   -to also to conf/hibernate.cfg.xml so that Hibernate will use it to load
23   -mappings.
24   -
25   -- WebWork
26   -WebWork configuation is located in conf/classes/xwork.xml and
27   -conf/classes/webwork.properties. All classes used in xwork.xml are loaded
28   -using Spring as a object factory. This means that the classes are declared
29   -as a non-singleton beans in Springs application context. Read WebWork
30   -documentation for information.
31   -
32   -System wide converters are declared in xwork-conversion.properties.
33   -
34   -XWork annotations are used in certain classes. XWork 1.2.1 (current version when
35   -writing this) had all annotation classes missing @Retention annotation causing
36   -them not to work. web/WEB-INF/classes contains fixed binaries for required
37   -classes. This bug has been reported to OpenSymphony and will be fixed in
38   -XWork 1.2.1.
39   -
40   -- Spring
41   -Beans are initialized by reading all applicationContext*.xml files from conf.
42   -Suffix of the file tries to describe the area where it belongs. Feel free
43   -to add your own files if needed to keep configuration files small enough.
44   -
45   -Keep in mind that all WebWork classes (actions and interceptors) are
46   -configured in applicationContext-actions.xml. To avoid unnecessary
47   -configuration lines byName autowire strategy is used, so keep that in mind when
48   -declaring your own beans. Remember also that all actions MUST be
49   -declared as singleton set to false. Forgetting this makes same
50   -instance of class to be shared between all requests causing odd behaviour.
51   -
52   -Where to start
53   ----
54   -Most of the actual business logic of AgilEfant is located in package
55   -fi.hut.soberit.agilefant.web. When adding new functionality, that's the
56   -place to start.
57   -
58   -
59   -
60   -
61   -
62   -
63   -
64   -
65   -
66   -
67   -
68   -
6 distribution/doc/dev/hibernate_DAOs.txt
... ... @@ -1,6 +0,0 @@
1   -TODO comments kheleniu, tiaijala
2   - How the files in \db\hibernate\event (XXXDAOHibernate.java) are used?
3   - Who calls them, and what parts of the system is called from here?
4   - Relating ibraries?
5   -
6   - DAO = Data Access Object
5 distribution/doc/dev/tags.txt
... ... @@ -1,5 +0,0 @@
1   -TODO comments kheleniu jmrantal
2   -
3   - Files in \web\tag\:
4   - What are the Tags for.
5   - Who uses them for what?
21 distribution/doc/upgrade/README.txt
... ... @@ -1,21 +0,0 @@
1   -+-------------------------------+
2   -| NOTICE ON UPGRADING AGILEFANT |
3   -+-------------------------------+
4   -
5   -See http://www.agilefant.org/wiki/display/AEF/Upgrade+instructions for full
6   -upgrade instructions.
7   -
8   -If you are upgrading from a version older than 2.0, please upgrade to 2.0 first.
9   -
10   -
11   -NOTE!
12   -The script will generate a backup of your MySQL database. Please move it to a
13   -secure location after running the update.
14   -
15   -
16   -Windows:
17   - * In command prompt, run the agilefant_upgrader.bat
18   -
19   -Unix (Linux/OS X):
20   - * In terminal, run the agilefant_upgrader.sh
21   -
65 pom.xml
@@ -25,8 +25,8 @@
25 25 <glassfish.jstl.version>1.2</glassfish.jstl.version>
26 26 <guava.version>13.0.1</guava.version>
27 27 <h2.version>1.1.114</h2.version>
28   - <hibernate.version>3.5.3-Final</hibernate.version>
29   - <hibernate.validator.version>3.1.0.GA</hibernate.validator.version>
  28 + <hibernate.version>4.1.9.Final</hibernate.version>
  29 + <hibernate.validator.version>4.3.1.Final</hibernate.validator.version>
30 30 <httpclient.version>4.1.3</httpclient.version>
31 31 <javax.annotation.version>1.0</javax.annotation.version>
32 32 <javax.mail.version>1.4.5</javax.mail.version>
@@ -36,7 +36,6 @@
36 36 <jersey.version>1.17</jersey.version>
37 37 <jfreechart.version>1.0.14</jfreechart.version>
38 38 <joda.time.version>2.1</joda.time.version>
39   - <joda.time.hibernate.version>1.2</joda.time.hibernate.version>
40 39 <joda.time.jsptags.version>1.1.1</joda.time.jsptags.version>
41 40 <junit.version>4.11</junit.version>
42 41 <logback.version>1.0.9</logback.version>
@@ -47,8 +46,9 @@
47 46 <spring.version>3.2.1.RELEASE</spring.version>
48 47 <spring.security.version>3.1.3.RELEASE</spring.security.version>
49 48 <stringtemplate.version>3.0</stringtemplate.version>
50   - <struts.version>2.1.8.1</struts.version>
  49 + <struts.version>2.2.3.1</struts.version>
51 50 <typesafe.config.version>1.0.0</typesafe.config.version>
  51 + <usertype.version>3.0.0.GA</usertype.version>
52 52
53 53 <maven.compiler.version>3.0</maven.compiler.version>
54 54 <maven.war.version>2.3</maven.war.version>
@@ -199,37 +199,6 @@
199 199 </dependency>
200 200 <dependency>
201 201 <groupId>joda-time</groupId>
202   - <artifactId>joda-time-hibernate</artifactId>
203   - <version>${joda.time.hibernate.version}</version>
204   - <exclusions>
205   - <exclusion>
206   - <artifactId>antlr</artifactId>
207   - <groupId>antlr</groupId>
208   - </exclusion>
209   - <exclusion>
210   - <artifactId>cglib-full</artifactId>
211   - <groupId>cglib</groupId>
212   - </exclusion>
213   - <exclusion>
214   - <artifactId>commons-logging-api</artifactId>
215   - <groupId>commons-logging</groupId>
216   - </exclusion>
217   - <exclusion>
218   - <artifactId>hsqldb</artifactId>
219   - <groupId>hsqldb</groupId>
220   - </exclusion>
221   - <exclusion>
222   - <artifactId>ehcache</artifactId>
223   - <groupId>ehcache</groupId>
224   - </exclusion>
225   - <exclusion>
226   - <artifactId>hibernate</artifactId>
227   - <groupId>org.hibernate</groupId>
228   - </exclusion>
229   - </exclusions>
230   - </dependency>
231   - <dependency>
232   - <groupId>joda-time</groupId>
233 202 <artifactId>joda-time-jsptags</artifactId>
234 203 <version>${joda.time.jsptags.version}</version>
235 204 </dependency>
@@ -284,18 +253,18 @@
284 253 <groupId>org.apache.struts</groupId>
285 254 <artifactId>struts2-core</artifactId>
286 255 <version>${struts.version}</version>
  256 + <exclusions>
  257 + <exclusion>
  258 + <!-- Invalid groupId -->
  259 + <groupId>javassist</groupId>
  260 + <artifactId>javassist</artifactId>
  261 + </exclusion>
  262 + </exclusions>
287 263 </dependency>
288 264 <dependency>
289 265 <groupId>org.apache.struts</groupId>
290 266 <artifactId>struts2-junit-plugin</artifactId>
291 267 <version>${struts.version}</version>
292   - <exclusions>
293   - <!-- No longer exists in Spring >= 2.5 -->
294   - <exclusion>
295   - <groupId>org.springframework</groupId>
296   - <artifactId>spring-mock</artifactId>
297   - </exclusion>
298   - </exclusions>
299 268 </dependency>
300 269 <dependency>
301 270 <groupId>org.apache.struts</groupId>
@@ -316,13 +285,6 @@
316 285 <groupId>org.easymock</groupId>
317 286 <artifactId>easymock</artifactId>
318 287 <version>${easymock.version}</version>
319   - <exclusions>
320   - <!-- Prevent duplicate cglib + cglib-nodep dependencies -->
321   - <exclusion>
322   - <groupId>cglib</groupId>
323   - <artifactId>cglib-nodep</artifactId>
324   - </exclusion>
325   - </exclusions>
326 288 </dependency>
327 289 <dependency>
328 290 <groupId>org.easymock</groupId>
@@ -381,6 +343,11 @@
381 343 <version>${hibernate.validator.version}</version>
382 344 </dependency>
383 345 <dependency>
  346 + <groupId>org.jadira.usertype</groupId>
  347 + <artifactId>usertype.core</artifactId>
  348 + <version>${usertype.version}</version>
  349 + </dependency>
  350 + <dependency>
384 351 <groupId>org.jfree</groupId>
385 352 <artifactId>jfreechart</artifactId>
386 353 <version>${jfreechart.version}</version>
12 webapp/legacy/database-mysql5.properties
... ... @@ -1,12 +0,0 @@
1   -#TODO comments ekantola - Hibernate uses this file if database in is MySql5(?)
2   -#(Where this is used, and, for what? One line of comment is good enough.
3   -
4   -hibernate.connection.username=agilefant
5   -hibernate.connection.password=agilefant
6   -hibernate.connection.url=jdbc:mysql://localhost/agilefant?relaxAutoCommit\=true&amp;autoReconnect\=true&amp;useUnicode\=true&amp;characterEncoding\=utf-8&amp;autoReconnectForPools\=true
7   -hibernate.connection.driver_class=com.mysql.jdbc.Driver
8   -hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
9   -hibernate.show_sql=false
10   -hibernate.max_fetch_depth=1
11   -#hibernate.hbm2ddl.auto=
12   -#hibernate.jdbc.batch_size=
82 webapp/legacy/hibernate.cfg.xml
... ... @@ -1,82 +0,0 @@
1   -<?xml version='1.0' encoding='utf-8'?>
2   -<!DOCTYPE hibernate-configuration PUBLIC
3   -"-//Hibernate/Hibernate Configuration DTD//EN"
4   -"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
5   -
6   -
7   -
8   -<!-- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
9   - Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
10   - Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception
11   - is java.lang.ClassFormatError: Illegal class name "fi/hut/soberit/agilefant/model/package-info" in class file fi/hut/soberit/agilefant/model/package-info -->
12   -
13   -<hibernate-configuration>
14   - <session-factory name="hibernateSessionFactory">
15   - <!-- we need the package mapping to make package-info.java work, but it won't map all the package classes -->
16   - <property name="org.hibernate.envers.store_data_at_delete">true</property>
17   -
18   - <mapping package="fi.hut.soberit.agilefant.model" />
19   -
20   - <mapping class="fi.hut.soberit.agilefant.model.Assignment" />
21   - <mapping class="fi.hut.soberit.agilefant.model.Backlog" />
22   - <mapping class="fi.hut.soberit.agilefant.model.BacklogHistoryEntry" />
23   - <mapping class="fi.hut.soberit.agilefant.model.BacklogHourEntry" />
24   - <mapping class="fi.hut.soberit.agilefant.model.ExactEstimate" />
25   - <mapping class="fi.hut.soberit.agilefant.model.SignedExactEstimate" />
26   - <mapping class="fi.hut.soberit.agilefant.model.Iteration" />
27   - <mapping class="fi.hut.soberit.agilefant.model.IterationHistoryEntry" />
28   - <mapping class="fi.hut.soberit.agilefant.model.Label" />
29   - <mapping class="fi.hut.soberit.agilefant.model.Product" />
30   - <mapping class="fi.hut.soberit.agilefant.model.Project" />
31   - <mapping class="fi.hut.soberit.agilefant.model.Setting" />
32   - <mapping class="fi.hut.soberit.agilefant.model.Story" />
33   - <mapping class="fi.hut.soberit.agilefant.model.StoryHourEntry" />
34   - <mapping class="fi.hut.soberit.agilefant.model.Task" />
35   - <mapping class="fi.hut.soberit.agilefant.model.TaskHourEntry" />
36   - <mapping class="fi.hut.soberit.agilefant.model.Team" />
37   - <mapping class="fi.hut.soberit.agilefant.model.User" />
38   - <mapping class="fi.hut.soberit.agilefant.model.Holiday" />
39   - <mapping class="fi.hut.soberit.agilefant.model.HolidayAnomaly" />
40   - <mapping class="fi.hut.soberit.agilefant.model.AgilefantRevisionEntity" />
41   - <mapping class="fi.hut.soberit.agilefant.model.WhatsNextEntry" />
42   - <mapping class="fi.hut.soberit.agilefant.model.StoryRank" />
43   - <mapping class="fi.hut.soberit.agilefant.model.AgilefantWidget" />
44   - <mapping class="fi.hut.soberit.agilefant.model.WidgetCollection" />
45   - <mapping class="fi.hut.soberit.agilefant.model.StoryAccess" />
46   -
47   - <!-- <mapping class="fi.hut.soberit.agilefant.model.BusinessTheme" /> <mapping class="fi.hut.soberit.agilefant.model.BacklogThemeBinding" /> -->
48   -
49   -
50   - <!-- Activate hibernate validation: these listeners will raise an exception if an annotation validation constraint is violated. -->
51   - <event type="pre-update">
52   - <listener class="org.hibernate.validator.event.ValidatePreUpdateEventListener" />
53   - </event>
54   - <event type="pre-insert">
55   - <listener class="org.hibernate.validator.event.ValidatePreInsertEventListener" />
56   - </event>
57   -
58   - <!-- Envers version listeners -->
59   -
60   - <event type="post-insert">
61   - <listener class="org.hibernate.envers.event.AuditEventListener" />
62   - <listener class="fi.hut.soberit.agilefant.db.hibernate.notification.NotificationEventListener" />
63   - </event>
64   - <event type="post-update">
65   - <listener class="org.hibernate.envers.event.AuditEventListener" />
66   - <listener class="fi.hut.soberit.agilefant.db.hibernate.notification.NotificationEventListener" />
67   - </event>
68   - <event type="post-delete">
69   - <listener class="org.hibernate.envers.event.AuditEventListener" />
70   - <listener class="fi.hut.soberit.agilefant.db.hibernate.notification.NotificationEventListener" />
71   - </event>
72   - <event type="pre-collection-update">
73   - <listener class="org.hibernate.envers.event.AuditEventListener" />
74   - </event>
75   - <event type="pre-collection-remove">
76   - <listener class="org.hibernate.envers.event.AuditEventListener" />
77   - </event>
78   - <event type="post-collection-recreate">
79   - <listener class="org.hibernate.envers.event.AuditEventListener" />
80   - </event>
81   - </session-factory>
82   -</hibernate-configuration>
14 webapp/pom.xml
@@ -75,10 +75,6 @@
75 75 </dependency>
76 76 <dependency>
77 77 <groupId>joda-time</groupId>
78   - <artifactId>joda-time-hibernate</artifactId>
79   - </dependency>
80   - <dependency>
81   - <groupId>joda-time</groupId>
82 78 <artifactId>joda-time-jsptags</artifactId>
83 79 </dependency>
84 80 <dependency>
@@ -142,6 +138,16 @@
142 138 <artifactId>hibernate-validator</artifactId>
143 139 </dependency>
144 140 <dependency>
  141 + <groupId>org.jadira.usertype</groupId>
  142 + <artifactId>usertype.core</artifactId>
  143 + <exclusions>
  144 + <exclusion>
  145 + <groupId>org.joda</groupId>
  146 + <artifactId>joda-money</artifactId>
  147 + </exclusion>
  148 + </exclusions>
  149 + </dependency>
  150 + <dependency>
145 151 <groupId>org.jfree</groupId>
146 152 <artifactId>jfreechart</artifactId>
147 153 </dependency>
27 webapp/src/main/java/fi/hut/soberit/agilefant/business/impl/SettingBusinessImpl.java
@@ -12,7 +12,11 @@
12 12 import org.springframework.beans.factory.annotation.Autowired;
13 13 import org.springframework.context.annotation.Scope;
14 14 import org.springframework.stereotype.Service;
  15 +import org.springframework.transaction.PlatformTransactionManager;
  16 +import org.springframework.transaction.TransactionStatus;
15 17 import org.springframework.transaction.annotation.Transactional;
  18 +import org.springframework.transaction.support.TransactionCallbackWithoutResult;
  19 +import org.springframework.transaction.support.TransactionTemplate;
16 20
17 21 import fi.hut.soberit.agilefant.business.SettingBusiness;
18 22 import fi.hut.soberit.agilefant.db.SettingDAO;
@@ -53,21 +57,32 @@ public SettingBusinessImpl() {
53 57
54 58 @Autowired
55 59 private SettingDAO settingDAO;
  60 + @Autowired
  61 + private PlatformTransactionManager transactionManager;
56 62 private Map<String,Setting> settingCache = new HashMap<String, Setting>();
57 63
58   -
59 64 public void setSettingDAO(SettingDAO settingDAO) {
60 65 this.genericDAO = settingDAO;
61 66 this.settingDAO = settingDAO;
62 67 }
63   -
  68 +
  69 + public void setTransactionManager(PlatformTransactionManager transactionManager) {
  70 + this.transactionManager = transactionManager;
  71 + }
  72 +
64 73 @PostConstruct
65 74 public void loadSettingCache() {
66 75 this.settingCache.clear();
67   - Collection<Setting> allSettings = this.settingDAO.getAll();
68   - for(Setting setting : allSettings) {
69   - this.settingCache.put(setting.getName(), setting);
70   - }
  76 + TransactionTemplate tx = new TransactionTemplate(transactionManager);
  77 + tx.execute(new TransactionCallbackWithoutResult() {
  78 + @Override
  79 + protected void doInTransactionWithoutResult(TransactionStatus ts) {
  80 + Collection<Setting> allSettings = settingDAO.getAll();
  81 + for(Setting setting : allSettings) {
  82 + settingCache.put(setting.getName(), setting);
  83 + }
  84 + }
  85 + });
71 86 }
72 87
73 88 @Transactional(readOnly = true)
6 webapp/src/main/java/fi/hut/soberit/agilefant/config/DaoConfiguration.java
@@ -10,7 +10,7 @@
10 10 import org.springframework.context.annotation.ComponentScan;
11 11 import org.springframework.context.annotation.Configuration;
12 12 import org.springframework.core.io.ResourceLoader;
13   -import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
  13 +import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
14 14
15 15 import com.googlecode.flyway.core.Flyway;
16 16 import com.typesafe.config.Config;
@@ -44,11 +44,11 @@ public DatabaseInitializer databaseInitializer() {
44 44 }
45 45
46 46 @Bean
47   - public AnnotationSessionFactoryBean sessionFactory() throws Exception {
  47 + public LocalSessionFactoryBean sessionFactory() throws Exception {
48 48 flyway();
49 49 databaseInitializer();
50 50
51   - AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
  51 + LocalSessionFactoryBean bean = new LocalSessionFactoryBean();
52 52 bean.setConfigLocation(resourceLoader.getResource("/WEB-INF/hibernate.cfg.xml"));
53 53 bean.setDataSource(dataSource);
54 54
2  webapp/src/main/java/fi/hut/soberit/agilefant/config/TransactionConfiguration.java
@@ -6,7 +6,7 @@
6 6 import org.springframework.beans.factory.annotation.Autowired;
7 7 import org.springframework.context.annotation.Bean;
8 8 import org.springframework.context.annotation.Configuration;
9   -import org.springframework.orm.hibernate3.HibernateTransactionManager;
  9 +import org.springframework.orm.hibernate4.HibernateTransactionManager;
10 10 import org.springframework.transaction.PlatformTransactionManager;
11 11 import org.springframework.transaction.annotation.EnableTransactionManagement;
12 12 import org.springframework.transaction.annotation.TransactionManagementConfigurer;
2  webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/AssignmentDAOHibernate.java
@@ -23,7 +23,7 @@ public AssignmentDAOHibernate() {
23 23
24 24 public List<Assignment> assigmentsInBacklogTimeframe(Interval interval,
25 25 User user) {
26   - Criteria crit = getCurrentSession().createCriteria(Assignment.class);
  26 + Criteria crit = this.createCriteria(Assignment.class);
27 27 Criteria backlog = crit.createCriteria("backlog");
28 28 crit.createCriteria("user").add(Restrictions.idEq(user.getId()));
29 29 DateTime startDate = interval.getStart();
15 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/BacklogDAOHibernate.java
@@ -29,22 +29,21 @@ public BacklogDAOHibernate() {
29 29
30 30 /** {@inheritDoc} */
31 31 public int getNumberOfChildren(Backlog backlog) {
32   - Criteria criteria = getCurrentSession().createCriteria(Backlog.class);
  32 + Criteria criteria = this.createCriteria(Backlog.class);
33 33 criteria.add(Restrictions.idEq(backlog.getId()));
34 34 criteria.createCriteria("children");
35 35 criteria.setProjection(Projections.rowCount());
36   - return ((Long) criteria.list().get(0)).intValue();
  36 + return ((Long)this.asList(criteria).get(0)).intValue();
37 37 }
38 38
39 39 @SuppressWarnings("unchecked")
40 40 public List<Object[]> getResponsiblesByBacklog(Backlog backlog) {
41 41 String hql = "from Story as story left outer join story.responsibles as resp WHERE story.backlog = ?";
42   - return (List<Object[]>) hibernateTemplate.find(hql,
43   - new Object[] { backlog });
  42 + return this.asTuplesList(this.getCurrentSession().createQuery(hql).setEntity(0, backlog));
44 43 }
45 44
46 45 public int calculateStoryPointSum(int iterationId) {
47   - Criteria crit = getCurrentSession().createCriteria(Story.class);
  46 + Criteria crit = this.createCriteria(Story.class);
48 47 crit.setProjection(Projections.sum("storyPoints"));
49 48 crit.createCriteria("iteration").add(Restrictions.idEq(iterationId));
50 49 Long result = uniqueResult(crit);
@@ -53,7 +52,7 @@ public int calculateStoryPointSum(int iterationId) {
53 52 }
54 53
55 54 public int calculateDoneStoryPointSum(int iterationId) {
56   - Criteria crit = getCurrentSession().createCriteria(Story.class);
  55 + Criteria crit = this.createCriteria(Story.class);
57 56 crit.setProjection(Projections.sum("storyPoints"));
58 57 crit.createCriteria("iteration").add(Restrictions.idEq(iterationId));
59 58 crit.add(Restrictions.eq("state", StoryState.DONE));
@@ -68,7 +67,7 @@ public int calculateDoneStoryPointSum(int iterationId) {
68 67 }
69 68
70 69 public List<Backlog> searchByName(String name, Class<?> type) {
71   - Criteria crit = getCurrentSession().createCriteria(type);
  70 + Criteria crit = this.createCriteria(type);
72 71 crit.add(Restrictions.like("name", name, MatchMode.ANYWHERE));
73 72 crit.addOrder(Order.asc("class"));
74 73 crit.addOrder(Order.asc("name"));
@@ -77,7 +76,7 @@ public int calculateDoneStoryPointSum(int iterationId) {
77 76 }
78 77
79 78 public Collection<Backlog> retrieveStandaloneIterations() {
80   - Criteria crit = getCurrentSession().createCriteria(Backlog.class);
  79 + Criteria crit = this.createCriteria(Backlog.class);
81 80 crit.add(Restrictions.sqlRestriction("{alias}.parent_id is NULL"));
82 81 crit.add(Restrictions.sqlRestriction("{alias}.backlogType like 'Iteration'"));
83 82 crit.setMaxResults(SearchBusiness.MAX_RESULTS_PER_TYPE);
4 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/BacklogHistoryEntryDAOHibernate.java
@@ -23,7 +23,7 @@ public BacklogHistoryEntryDAOHibernate() {
23 23 }
24 24
25 25 public BacklogHistoryEntry retrieveLatest(DateTime timestamp, int backlogId) {
26   - Criteria crit = getCurrentSession().createCriteria(
  26 + Criteria crit = this.createCriteria(
27 27 BacklogHistoryEntry.class);
28 28 crit.add(Restrictions.eq("backlog.id", backlogId));
29 29 crit.add(Restrictions.le("timestamp", timestamp));
@@ -33,7 +33,7 @@ public BacklogHistoryEntry retrieveLatest(DateTime timestamp, int backlogId) {
33 33 }
34 34
35 35 public ProjectBurnupData retrieveBurnupData(int projectId) {
36   - Criteria crit = getCurrentSession().createCriteria(
  36 + Criteria crit = this.createCriteria(
37 37 BacklogHistoryEntry.class);
38 38 crit.add(Restrictions.eq("backlog.id", projectId));
39 39 crit.addOrder(Order.asc("timestamp"));
11 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/BacklogHourEntryDAOHibernate.java
@@ -2,7 +2,7 @@
2 2
3 3 import java.util.List;
4 4
5   -import org.hibernate.criterion.DetachedCriteria;
  5 +import org.hibernate.Criteria;
6 6 import org.hibernate.criterion.Restrictions;
7 7 import org.springframework.stereotype.Repository;
8 8
@@ -20,12 +20,9 @@ public BacklogHourEntryDAOHibernate() {
20 20
21 21 @SuppressWarnings("unchecked")
22 22 public List<BacklogHourEntry> retrieveByBacklog(Backlog target) {
23   - DetachedCriteria criteria = DetachedCriteria.forClass(this
24   - .getPersistentClass());
25   - criteria.add(Restrictions.eq("backlog", target));
26   -
27   - return (List<BacklogHourEntry>) hibernateTemplate
28   - .findByCriteria(criteria);
  23 + Criteria criteria = this.createCriteria(this.getPersistentClass());
  24 + criteria.add(Restrictions.eq("backlog", target));
  25 + return this.asList(criteria);
29 26 }
30 27
31 28 }
11 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/Email.java
@@ -6,7 +6,8 @@
6 6 import java.lang.annotation.RetentionPolicy;
7 7 import java.lang.annotation.Target;
8 8
9   -import org.hibernate.validator.ValidatorClass;
  9 +import javax.validation.Constraint;
  10 +import javax.validation.Payload;
10 11
11 12 /**
12 13 * Annotation to enable our hibernate custom email validator.
@@ -15,10 +16,14 @@
15 16 * @see fi.fi.hut.soberit.agilefant.db.hibernate.EmailValidator
16 17 */
17 18 @Documented
18   -@ValidatorClass(EmailValidator.class)
  19 +@Constraint(validatedBy = EmailValidator.class)
19 20 // bind to EmailValidator
20   -@Target( { ElementType.METHOD, ElementType.FIELD })
  21 +@Target({ ElementType.METHOD, ElementType.FIELD })
21 22 @Retention(RetentionPolicy.RUNTIME)
22 23 public @interface Email {
23 24 String message() default "is not a proper email address";
  25 +
  26 + Class<? extends Payload>[] payload() default {};
  27 +
  28 + Class<?>[] groups() default {};
24 29 }
31 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/EmailValidator.java
@@ -2,7 +2,10 @@
2 2
3 3 import java.io.Serializable;
4 4
5   -import org.hibernate.validator.Validator;
  5 +import javax.validation.ConstraintValidator;
  6 +import javax.validation.ConstraintValidatorContext;
  7 +
  8 +import com.google.common.base.Strings;
6 9
7 10 /**
8 11 * Implementation of the email validator. When using the email annotation in the
@@ -12,31 +15,19 @@
12 15 * @author Turkka Äijälä
13 16 * @see fi.fi.hut.soberit.agilefant.db.hibernate.Email
14 17 */
15   -public class EmailValidator implements Validator<Email>, Serializable {
  18 +public class EmailValidator implements ConstraintValidator<Email, String>, Serializable {
16 19
17 20 private static final long serialVersionUID = 4334203403474352735L;
18 21
  22 + @Override
19 23 public void initialize(Email parameters) {
20 24 }
21 25
22   - public boolean isValid(Object value) {
23   -
24   - // nulls qualify
25   - if (value == null)
26   - return true;
27   -
28   - // non-string objects don't qualify
29   - if (!(value instanceof String))
30   - return false;
31   -
32   - String string = (String) value;
33   -
34   - // empty strings qualify
35   - if (string.equals(""))
  26 + @Override
  27 + public boolean isValid(String value, ConstraintValidatorContext context) {
  28 + if (Strings.isNullOrEmpty(value))
36 29 return true;
37   -
38   - // use commons-validator to validate email addresses
39   - return org.apache.commons.validator.EmailValidator.getInstance()
40   - .isValid(string);
  30 + return org.apache.commons.validator.routines.EmailValidator.getInstance().isValid(value);
41 31 }
  32 +
42 33 }
116 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/EnumUserType.java
... ... @@ -1,116 +0,0 @@
1   -package fi.hut.soberit.agilefant.db.hibernate;
2   -
3   -import java.io.Serializable;
4   -import java.sql.PreparedStatement;
5   -import java.sql.ResultSet;
6   -import java.sql.SQLException;
7   -import java.sql.Types;
8   -import java.util.Properties;
9   -
10   -import org.hibernate.HibernateException;
11   -import org.hibernate.MappingException;
12   -import org.hibernate.usertype.ParameterizedType;
13   -import org.hibernate.usertype.UserType;
14   -
15   -public class EnumUserType implements UserType, ParameterizedType {
16   -
17   - public static final String USE_ORDINAL_PARAM = "useOrdinal";
18   -
19   - public static final String ENUM_CLASS_NAME = "enumClassName";
20   -
21   - @SuppressWarnings("unchecked")
22   - private Class<Enum> clazz = null;
23   -
24   - private boolean useOrdinal;
25   -
26   - private static final int[] VARCHAR_SQL_TYPES = { Types.VARCHAR };
27   -
28   - private static final int[] INT_SQL_TYPES = { Types.INTEGER };
29   -
30   - @SuppressWarnings("unchecked")
31   - public Class returnedClass() {
32   - return clazz;
33   - }
34   -
35   - @SuppressWarnings("unchecked")
36   - public void setParameterValues(Properties params) {
37   - String enumClassName = params.getProperty(ENUM_CLASS_NAME);
38   - try {
39   - clazz = (Class<Enum>) Class.forName(enumClassName);
40   - } catch (Exception e) {
41   - throw new MappingException("Failed to create class "
42   - + enumClassName + ". Check param " + ENUM_CLASS_NAME);
43   - }
44   - useOrdinal = "true".equalsIgnoreCase(params
45   - .getProperty(USE_ORDINAL_PARAM));
46   - }
47   -
48   - public int[] sqlTypes() {
49   - return useOrdinal ? INT_SQL_TYPES : VARCHAR_SQL_TYPES;
50   - }
51   -
52   - @SuppressWarnings("unchecked")
53   - public Object nullSafeGet(ResultSet rs, String[] names, Object obj)
54   - throws HibernateException, SQLException {
55   - if (useOrdinal) {
56   - int ordinal = rs.getInt(names[0]);
57   - if (rs.wasNull()) {
58   - return null;
59   - } else {
60   - return clazz.getEnumConstants()[ordinal];
61   - }
62   - } else {
63   - String value = rs.getString(names[0]);
64   - if (rs.wasNull()) {
65   - return null;
66   - } else {
67   - return Enum.valueOf(clazz, value);
68   - }
69   - }
70   - }
71   -
72   - public void nullSafeSet(PreparedStatement stmt, Object obj, int index)
73   - throws HibernateException, SQLException {
74   - if (obj == null) {
75   - stmt.setNull(index, this.sqlTypes()[0]);
76   - } else if (useOrdinal) {
77   - stmt.setInt(index, ((Enum<?>) obj).ordinal());
78   - } else {
79   - stmt.setString(index, ((Enum<?>) obj).name());
80   - }
81   - }
82   -
83   - public Object assemble(Serializable cached, Object obj)
84   - throws HibernateException {
85   - return cached;
86   - }
87   -
88   - public Object deepCopy(Object obj) throws HibernateException {
89   - return obj;
90   - }
91   -
92   - public Serializable disassemble(Object obj) throws HibernateException {
93   - return (Serializable) obj;
94   - }
95   -
96   - public int hashCode(Object x) throws HibernateException {
97   - return x.hashCode();
98   - }
99   -
100   - public boolean equals(Object x, Object y) throws HibernateException {
101   - if (x == y)
102   - return true;
103   - if (null == x || null == y)
104   - return false;
105   - return x.equals(y);
106   - }
107   -
108   - public boolean isMutable() {
109   - return false;
110   - }
111   -
112   - public Object replace(Object obj, Object obj1, Object obj2)
113   - throws HibernateException {
114   - return obj;
115   - }
116   -}
61 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/GenericDAOHibernate.java
@@ -9,13 +9,12 @@
9 9 import javax.annotation.PostConstruct;
10 10
11 11 import org.hibernate.Criteria;
  12 +import org.hibernate.Query;
12 13 import org.hibernate.Session;
13 14 import org.hibernate.SessionFactory;
14   -import org.hibernate.criterion.DetachedCriteria;
15 15 import org.hibernate.criterion.Projections;
16 16 import org.hibernate.criterion.Restrictions;
17 17 import org.springframework.beans.factory.annotation.Autowired;
18   -import org.springframework.orm.hibernate3.HibernateTemplate;
19 18
20 19 import fi.hut.soberit.agilefant.db.GenericDAO;
21 20
@@ -36,8 +35,6 @@
36 35
37 36 protected SessionFactory sessionFactory;
38 37
39   - protected HibernateTemplate hibernateTemplate;
40   -
41 38 @PostConstruct
42 39 public void init() {
43 40 if (sessionFactory == null) {
@@ -48,7 +45,6 @@ public void init() {
48 45 @Autowired
49 46 public void setSessionFactory(SessionFactory sessionFactory) {
50 47 this.sessionFactory = sessionFactory;
51   - this.hibernateTemplate = new HibernateTemplate(sessionFactory);
52 48 }
53 49
54 50 protected GenericDAOHibernate(Class<T> clazz) {
@@ -61,7 +57,7 @@ protected GenericDAOHibernate(Class<T> clazz) {
61 57
62 58 /** {@inheritDoc} */
63 59 public T get(int id) {
64   - return hibernateTemplate.get(this.getPersistentClass(), id);
  60 + return (T) this.getCurrentSession().get(getPersistentClass(), id);
65 61 }
66 62
67 63 /** {@inheritDoc} */
@@ -70,18 +66,18 @@ public T getAndDetach(int id) {
70 66 this.sessionFactory.getCurrentSession().evict(object);
71 67 return object;
72 68 }
73   -
  69 +
74 70 /** {@inheritDoc} */
75   - public List<T> getAll() {
76   - return hibernateTemplate.loadAll(getPersistentClass());
  71 + public Collection<T> getAll() {
  72 + return this.asList(this.createCriteria(this.getPersistentClass()));
77 73 }
78   -
  74 +
79 75 /** {@inheritDoc} */
80 76 public Collection<T> getMultiple(Collection<Integer> ids) {
81 77 if (ids == null || ids.isEmpty()) {
82 78 return new HashSet<T>();
83 79 }
84   - Criteria c = getCurrentSession().createCriteria(getPersistentClass());
  80 + Criteria c = this.createCriteria(getPersistentClass());
85 81 c.add(Restrictions.in("id", ids));
86 82 return asCollection(c);
87 83 }
@@ -93,17 +89,17 @@ public void remove(int id) {
93 89
94 90 /** {@inheritDoc} */
95 91 public void remove(T object) {
96   - hibernateTemplate.delete(object);
  92 + this.getCurrentSession().delete(object);
97 93 }
98 94
99 95 /** {@inheritDoc} */
100 96 public void store(T object) {
101   - hibernateTemplate.saveOrUpdate(object);
  97 + this.getCurrentSession().saveOrUpdate(object);
102 98 }
103 99
104 100 /** {@inheritDoc} */
105 101 public Serializable create(T object) {
106   - return hibernateTemplate.save(object);
  102 + return this.getCurrentSession().save(object);
107 103 }
108 104
109 105 protected T getFirst(Collection<T> list) {
@@ -113,30 +109,31 @@ protected T getFirst(Collection<T> list) {
113 109 return list.iterator().next();
114 110 }
115 111
116   - protected <ResultType> ResultType getFirstTypeSafe(
117   - Collection<ResultType> list) {
  112 + protected <ResultType> ResultType getFirstTypeSafe(Collection<ResultType> list) {
118 113 if (list == null || list.isEmpty()) {
119 114 return null;
120 115 }
121 116 return list.iterator().next();
122 117 }
123 118
124   - protected DetachedCriteria createCriteria() {
125   - return DetachedCriteria.forClass(this.getPersistentClass());
  119 + protected Criteria createCriteria(Class clazz) {
  120 + return this.getCurrentSession().createCriteria(clazz);
  121 + }
  122 +
  123 + protected Criteria createCriteria(Class clazz, String alias) {
  124 + return this.getCurrentSession().createCriteria(clazz, alias);
126 125 }
127 126
128 127 public int count() {
129   - DetachedCriteria criteria = createCriteria().setProjection(
130   - Projections.rowCount());
131   - return ((Long) hibernateTemplate.findByCriteria(criteria).get(0))
132   - .intValue();
  128 + Criteria criteria = this.createCriteria(this.getPersistentClass());
  129 + criteria.setProjection(Projections.rowCount());
  130 + return ((Long) this.uniqueResult(criteria)).intValue();
133 131 }
134 132
135 133 public boolean exists(int id) {
136   - DetachedCriteria crit = createCriteria().add(Restrictions.idEq(id))
137   - .setProjection(Projections.rowCount());
138   - return ((Long) hibernateTemplate.findByCriteria(crit).get(0))
139   - .intValue() > 0;
  134 + Criteria criteria = this.createCriteria(this.getPersistentClass());
  135 + criteria.add(Restrictions.idEq(id)).setProjection(Projections.rowCount());
  136 + return ((Long) this.uniqueResult(criteria)).intValue() > 0;
140 137 }
141 138
142 139 public Session getCurrentSession() {
@@ -145,7 +142,7 @@ public Session getCurrentSession() {
145 142
146 143 @SuppressWarnings("unchecked")
147 144 protected <ResultType> Collection<ResultType> asCollection(Criteria criteria) {
148   - Collection<ResultType> list = criteria.list();
  145 + Collection<ResultType> list = this.asList(criteria);
149 146 if (list == null) {
150 147 return Collections.EMPTY_LIST;
151 148 }
@@ -171,4 +168,14 @@ public Session getCurrentSession() {
171 168 return (ResultType) criteria.uniqueResult();
172 169 }
173 170
  171 + @SuppressWarnings("unchecked")
  172 + protected List<T> asList(Query query) {
  173 + return query.list();
  174 + }
  175 +
  176 + @SuppressWarnings("unchecked")
  177 + protected List<Object[]> asTuplesList(Query query) {
  178 + return query.list();
  179 + }
  180 +
174 181 }
2  webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/HolidayDAOHibernate.java
@@ -22,7 +22,7 @@ public HolidayDAOHibernate() {
22 22 }
23 23
24 24 public List<Holiday> retrieveFutureHolidaysByUser(User user) {
25   - Criteria crit = sessionFactory.getCurrentSession().createCriteria(Holiday.class);
  25 + Criteria crit = this.createCriteria(Holiday.class);
26 26 crit.add(Restrictions.eq("user", user));
27 27 crit.add(Restrictions.ge("endDate", new DateTime()));
28 28 crit.addOrder(Order.asc("startDate"));
56 webapp/src/main/java/fi/hut/soberit/agilefant/db/hibernate/HourEntryDAOHibernate.java