Skip to content

Commit 5f93af4

Browse files
phasenraum2010phasenraum2010
phasenraum2010
authored and
phasenraum2010
committed
JPA Mapping for Migration from PostgreSQL to MySQL
1 parent 2cba98b commit 5f93af4

File tree

7 files changed

+55
-39
lines changed

7 files changed

+55
-39
lines changed

twitterwall2/pom.xml

+8-1
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,17 @@
143143
<artifactId>jsoup</artifactId>
144144
<version>1.10.3</version>
145145
</dependency>
146+
<!--
146147
<dependency>
147148
<groupId>org.postgresql</groupId>
148149
<artifactId>postgresql</artifactId>
149-
<version>42.1.1</version>
150+
<version>42.2.2</version>
151+
</dependency>
152+
-->
153+
<dependency>
154+
<groupId>mysql</groupId>
155+
<artifactId>mysql-connector-java</artifactId>
156+
<version>5.1.46</version>
150157
</dependency>
151158
<dependency>
152159
<groupId>org.webjars</groupId>

twitterwall2/run.cmd

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
set DATABASE_URL='jdbc:postgresql://localhost:5432/twitterwall2?user=twitterwall2&password=twitterwall2pwd'
2-
set DATABASE_URL_TEST='jdbc:postgresql://localhost:5432/twitterwall2test?user=twitterwall2test&password=twitterwall2testpwd'
1+
@REM set DATABASE_URL='jdbc:postgresql://[::1]:5432/twitterwall2?user=twitterwall2&password=twitterwall2pwd'
2+
@REM set DATABASE_URL_TEST='jdbc:postgresql://localhost:5432/twitterwall2test?user=twitterwall2test&password=twitterwall2testpwd'
3+
set DATABASE_URL=jdbc:mysql://localhost/twitterwall2?user=twitterwall2&amp;password=twitterwall2pwd
4+
set DATABASE_PWD=twitterwall2pwd
5+
set DATABASE_URL_TEST=jdbc:mysql://localhost/twitterwall2test?user=twitterwall2test&amp;password=twitterwall2testpwd
6+
set DATABASE_PWD_TEST=twitterwall2pwd
37
set TWITTERWALL_FRONTEND_MAX_RESULTS=200
48
set TWITTERWALL_SHOW_USERS_MENU=true
59
set TWITTERWALL_CONTEXT_TEST=true

