-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.html
119 lines (104 loc) · 3.45 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<html>
<head>
<title>MariaDB | Ebean ORM</title>
<meta name="layout" content="_layout2/base-docs.html"/>
<meta name="bread1" content="Database platforms" href="/docs/database"/>
<meta name="bread2" content="MariaDB" href="/docs/database/mariadb"/>
<#assign n0_docs="active">
<#assign n1_platforms="active">
<#assign n2_mariadb="active">
</head>
<body>
<h2>MariaDB</h2>
<p>
Since 12.3.6 MariaDB has it's own platform with SQL2012 History support and DDL generation to support that.
</p>
<h3>MariaDB JDBC Driver - useLegacyDatetimeCode</h3>
<p>
The expectation is that the MariaDB JDBC driver is used and that <code>useLegacyDatetimeCode=false</code>
is set. This ensures the JDBC driver honours the database server timezone. ebean-test will automatically
set the useLegacyDatetimeCode parameter for but otherwise we need to ensure that parameter is set on
the connection pool.
</p>
<pre content="properties">
## example manually setting useLegacyDatetimeCode in properties file
datasource.db.username=my_app
datasource.db.password=test
datasource.db.url=jdbc:mariadb://localhost:4306/unit?useLegacyDatetimeCode=false
</pre>
<p>
It is expected that the MariaDB JDBC Driver is used.
</p>
<pre content="xml">
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.6.0</version>
</dependency>
</pre>
<h3>Testing</h3>
<p>
To test against MariaDB docker test container set the <em>platform</em> to <code>mariadb</code> in
<code>src/test/resources/application-test.yaml</code>
</p>
<p>
Refer to <a href="/docs/testing">docs / testing</a> if application-test.yaml doesn't exist yet.
</p>
<pre content="yml">
ebean:
test:
platform: mariadb
ddlMode: dropCreate # none | dropCreate | migrations | create
dbName: my_app
</pre>
<p>
The above will use the following defaults:
</p>
<table class="compact w100">
<tr><th>username:</th><td>{dbName}</td></tr>
<tr><th>password:</th><td>test</td></tr>
<tr><th>port:</th><td>4306</td></tr>
<tr><th>url:</th><td>jdbc:mariadb://localhost:{port}/{dbName}?useLegacyDatetimeCode=false</td></tr>
<tr><th>image:</th><td>mariadb:{version:10}</td></tr>
</table>
<p> </p>
<p> </p>
<h2 id="ebean-mariadb">ebean-mariadb dependency</h2>
<p>
We can use the <code>io.ebean:ebean-mariadb</code> dependency rather than <code>io.ebean:ebean</code> if we want to only
bring in the MariaDB specific platform code. Depending on <code>io.ebean:ebean</code> will bring in all platforms.
</p>
<h2 id="types">Types</h2>
<h5>UUID</h5>
<p>
UUID is not a native MariaDB type and can be mapped to either BINARY(16) or VARCHAR(36).
</p>
<h5>JSON</h5>
<p>
We can use <code>@DbJson</code> to map content.
</p>
<h2 id="history">History support</h2>
<p>
MariaDB has native SQL2011 history support and Ebean will generate DDL to enable and use this
on entities annotated with <code>@History</code>.
</p>
<h2 id="start-docker">Docker container</h2>
<p>
We can programmatically start a MariaDB docker container using <code>ebean-test-docker</code> via:
</p>
<pre content="java">
package main;
import io.ebean.docker.commands.MariaDBContainer;
public class Main {
public static void main(String[] args) {
MariaDBContainer container = MariaDBContainer.newBuilder("10.5")
.dbName("unit")
.password("unit")
.build();
container.start();
}
}
</pre>
<@next_edit "SQL Server" "/docs/database/sqlserver" "/docs/database/mariadb/index.html"/>
</body>
</html>