|
20 | 20 |
|
21 | 21 | ## 1. The `<hibernatetool>` Task |
22 | 22 |
|
23 | | -### 1.1 `<hibernatetool>` task definition |
| 23 | +### 1.1 `<hibernatetool>` Task Definition |
24 | 24 | To use the Ant tasks you need to have the `<hibernatetool>` task defined. |
25 | 25 | That is done in your `build.xml` file by inserting the following XML. |
26 | 26 |
|
@@ -55,4 +55,70 @@ the jdbc driver and for the version information. See an example in the snippet b |
55 | 55 | <property name="jdbc-driver.version" value="2.3.232"/> |
56 | 56 | ``` |
57 | 57 |
|
| 58 | +### 1.2 `<hibernatetool>` Task Element |
58 | 59 |
|
| 60 | +As an introductory example, look at the XML snippet below. |
| 61 | +```xml |
| 62 | +<target name="reveng"> |
| 63 | + <hibernatetool destdir="generated-sources"> |
| 64 | + <jdbcconfiguration propertyfile="hibernate.properties" /> |
| 65 | + <hbm2java/> |
| 66 | + </hibernatetool> |
| 67 | +</target> |
| 68 | +``` |
| 69 | +The snippet creates an Ant target named `reveng` which contains an embedded `hibernatetool` task. |
| 70 | +This task has the folder `generated-sources` set as its destination directory. Additionally |
| 71 | +it specifies a JDBC configuration for which the connection information is to be found in the |
| 72 | +file `hibernate.properties`. Finally it contains a `hbm2java` element that will generate Java files |
| 73 | +based on the JDBC configuration in the specified destination directory. |
| 74 | + |
| 75 | +As illustrated, the `hibernatetool` task element can be configured with additional attributes |
| 76 | +and nested elements. |
| 77 | + |
| 78 | +Let's walk through the different possibilities. |
| 79 | + |
| 80 | +#### 1.2.1 The 'destdir' Attribute |
| 81 | + |
| 82 | +This mandatory attribute lets you control the folder where the artefacts will be generated. If the |
| 83 | +specified folder does not exist it will be created. |
| 84 | + |
| 85 | +```xml |
| 86 | +<hibernatetool destdir="path/to/generated/sources"> |
| 87 | + ... |
| 88 | +</hibernatetool> |
| 89 | +``` |
| 90 | +In the snippet above the artefacts will be generated in the subfolder `path/to/generated/sources` of |
| 91 | +the working directory. |
| 92 | + |
| 93 | +#### 1.2.2 The 'templatepath' Attribute |
| 94 | + |
| 95 | +The generation of artefacts is based on FreeMarker templates. By default, the templates are |
| 96 | +looked up on the classpath. If you want to have fine control over the artefact generation |
| 97 | +you can create custom templates. The optional `templatepath` attribute lets you specify the |
| 98 | +location of those templates. |
| 99 | + |
| 100 | +```xml |
| 101 | +<hibernatetool |
| 102 | + destdir="..." |
| 103 | + templatepath="path/to/templates"> |
| 104 | + ... |
| 105 | +</hibernatetool> |
| 106 | +``` |
| 107 | + |
| 108 | + |
| 109 | +#### 1.2.3 The 'classpath' Element |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +## 2. The Hibernate Tools Configurations |
| 115 | + |
| 116 | +The reverse engineering and generation of artefacts with Hibernate Tools is based on a |
| 117 | + |
| 118 | +### 2.1 JDBC Configuration |
| 119 | + |
| 120 | +### 2.2 JPA Configuration |
| 121 | + |
| 122 | +### 2.3 Native Configuration |
| 123 | + |
| 124 | +## 3. The Hibernate Tools Exporters |
0 commit comments