From ae4b429379895a41fc16be313dac08e6a6b1ce82 Mon Sep 17 00:00:00 2001 From: Alessandro Polverini Date: Mon, 10 Feb 2014 08:43:40 +0100 Subject: [PATCH] Using HSQL integrated db --- SPR-11406/nbactions.xml | 6 +- SPR-11406/pom.xml | 242 +++++++++--------- .../main/java/it/nibbles/test/objs/User.java | 6 +- SPR-11406/src/main/resources/schema.sql | 7 + .../webapp/WEB-INF/applicationContext.xml | 38 +-- 5 files changed, 153 insertions(+), 146 deletions(-) create mode 100644 SPR-11406/src/main/resources/schema.sql diff --git a/SPR-11406/nbactions.xml b/SPR-11406/nbactions.xml index 0c2b5400..5295c3b0 100644 --- a/SPR-11406/nbactions.xml +++ b/SPR-11406/nbactions.xml @@ -12,7 +12,7 @@ true - /adm/info + /newUser/test @@ -28,7 +28,7 @@ true true - /adm/info + /newUser/test @@ -44,7 +44,7 @@ true true - /adm/info + /newUser/test diff --git a/SPR-11406/pom.xml b/SPR-11406/pom.xml index 42fa3863..b65055c3 100644 --- a/SPR-11406/pom.xml +++ b/SPR-11406/pom.xml @@ -1,128 +1,134 @@ - 4.0.0 - SPR-11406 - it.nibbles - SPR-11406 - war - 0.1-wip - http://maven.apache.org - - - UTF-8 - 4.0.1.RELEASE - 1.7.5 - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - org.slf4j - slf4j-api - ${slf4j.version} - compile - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - runtime - - - org.slf4j - slf4j-log4j12 - ${slf4j.version} - runtime - - - log4j - log4j - 1.2.17 - runtime - - - org.springframework - spring-core - ${spring.version} - - - commons-logging - commons-logging - - - - - - - - org.springframework - spring-web - ${spring.version} - - - - org.springframework - spring-webmvc - ${spring.version} - - - - org.springframework - spring-orm - ${spring.version} - - - - org.springframework - spring-tx - ${spring.version} - + 4.0.0 + SPR-11406 + it.nibbles + SPR-11406 + war + 0.1-wip + http://maven.apache.org + + + UTF-8 + 4.0.1.RELEASE + 1.7.5 + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + org.slf4j + slf4j-api + ${slf4j.version} + compile + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + runtime + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + runtime + + + log4j + log4j + 1.2.17 + runtime + + + org.springframework + spring-core + ${spring.version} + + + commons-logging + commons-logging + + + + + + + + org.springframework + spring-web + ${spring.version} + + + + org.springframework + spring-webmvc + ${spring.version} + + + + org.springframework + spring-orm + ${spring.version} + + + + org.springframework + spring-tx + ${spring.version} + - - org.springframework - spring-jdbc - ${spring.version} - - - - org.springframework.data - spring-data-jpa - 1.4.3.RELEASE - - - - org.hibernate - hibernate-entitymanager - 4.3.0.Final - - - + + org.springframework + spring-jdbc + ${spring.version} + + + + org.springframework.data + spring-data-jpa + 1.4.3.RELEASE + + + + org.hsqldb + hsqldb + 2.3.1 + + + + org.hibernate + hibernate-entitymanager + 4.3.0.Final + + + - + - + - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - true - - + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + + - - SPR-11406 - + + SPR-11406 + diff --git a/SPR-11406/src/main/java/it/nibbles/test/objs/User.java b/SPR-11406/src/main/java/it/nibbles/test/objs/User.java index 9c9bcf8a..c3a2a2af 100644 --- a/SPR-11406/src/main/java/it/nibbles/test/objs/User.java +++ b/SPR-11406/src/main/java/it/nibbles/test/objs/User.java @@ -1,5 +1,6 @@ package it.nibbles.test.objs; +import java.util.Random; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -14,13 +15,16 @@ public class User { public static final int STR_LEN = 64; @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Integer id; @Column(name = "username", nullable = false) private String name; + public User() { + setId(new Random().nextInt()); + } + public Integer getId() { return id; } diff --git a/SPR-11406/src/main/resources/schema.sql b/SPR-11406/src/main/resources/schema.sql new file mode 100644 index 00000000..eab2ca5a --- /dev/null +++ b/SPR-11406/src/main/resources/schema.sql @@ -0,0 +1,7 @@ +-- For HSQL +CREATE TABLE UserTest(id int, username varchar(100), PRIMARY KEY (id)); +--ALTER TABLE User ALTER COLUMN id +-- SET GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1); + +-- For Mysql +-- CREATE TABLE UserTest(id int AUTO_INCREMENT, username varchar(100), PRIMARY KEY (id)); diff --git a/SPR-11406/src/main/webapp/WEB-INF/applicationContext.xml b/SPR-11406/src/main/webapp/WEB-INF/applicationContext.xml index 8466f078..aff64a2e 100644 --- a/SPR-11406/src/main/webapp/WEB-INF/applicationContext.xml +++ b/SPR-11406/src/main/webapp/WEB-INF/applicationContext.xml @@ -8,42 +8,32 @@ xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa" + xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd - http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd + http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd "> - - - - - - - - - + + @@ -59,6 +49,6 @@ + entity-manager-factory-ref="entityManagerFactory" transaction-manager-ref="transactionManager"/>