@@ -7,7 +7,7 @@ project: tools
7
7
-# Center body
8
8
.feature-block
9
9
:asciidoc
10
- == Reverse Engineering from a Database
10
+ == Reverse engineering from a database
11
11
12
12
Hibernate Tools is a set of build plugins and a Java library that can be used to generate Hibernate/JPA entities starting
13
13
from your relational database structure. The default behavior of the code generator is highly customizable via
@@ -20,13 +20,13 @@ project: tools
20
20
21
21
.feature-block
22
22
:asciidoc
23
- == Project Configuration
23
+ == Project configuration
24
24
25
- For the purpose of a quick introduction, let's assume that you have a database running, e.g.
26
- https://github.com/maxandersen/sakila-h2[H2 Sakila database] reacheable at the following JDBC URL:
25
+ For the purpose of a quick introduction, let's suppose that we have a database running, for example,
26
+ https://github.com/maxandersen/sakila-h2[H2 Sakila database], reachable at the following JDBC URL:
27
27
`jdbc:h2:tcp://localhost/./sakila`.
28
28
29
- Let's assume as well that a `hibernate.properties` file below is available somewhere on the project's class path:
29
+ Let's also suppose that the following `hibernate.properties` file is available somewhere on the project class path:
30
30
31
31
[listing]
32
32
hibernate.connection.driver_class=org.h2.Driver
@@ -35,17 +35,16 @@ project: tools
35
35
hibernate.default_catalog=SAKILA
36
36
hibernate.default_schema=PUBLIC
37
37
38
- With this in place let's show some possible uses of the reverse engineering tooling to create Java classes from the
38
+ With this in place, let's show some possible uses of the reverse engineering tooling to create Java classes from the
39
39
database.
40
40
41
41
.feature-block
42
42
:asciidoc
43
- == Using the Maven Plugin
44
-
45
- The Hibernate Tools Maven plugin can be used either directly or by configuration
46
- in the `pom.xml` file of your project to generate entity classes or other artefacts. Let's assume you have created
47
- a Maven project with the following `pom.xml` file.
43
+ == Using the Maven plugin
48
44
45
+ The Hibernate Tools Maven plugin can be used either directly or by configuration in the `pom.xml` file of our
46
+ project to generate entity classes or other artefacts.
47
+ Let's assume we have created a Maven project with the following `pom.xml` file.
49
48
50
49
[source, xml]
51
50
----
@@ -82,13 +81,13 @@ project: tools
82
81
83
82
Let's assume as well that the `src/main/resources` folder contains the `hibernate.properties` file shown earlier.
84
83
85
- Having this in place simply issuing
84
+ Having this in place, simply issuing:
86
85
[source]
87
86
-----
88
87
mvn org.hibernate.tool:hibernate-tools-maven:${hibernate.version}:hbm2java
89
88
-----
90
- from a command line prompt in the project folder would use all the default settings to generate Java classes
91
- for all the tables in `target/generated-sources/`.
89
+ from a command line prompt in the project folder will use all the default settings to generate Java classes for the
90
+ tables in `target/generated-sources/`.
92
91
93
92
[source]
94
93
-----
@@ -102,17 +101,16 @@ project: tools
102
101
me@machine foo %
103
102
-----
104
103
105
-
106
104
Of course all these defaults can be overridden and tuned. Please consult the documentation for more information.
107
105
108
106
.feature-block
109
107
:asciidoc
110
- == Using Gradle Tasks
108
+ == Using Gradle tasks
111
109
112
- Let's assume in this case that we start off with a very simple default Gradle application, e.g. created with
113
- `gradle init --type java-application --dsl groovy`.
110
+ Let's assume in this case that we start off with a very simple default Gradle application, for example, a project
111
+ created via `gradle init --type java-application --dsl groovy`.
114
112
115
- With this setup, we replace the contents of the file `app/build.gradle` with the code below :
113
+ With this setup, we replace the contents of the file `app/build.gradle` with the code below:
116
114
117
115
[source, groovy]
118
116
-----
@@ -130,19 +128,19 @@ project: tools
130
128
}
131
129
-----
132
130
133
- As a last precondition, we make sure that the above `hibernate.properties` file is present in
134
- folder `app/src/main/resources`.
131
+ As a final precondition, we make sure that the above `hibernate.properties` file is present in folder
132
+ `app/src/main/resources`.
135
133
136
- With this in place, issuing
134
+ With this in place, issuing:
137
135
[source]
138
136
-----
139
137
gradle generateJava
140
138
-----
141
- will use all the default settings to generate Java classes for all the tables in `app/generated-sources/`.
139
+ will use all the default settings to generate Java classes for the tables in `app/generated-sources/`.
142
140
143
141
.feature-block
144
142
:asciidoc
145
- == Using Good Old Ant
143
+ == Using good old Ant
146
144
147
145
Creating an Ant project is very simple. We only need a `build.xml` file to be present in the root of the project.
148
146
In order to manage the needed dependencies, the easiest way is to use the Ant tasks provided by Apache Ivy.
@@ -180,9 +178,9 @@ project: tools
180
178
</project>
181
179
-----
182
180
183
- With the `hibernate.properties` file from above also present in the root of the project, simply issuing
181
+ With the `hibernate.properties` file from above also present in the root of the project, simply issuing:
184
182
[source]
185
183
-----
186
184
ant reveng
187
185
-----
188
- would generate the Java files in the folder `generated-sources`.
186
+ generates the Java files in the folder `generated-sources`.
0 commit comments