Commit e76b8f6a5aa5ce4beefa15b76c08d6884d6b3f2f
1 parent
474776a8
SQLite → Mémoire
Showing
7 changed files
with
34 additions
and
188 deletions
Show diff stats
.gitignore
etunicorn-server.iml
... | ... | @@ -10,11 +10,8 @@ |
10 | 10 | </content> |
11 | 11 | <orderEntry type="inheritedJdk" /> |
12 | 12 | <orderEntry type="sourceFolder" forTests="false" /> |
13 | - <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.3" level="project" /> | |
14 | 13 | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-rest:1.4.4.RELEASE" level="project" /> |
15 | 14 | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.4.4.RELEASE" level="project" /> |
16 | - <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.4.4.RELEASE" level="project" /> | |
17 | - <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.4.4.RELEASE" level="project" /> | |
18 | 15 | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.4.4.RELEASE" level="project" /> |
19 | 16 | <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.9" level="project" /> |
20 | 17 | <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.9" level="project" /> |
... | ... | @@ -85,7 +82,10 @@ |
85 | 82 | <orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.1" level="project" /> |
86 | 83 | <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.3" level="project" /> |
87 | 84 | <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.22" level="project" /> |
88 | - <orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.16.1" level="project" /> | |
85 | + <orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.40" level="project" /> | |
89 | 86 | <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.3" level="project" /> |
87 | + <orderEntry type="library" name="Maven: com.h2database:h2:1.4.193" level="project" /> | |
88 | + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.4.4.RELEASE" level="project" /> | |
89 | + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.4.4.RELEASE" level="project" /> | |
90 | 90 | </component> |
91 | 91 | </module> |
92 | 92 | \ No newline at end of file | ... | ... |
pom.xml
... | ... | @@ -32,9 +32,8 @@ |
32 | 32 | </dependency> |
33 | 33 | |
34 | 34 | <dependency> |
35 | - <groupId>org.xerial</groupId> | |
36 | - <artifactId>sqlite-jdbc</artifactId> | |
37 | - <version>3.16.1</version> | |
35 | + <groupId>mysql</groupId> | |
36 | + <artifactId>mysql-connector-java</artifactId> | |
38 | 37 | </dependency> |
39 | 38 | |
40 | 39 | <dependency> |
... | ... | @@ -42,6 +41,15 @@ |
42 | 41 | <artifactId>commons-lang</artifactId> |
43 | 42 | <version>2.3</version> |
44 | 43 | </dependency> |
44 | + <dependency> | |
45 | + <groupId>com.h2database</groupId> | |
46 | + <artifactId>h2</artifactId> | |
47 | + </dependency> | |
48 | + <dependency> | |
49 | + <groupId>org.springframework.boot</groupId> | |
50 | + <artifactId>spring-boot-autoconfigure</artifactId> | |
51 | + <version>1.4.4.RELEASE</version> | |
52 | + </dependency> | |
45 | 53 | |
46 | 54 | |
47 | 55 | </dependencies> | ... | ... |
src/main/java/etunicorn/Application.java
... | ... | @@ -12,10 +12,9 @@ import org.springframework.boot.CommandLineRunner; |
12 | 12 | import org.springframework.boot.SpringApplication; |
13 | 13 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
14 | 14 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
15 | -import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; | |
16 | 15 | import org.springframework.context.annotation.Bean; |
16 | +import org.springframework.context.annotation.Configuration; | |
17 | 17 | |
18 | -import javax.sql.DataSource; | |
19 | 18 | import java.util.ArrayList; |
20 | 19 | import java.util.Date; |
21 | 20 | import java.util.List; |
... | ... | @@ -25,6 +24,7 @@ import java.util.List; |
25 | 24 | * Copyright © 2017 Le Club Info Polytech Lille |
26 | 25 | * Tous droits réservés |
27 | 26 | */ |
27 | +@Configuration | |
28 | 28 | @SpringBootApplication |
29 | 29 | @EnableAutoConfiguration |
30 | 30 | public class Application { |
... | ... | @@ -60,11 +60,21 @@ public class Application { |
60 | 60 | }; |
61 | 61 | } |
62 | 62 | |
63 | - @Bean | |
64 | - public DataSource dataSource() { | |
65 | - DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create(); | |
66 | - dataSourceBuilder.driverClassName("org.sqlite.JDBC"); | |
67 | - dataSourceBuilder.url("jdbc:sqlite:etunicorn.db"); | |
68 | - return dataSourceBuilder.build(); | |
69 | - } | |
63 | + // @Bean | |
64 | + // public DataSource dataSource() { | |
65 | + // DriverManagerDataSource dataSource = new DriverManagerDataSource(); | |
66 | + // dataSource.setDriverClassName("com.mysql.jdbc.Driver"); | |
67 | + // dataSource.setUrl("jdbc:mysql://localhost/etunicorn"); | |
68 | + // dataSource.setUsername("etunicorn"); | |
69 | + // dataSource.setPassword("etunicorn"); | |
70 | + // return dataSource; | |
71 | + // } | |
72 | + | |
73 | + // Properties additionalProperties() { | |
74 | + // Properties properties = new Properties(); | |
75 | + // properties.setProperty("spring.jpa.hibernale.ddl-auto", "create-drop"); | |
76 | + // properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); | |
77 | + // return properties; | |
78 | + // } | |
79 | + | |
70 | 80 | } | ... | ... |
src/main/java/etunicorn/controller/BaseController.java
... | ... | @@ -6,7 +6,6 @@ import etunicorn.repository.PermissionRepository; |
6 | 6 | import etunicorn.service.SessionService; |
7 | 7 | import net.minidev.json.JSONObject; |
8 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
9 | -import org.springframework.data.repository.Repository; | |
10 | 9 | import org.springframework.http.HttpStatus; |
11 | 10 | import org.springframework.http.ResponseEntity; |
12 | 11 | import org.springframework.web.bind.annotation.RestController; |
... | ... | @@ -15,7 +14,6 @@ import javax.servlet.http.HttpServletRequest; |
15 | 14 | import java.io.PrintWriter; |
16 | 15 | import java.io.StringWriter; |
17 | 16 | import java.util.Date; |
18 | -import java.util.Map; | |
19 | 17 | |
20 | 18 | /** |
21 | 19 | * etunicorn-server |
... | ... | @@ -25,9 +23,6 @@ import java.util.Map; |
25 | 23 | @RestController |
26 | 24 | public class BaseController { |
27 | 25 | |
28 | - // Utilités pour merger un request dans une entity | |
29 | - @Autowired | |
30 | - Map<String, Repository> repositories; | |
31 | 26 | // Permettent la vérification de permissions dans les méthodes de controlleur |
32 | 27 | @Autowired |
33 | 28 | private HttpServletRequest request; | ... | ... |
src/main/java/etunicorn/databaseConfiguration/SQLiteDialect.java deleted
... | ... | @@ -1,161 +0,0 @@ |
1 | -package etunicorn.databaseConfiguration; | |
2 | - | |
3 | -/** | |
4 | - * etunicorn-server | |
5 | - * Copyright © 2017 Le Club Info Polytech Lille | |
6 | - * Tous droits réservés | |
7 | - */ | |
8 | - | |
9 | -import org.hibernate.dialect.Dialect; | |
10 | -import org.hibernate.dialect.function.SQLFunctionTemplate; | |
11 | -import org.hibernate.dialect.function.StandardSQLFunction; | |
12 | -import org.hibernate.dialect.function.VarArgsSQLFunction; | |
13 | -import org.hibernate.type.StringType; | |
14 | - | |
15 | -import java.sql.Types; | |
16 | - | |
17 | -public class SQLiteDialect extends Dialect { | |
18 | - public SQLiteDialect() { | |
19 | - registerColumnType(Types.BIT, "integer"); | |
20 | - registerColumnType(Types.TINYINT, "tinyint"); | |
21 | - registerColumnType(Types.SMALLINT, "smallint"); | |
22 | - registerColumnType(Types.INTEGER, "integer"); | |
23 | - registerColumnType(Types.BIGINT, "bigint"); | |
24 | - registerColumnType(Types.FLOAT, "float"); | |
25 | - registerColumnType(Types.REAL, "real"); | |
26 | - registerColumnType(Types.DOUBLE, "double"); | |
27 | - registerColumnType(Types.NUMERIC, "numeric"); | |
28 | - registerColumnType(Types.DECIMAL, "decimal"); | |
29 | - registerColumnType(Types.CHAR, "char"); | |
30 | - registerColumnType(Types.VARCHAR, "varchar"); | |
31 | - registerColumnType(Types.LONGVARCHAR, "longvarchar"); | |
32 | - registerColumnType(Types.DATE, "date"); | |
33 | - registerColumnType(Types.TIME, "time"); | |
34 | - registerColumnType(Types.TIMESTAMP, "timestamp"); | |
35 | - registerColumnType(Types.BINARY, "blob"); | |
36 | - registerColumnType(Types.VARBINARY, "blob"); | |
37 | - registerColumnType(Types.LONGVARBINARY, "blob"); | |
38 | - // registerColumnType(Types.NULL, "null"); | |
39 | - registerColumnType(Types.BLOB, "blob"); | |
40 | - registerColumnType(Types.CLOB, "clob"); | |
41 | - registerColumnType(Types.BOOLEAN, "integer"); | |
42 | - | |
43 | - registerFunction( "concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", "") ); | |
44 | - registerFunction( "mod", new SQLFunctionTemplate( StringType.INSTANCE, "?1 % ?2" ) ); | |
45 | - registerFunction( "substr", new StandardSQLFunction("substr", StringType.INSTANCE) ); | |
46 | - registerFunction( "substring", new StandardSQLFunction( "substr", StringType.INSTANCE) ); | |
47 | - } | |
48 | - | |
49 | - public boolean supportsIdentityColumns() { | |
50 | - return true; | |
51 | - } | |
52 | - | |
53 | - /* | |
54 | - public boolean supportsInsertSelectIdentity() { | |
55 | - return true; // As specify in NHibernate dialect | |
56 | - } | |
57 | - */ | |
58 | - | |
59 | - public boolean hasDataTypeInIdentityColumn() { | |
60 | - return false; // As specify in NHibernate dialect | |
61 | - } | |
62 | - | |
63 | - /* | |
64 | - public String appendIdentitySelectToInsert(String insertString) { | |
65 | - return new StringBuffer(insertString.length()+30). // As specify in NHibernate dialect | |
66 | - append(insertString). | |
67 | - append("; ").append(getIdentitySelectString()). | |
68 | - toString(); | |
69 | - } | |
70 | - */ | |
71 | - | |
72 | - public String getIdentityColumnString() { | |
73 | - // return "integer primary key autoincrement"; | |
74 | - return "integer"; | |
75 | - } | |
76 | - | |
77 | - public String getIdentitySelectString() { | |
78 | - return "select last_insert_rowid()"; | |
79 | - } | |
80 | - | |
81 | - public boolean supportsLimit() { | |
82 | - return true; | |
83 | - } | |
84 | - | |
85 | - protected String getLimitString(String query, boolean hasOffset) { | |
86 | - return new StringBuffer(query.length()+20). | |
87 | - append(query). | |
88 | - append(hasOffset ? " limit ? offset ?" : " limit ?"). | |
89 | - toString(); | |
90 | - } | |
91 | - | |
92 | - public boolean supportsTemporaryTables() { | |
93 | - return true; | |
94 | - } | |
95 | - | |
96 | - public String getCreateTemporaryTableString() { | |
97 | - return "create temporary table if not exists"; | |
98 | - } | |
99 | - | |
100 | - public boolean dropTemporaryTableAfterUse() { | |
101 | - return false; | |
102 | - } | |
103 | - | |
104 | - public boolean supportsCurrentTimestampSelection() { | |
105 | - return true; | |
106 | - } | |
107 | - | |
108 | - public boolean isCurrentTimestampSelectStringCallable() { | |
109 | - return false; | |
110 | - } | |
111 | - | |
112 | - public String getCurrentTimestampSelectString() { | |
113 | - return "select current_timestamp"; | |
114 | - } | |
115 | - | |
116 | - public boolean supportsUnionAll() { | |
117 | - return true; | |
118 | - } | |
119 | - | |
120 | - public boolean hasAlterTable() { | |
121 | - return false; // As specify in NHibernate dialect | |
122 | - } | |
123 | - | |
124 | - public boolean dropConstraints() { | |
125 | - return false; | |
126 | - } | |
127 | - | |
128 | - public String getAddColumnString() { | |
129 | - return "add column"; | |
130 | - } | |
131 | - | |
132 | - public String getForUpdateString() { | |
133 | - return ""; | |
134 | - } | |
135 | - | |
136 | - public boolean supportsOuterJoinForUpdate() { | |
137 | - return false; | |
138 | - } | |
139 | - | |
140 | - public String getDropForeignKeyString() { | |
141 | - throw new UnsupportedOperationException("No drop foreign key syntax supported by SQLiteDialect"); | |
142 | - } | |
143 | - | |
144 | - public String getAddForeignKeyConstraintString(String constraintName, | |
145 | - String[] foreignKey, String referencedTable, String[] primaryKey, | |
146 | - boolean referencesPrimaryKey) { | |
147 | - throw new UnsupportedOperationException("No add foreign key syntax supported by SQLiteDialect"); | |
148 | - } | |
149 | - | |
150 | - public String getAddPrimaryKeyConstraintString(String constraintName) { | |
151 | - throw new UnsupportedOperationException("No add primary key syntax supported by SQLiteDialect"); | |
152 | - } | |
153 | - | |
154 | - public boolean supportsIfExistsBeforeTableName() { | |
155 | - return true; | |
156 | - } | |
157 | - | |
158 | - public boolean supportsCascadeDelete() { | |
159 | - return false; | |
160 | - } | |
161 | -} | |
162 | 0 | \ No newline at end of file |