File tree Expand file tree Collapse file tree 5 files changed +90
-9
lines changed
it/GenerateJavaWithAnnotations
main/java/org/hibernate/tool/maven Expand file tree Collapse file tree 5 files changed +90
-9
lines changed Original file line number Diff line number Diff line change 1+ # ###########################################################################
2+ # Hibernate Tools, Tooling for your Hibernate Projects #
3+ # #
4+ # Copyright 2018-2025 Red Hat, Inc. #
5+ # #
6+ # Licensed under the Apache License, Version 2.0 (the "License"); #
7+ # you may not use this file except in compliance with the License. #
8+ # You may obtain a copy of the License at #
9+ # #
10+ # http://www.apache.org/licenses/LICENSE-2.0 #
11+ # #
12+ # Unless required by applicable law or agreed to in writing, software #
13+ # distributed under the License is distributed on an "AS IS" basis, #
14+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15+ # See the License for the specific language governing permissions and #
16+ # limitations under the License. #
17+ # ###########################################################################
18+ invoker.goals = generate-resources
Original file line number Diff line number Diff line change 1+ /*
2+ * Hibernate Tools, Tooling for your Hibernate Projects
3+ *
4+ * Copyright 2018-2025 Red Hat, Inc.
5+ *
6+ * Licensed under the Apache License, Version 2.0 (the "License");
7+ * you may not use this file except in compliance with the License.
8+ * You may obtain a copy of the License at
9+ *
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ *
12+ * Unless required by applicable law or agreed to in writing, software
13+ * distributed under the License is distributed on an "AS IS" basis,
14+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ * See the License for the specific language governing permissions and
16+ * limitations under the License.
17+ */
118import java.sql.DriverManager;
219import java.sql.Connection;
320
4- String JDBC_CONNECTION = "jdbc:h2:mem: test";
21+ String JDBC_CONNECTION = "jdbc:h2:" + basedir + "/ test";
522String CREATE_PERSON_TABLE = "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";
623
7- DriverManager
8- .getConnection(JDBC_CONNECTION)
9- .createStatement()
10- .execute(CREATE_PERSON_TABLE);
11-
12- System.out.println("Database created!");
24+ Connection connection = DriverManager.getConnection(JDBC_CONNECTION);
25+ connection.createStatement().execute(CREATE_PERSON_TABLE);
26+ connection.close();
Original file line number Diff line number Diff line change 1+ # ###########################################################################
2+ # Hibernate Tools, Tooling for your Hibernate Projects #
3+ # #
4+ # Copyright 2018-2025 Red Hat, Inc. #
5+ # #
6+ # Licensed under the Apache License, Version 2.0 (the "License"); #
7+ # you may not use this file except in compliance with the License. #
8+ # You may obtain a copy of the License at #
9+ # #
10+ # http://www.apache.org/licenses/LICENSE-2.0 #
11+ # #
12+ # Unless required by applicable law or agreed to in writing, software #
13+ # distributed under the License is distributed on an "AS IS" basis, #
14+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15+ # See the License for the specific language governing permissions and #
16+ # limitations under the License. #
17+ # ###########################################################################
18+ hibernate.connection.driver_class =org.h2.Driver
19+ hibernate.connection.url =jdbc:h2:./test
20+ hibernate.default_catalog =TEST
21+ hibernate.default_schema =PUBLIC
Original file line number Diff line number Diff line change 1- System.out.println("Hello from 'verify.bsh'");
1+ /*
2+ * Hibernate Tools, Tooling for your Hibernate Projects
3+ *
4+ * Copyright 2018-2025 Red Hat, Inc.
5+ *
6+ * Licensed under the Apache License, Version 2.0 (the "License");
7+ * you may not use this file except in compliance with the License.
8+ * You may obtain a copy of the License at
9+ *
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ *
12+ * Unless required by applicable law or agreed to in writing, software
13+ * distributed under the License is distributed on an "AS IS" basis,
14+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ * See the License for the specific language governing permissions and
16+ * limitations under the License.
17+ */
18+ import java.nio.file.Files;
19+
20+ File personEntity = new File(basedir, "target/generated-sources/Person.java");
21+ if (!personEntity.isFile()) {
22+ throw new FileNotFoundException("Could not find generated JPA Entity: " + personEntity);
23+ }
24+ byte[] raw = Files.readAllBytes(personEntity.toPath());
25+ if (!new String(raw).contains("import jakarta.persistence.Entity;")) {
26+ throw new RuntimeException("The generated java file is not a JPA Entity");
27+ }
28+
29+
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public class GenerateJavaMojo extends AbstractGenerationMojo {
4949
5050 /** Code will contain JPA features, e.g. using annotations from jakarta.persistence
5151 * and org.hibernate.annotations. */
52- @ Parameter (defaultValue = "false " )
52+ @ Parameter (defaultValue = "true " )
5353 private boolean ejb3 ;
5454
5555 /** Code will contain JDK 5 constructs such as generics and static imports. */
You can’t perform that action at this time.
0 commit comments