Skip to content

Commit 8a02715

Browse files
committed
HBX-2984: Create Reference Guide for Ant
- Add a new example showing the use of the JPA configuration Signed-off-by: Koen Aers <[email protected]>
1 parent e1c6af3 commit 8a02715

File tree

6 files changed

+110
-2
lines changed

6 files changed

+110
-2
lines changed

ant/docs/examples/common/included.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<project name="common" xmlns:ivy="antlib:org.apache.ivy.ant">
1717

1818
<property name="hibernate-tools.version" value="7.0.0.CR1"/>
19+
<property name="javaee-api.version" value="8.0.1"/>
1920
<property name="jdbc-driver.org" value="com.h2database"/>
2021
<property name="jdbc-driver.module" value="h2"/>
2122
<property name="jdbc-driver.version" value="2.3.232"/>
@@ -26,6 +27,12 @@
2627
revision="${hibernate-tools.version}"
2728
pathid="hibernate-tools.path"
2829
inline="true"/>
30+
<ivy:cachepath
31+
organisation="javax"
32+
module="javaee-api"
33+
revision="${javaee-api.version}"
34+
pathid="javaee-api.path"
35+
inline="true"/>
2936
<ivy:cachepath
3037
organisation="${jdbc-driver.org}"
3138
module="${jdbc-driver.module}"
@@ -35,6 +42,7 @@
3542

3643
<path id="classpath">
3744
<path refid="hibernate-tools.path"/>
45+
<path refid="javaee-api.path"/>
3846
<path refid="jdbc-driver.path"/>
3947
<path location="."/>
4048
</path>

ant/docs/examples/jpa/Foo.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import jakarta.persistence.Entity;
2+
import jakarta.persistence.Id;
3+
4+
@Entity
5+
public class Foo {
6+
7+
@Id
8+
private int id;
9+
private String bar;
10+
11+
public int getId() { return id; }
12+
public void setId(int id) { this.id = id; }
13+
14+
public String getBar() { return bar;}
15+
public void setBar(String bar) { this.bar = bar; }
16+
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
~ Copyright 2004 - 2025 Red Hat, Inc.
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" basis,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
<persistence>
17+
<persistence-unit name="bar">
18+
<properties>
19+
<property name="jakarta.persistence.jdbc.driver" value="org.h2.Driver" />
20+
<property name="jakarta.persistence.jdbc.url" value="jdbc:h2:mem:" />
21+
</properties>
22+
<class>Foo</class>
23+
</persistence-unit>
24+
</persistence>

ant/docs/examples/jpa/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
~ Copyright 2004 - 2025 Red Hat, Inc.
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" basis,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
To run this example:
17+
- Have [Apache Ant](https://ant.apache.org) installed
18+
- Issue `ant` from a command-line window

ant/docs/examples/jpa/build.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--
2+
~ Copyright 2004 - 2025 Red Hat, Inc.
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" basis,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
<project name="jpa" default="reveng">
17+
18+
<!-- Include the 'hibernatetool' task definition from the file '../common/included.xml' -->
19+
<include file="../common/included.xml"/>
20+
21+
<target name="reveng" depends="common.compile">
22+
<hibernatetool destdir="generated">
23+
<classpath location="."/>
24+
<!-- JPA configuration read from 'META-INF/persistence.xml' -->
25+
<jpaconfiguration persistenceunit="bar"/>
26+
<!-- Export the DDL file as an example use of the JPA configuration above -->
27+
<hbm2ddl outputfilename="bar.sql"/>
28+
</hibernatetool>
29+
30+
</target>
31+
32+
</project>
33+

test/pom.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@
3737
<maven.deploy.skip>true</maven.deploy.skip>
3838
<maven.install.skip>true</maven.install.skip>
3939
</properties>
40-
41-
<profiles>
40+
<dependencies>
41+
<dependency>
42+
<groupId>org.junit.jupiter</groupId>
43+
<artifactId>junit-jupiter-api</artifactId>
44+
<version>5.12.2</version>
45+
<scope>compile</scope>
46+
</dependency>
47+
</dependencies>
48+
49+
<profiles>
4250
<profile>
4351
<id>all</id>
4452
<modules>

0 commit comments

Comments
 (0)