twitterwall2/src/main/java/org/woehlke/twitterwall/oodm/model/Media.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
name = "media",
2222
uniqueConstraints = {
2323
@UniqueConstraint(name="unique_media_id_twitter", columnNames = {"id_twitter"})
24-
},
25-
indexes = {
26-
@Index(name="idx_media_url", columnList= "url"),
27-
@Index(name="idx_media_expanded", columnList="expanded"),
28-
@Index(name="idx_media_display", columnList="display") ,
29-
@Index(name="idx_media_media_http", columnList="media_http"),
30-
@Index(name="idx_media_media_https", columnList="media_https"),
31-
@Index(name="idx_media_media_type", columnList="media_type")
32-
}
24+
}//,
25+
//indexes = {
26+
//@Index(name="idx_media_url", columnList= "url"),
27+
//@Index(name="idx_media_expanded", columnList="expanded"),
28+
//@Index(name="idx_media_display", columnList="display") ,
29+
//@Index(name="idx_media_media_http", columnList="media_http"),
30+
//@Index(name="idx_media_media_https", columnList="media_https"),
31+
//@Index(name="idx_media_media_type", columnList="media_type")
32+
//}
3333
)
3434
@NamedQueries({
3535
@NamedQuery(
@@ -51,28 +51,28 @@ public class Media extends AbstractDomainObject<Media> implements DomainObjectEn
5151
private Long idTwitter;
5252

5353
@NotNull
54-
@Column(name = "media_http",length=4096, nullable = false)
54+
@Column(name = "media_http", length=4096, columnDefinition="CHAR(4096)", nullable = false)
5555
private String mediaHttp = "";
5656

5757
@NotNull
58-
@Column(name = "media_https",length=4096, nullable = false)
58+
@Column(name = "media_https", length=4096, columnDefinition="CHAR(4096)", nullable = false)
5959
private String mediaHttps = "";
6060

6161
@URL
6262
@NotEmpty
63-
@Column(length=4096, nullable = false)
63+
@Column(length=4096, columnDefinition="CHAR(4096)", nullable = false)
6464
private String url;
6565

6666
@NotNull
67-
@Column(length=4096, nullable = false)
67+
@Column(length=4096, columnDefinition="CHAR(4096)", nullable = false)
6868
private String display = "";
6969

7070
@NotNull
71-
@Column(length=4096, nullable = false)
71+
@Column(length=4096, columnDefinition="CHAR(4096)", nullable = false)
7272
private String expanded = "";
7373

7474
@NotNull
75-
@Column(name = "media_type",length=4096, nullable = false)
75+
@Column(name = "media_type", length=4096, columnDefinition="CHAR(4096)", nullable = false)
7676
private String mediaType = "";
7777

7878

twitterwall2/src/main/java/org/woehlke/twitterwall/oodm/model/Mention.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
uniqueConstraints = {
2424
@UniqueConstraint(name = "unique_mention", columnNames = {"screen_name_unique", "id_twitter"}),
2525
@UniqueConstraint(name = "unique_mention_screen_name_unique", columnNames = {"screen_name_unique"}),
26-
},
26+
}/*,
2727
indexes = {
2828
@Index(name = "idx_mention_name", columnList = "name"),
2929
@Index(name = "idx_mention_screen_name", columnList = "screen_name"),
3030
@Index(name = "idx_mention_id_twitter_of_user", columnList = "id_twitter_of_user"),
3131
@Index(name = "idx_mention_fk_user", columnList = "fk_user")
32-
}
32+
} */
3333
)
3434
@NamedQueries({
3535
@NamedQuery(
@@ -93,7 +93,7 @@ public class Mention extends AbstractDomainObject<Mention> implements DomainObje
9393
@Column(name = "screen_name_unique", nullable = false)
9494
private String screenNameUnique = "";
9595

96-
@Column(name = "name",length=4096, nullable = false)
96+
@Column(name = "name", length=4096, columnDefinition="CHAR(4096)", nullable = false)
9797
private String name = "";
9898

9999
@NotNull

twitterwall2/src/main/java/org/woehlke/twitterwall/oodm/model/Url.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
name = "url",
2121
uniqueConstraints = {
2222
@UniqueConstraint(name="unique_url", columnNames = {"url"})
23-
},
23+
}/*,
2424
indexes = {
2525
@Index(name="idx_url_expanded", columnList="expanded"),
2626
@Index(name="idx_url_display", columnList="display")
27-
}
27+
} */
2828
)
2929
@NamedQueries({
3030
@NamedQuery(
@@ -52,11 +52,11 @@ public class Url extends AbstractDomainObject<Url> implements DomainObjectEntity
5252
protected Long id;
5353

5454
@NotNull
55-
@Column(length=4096,nullable = false)
55+
@Column(columnDefinition="CHAR(2048)",nullable = false)
5656
private String display="";
5757

5858
@NotNull
59-
@Column(length=4096,nullable = false)
59+
@Column(columnDefinition="CHAR(2048)",nullable = false)
6060
private String expanded="";
6161

6262
public static final String URL_PATTTERN_FOR_USER_HTTPS = "https://t\\.co/\\w*";
@@ -65,7 +65,7 @@ public class Url extends AbstractDomainObject<Url> implements DomainObjectEntity
6565

6666
@URL
6767
@NotEmpty
68-
@Column(nullable = false,length=4096)
68+
@Column(nullable = false,columnDefinition="TEXT")
6969
private String url;
7070

7171
@Transient

twitterwall2/src/main/java/org/woehlke/twitterwall/oodm/model/User.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
},
3333
indexes = {
3434
@Index(name="idx_userprofile_created_date", columnList="created_date"),
35-
@Index(name="idx_userprofile_description", columnList="description"),
35+
//@Index(name="idx_userprofile_description", columnList="description"),
3636
@Index(name="idx_userprofile_location", columnList="location"),
37-
@Index(name="idx_userprofile_url", columnList="url")
37+
//@Index(name="idx_userprofile_url", columnList="url")
3838
}
3939
)
4040
@NamedQueries({
@@ -162,13 +162,13 @@ public class User extends AbstractDomainObject<User> implements DomainObjectWith
162162
@Column(nullable = false)
163163
private String name;
164164

165-
@Column(name="url", length = 4096)
165+
@Column(name="url", length=4096, columnDefinition="CHAR(4096)")
166166
private String url;
167167

168-
@Column(length = 4096)
168+
@Column(length=4096, columnDefinition="CHAR(2048)")
169169
private String profileImageUrl;
170170

171-
@Column(name="description", length = 4096)
171+
@Column(name="description", length=4096, columnDefinition="CHAR(4096)")
172172
private String description;
173173

174174
@Column(name="location")
@@ -238,7 +238,7 @@ public class User extends AbstractDomainObject<User> implements DomainObjectWith
238238
@Column
239239
private Boolean useBackgroundImage;
240240

241-
@Column(length = 4096)
241+
@Column(length=4096, columnDefinition="CHAR(4096)")
242242
private String backgroundImageUrl;
243243

244244
@Column
@@ -259,7 +259,7 @@ public class User extends AbstractDomainObject<User> implements DomainObjectWith
259259
@Column
260260
private Boolean friend;
261261

262-
@Column(length = 4096)
262+
@Column(length=4096, columnDefinition="CHAR(4096)")
263263
private String profileBannerUrl;
264264

265265
@NotNull

twitterwall2/src/main/resources/application.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,37 @@ spring:
4040
enabled: false
4141
name: @project.name@
4242
datasource:
43-
driverClassName: org.postgresql.Driver
43+
#driverClassName: org.postgresql.Driver
44+
driverClassName: com.mysql.jdbc.Driver
4445
#initialSize: 5
4546
max-total: 20
4647
maxActive: 20
4748
maxIdle: 20
4849
#minIdle: 2
49-
platform: POSTGRESQL
50+
platform: MYSQL
51+
#platform: POSTGRESQL
5052
#removeAbandoned: true
5153
tomcat:
5254
max-active: 20
5355
#max-wait: 100000
5456
#test-on-borrow: true
5557
url: ${DATABASE_URL}
58+
password: ${DATABASE_PWD}
5659
continue-on-error: true
57-
schema: classpath:org/springframework/session/jdbc/schema-postgresql.sql
60+
#schema: classpath:org/springframework/session/jdbc/schema-postgresql.sql
61+
schema: classpath:org/springframework/session/jdbc/schema-mysql.sql
5862
devtools:
5963
livereload:
6064
enabled: false
6165
jpa:
6266
generate-ddl: true
6367
hibernate:
64-
ddl-auto: ${TWITTERWALL_JPA_HIBERNATE_DDL_AUTO}
65-
#ddl-auto: create-drop
68+
#ddl-auto: ${TWITTERWALL_JPA_HIBERNATE_DDL_AUTO}
69+
ddl-auto: create-drop
6670
properties:
6771
hibernate:
68-
dialect: org.hibernate.dialect.PostgreSQL94Dialect
72+
#dialect: org.hibernate.dialect.PostgreSQL94Dialect
73+
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
6974
show-sql: false
7075
template:
7176
cache: false

0 commit comments

Comments
 (0)