Skip to content

Commit 762d20f

Browse files
committed
Merge Hibernate Tools into ORM : Update the Reverse Engineering module to respect the coding rules
1 parent b238805 commit 762d20f

File tree

160 files changed

+6252
-8169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+6252
-8169
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
plugins {
2-
id "local.java-module"
2+
id "local.publishing-java-module"
33
}
44

55
description = "Library providing functionality to perform reverse engineering Hibernate related artefacts from an existing database"
66

77
dependencies {
88
implementation project( ':hibernate-core' )
9-
// implementation project( ':hibernate-ant' )
109
implementation "org.apache.commons:commons-collections4:4.5.0"
1110
implementation "com.google.googlejavaformat:google-java-format:1.27.0"
1211
implementation "org.freemarker:freemarker:2.3.34"
1312
implementation "org.antlr:antlr4-runtime:4.13.2"
14-
}
13+
}
14+
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
/*
2-
* Hibernate Tools, Tooling for your Hibernate Projects
3-
*
4-
* Copyright 2010-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.
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
174
*/
185
package org.hibernate.tool.reveng.api.core;
196

207
public interface AssociationInfo {
218

22-
String getCascade();
23-
String getFetch();
9+
String getCascade();
10+
String getFetch();
2411
Boolean getUpdate();
25-
Boolean getInsert();
12+
Boolean getInsert();
2613

2714
}
Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
/*
2-
* Hibernate Tools, Tooling for your Hibernate Projects
3-
*
4-
* Copyright 2010-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.
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
174
*/
185
package org.hibernate.tool.reveng.api.core;
196

@@ -26,28 +13,28 @@
2613
* Interface for fetching metadata from databases.
2714
* The dialect is configured with a ConnectionProvider but is not
2815
* required to actually use any connections.
29-
*
16+
*
3017
* The metadata methods all returns Iterator and allows for more efficient and partial reads
31-
* for those databases that has "flakey" JDBC metadata implementions.
32-
*
18+
* for those databases that has "flakey" JDBC metadata implementions.
19+
*
3320
* @author Max Rydahl Andersen
3421
*
3522
*/
3623
public interface RevengDialect {
3724

3825
/**
39-
* Configure the metadatadialect.
40-
* @param connectionProvider a {@link ConnectionProvider}
26+
* Configure the metadatadialect.
27+
* @param connectionProvider a {@link ConnectionProvider}
4128
*/
4229
public void configure(ConnectionProvider connectionProvider);
43-
44-
/**
30+
31+
/**
4532
* Return iterator over the tables that mathces catalog, schema and table
46-
*
33+
*
4734
* @param catalog name or null
4835
* @param schema name or null
49-
* @param table name or null
50-
* @return iterator with map elements that has "TABLE_NAME", "TABLE_SCHEMA", "TABLE_CAT", "TABLE_TYPE" keys.
36+
* @param table name or null
37+
* @return iterator with map elements that has "TABLE_NAME", "TABLE_SCHEMA", "TABLE_CAT", "TABLE_TYPE" keys.
5138
*/
5239
Iterator<Map<String,Object>> getTables(String catalog, String schema, String table);
5340

@@ -57,19 +44,19 @@ public interface RevengDialect {
5744
*/
5845
void close(Iterator<?> iterator);
5946

60-
/**
47+
/**
6148
* Return iterator over the indexes that mathces catalog, schema and table
62-
*
49+
*
6350
* @param catalog name or null
6451
* @param schema name or null
65-
* @param table name or null
66-
* @return iterator with map elements that has "TABLE_NAME", "TABLE_SCHEMA", "TABLE_CAT", "INDEX_NAME", "COLUMN_NAME", "NON_UNIQUE", "TYPE" keys.
52+
* @param table name or null
53+
* @return iterator with map elements that has "TABLE_NAME", "TABLE_SCHEMA", "TABLE_CAT", "INDEX_NAME", "COLUMN_NAME", "NON_UNIQUE", "TYPE" keys.
6754
*/
6855
Iterator<Map<String, Object>> getIndexInfo(String catalog, String schema, String table);
6956

7057
/**
7158
* Return iterator over the columns that mathces catalog, schema and table
72-
*
59+
*
7360
* @param catalog name or null
7461
* @param schema name or null
7562
* @param table name or null
@@ -80,7 +67,7 @@ public interface RevengDialect {
8067

8168
/**
8269
* Return iterator over the columns that mathces catalog, schema and table
83-
*
70+
*
8471
* @param catalog name or null
8572
* @param schema name or null
8673
* @param table name or null
@@ -91,7 +78,7 @@ public interface RevengDialect {
9178

9279
/**
9380
* Return iterator over the exported foreign keys that mathces catalog, schema and table
94-
*
81+
*
9582
* @param catalog name or null
9683
* @param schema name or null
9784
* @param table name or null
@@ -101,26 +88,26 @@ public interface RevengDialect {
10188

10289
/**
10390
* Does this name need quoting
104-
*
91+
*
10592
* @param name
10693
* @return
10794
*/
10895
boolean needQuote(String name);
109-
96+
11097
/**
11198
* Close any resources this dialect might have used.
11299
*/
113100
void close();
114101

115102
/**
116-
* Use database (possible native) metadata to suggest identifier strategy.
117-
*
103+
* Use database (possible native) metadata to suggest identifier strategy.
104+
*
118105
* @param catalog
119106
* @param schema
120107
* @param name
121108
* @return iterator with map elements that has "TABLE_NAME", "TABLE_SCHEMA", "TABLE_CAT", "HIBERNATE_STRATEGY" (null if no possible to determine strategy, otherwise return hibernate identifier strategy name/classname)
122109
*/
123110
public Iterator<Map<String, Object>> getSuggestedPrimaryKeyStrategyName(String catalog, String schema, String table);
124111

125-
112+
126113
}

tooling/hibernate-reveng/src/main/java/org/hibernate/tool/reveng/api/core/RevengDialectFactory.java

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
/*
2-
* Hibernate Tools, Tooling for your Hibernate Projects
3-
*
4-
* Copyright 2010-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.
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
174
*/
185
package org.hibernate.tool.reveng.api.core;
196

@@ -35,7 +22,7 @@
3522
import java.util.Properties;
3623

3724
public class RevengDialectFactory {
38-
25+
3926
private RevengDialectFactory() {}
4027

4128
public static RevengDialect createMetaDataDialect(Dialect dialect, Properties cfg) {
@@ -56,7 +43,7 @@ public static RevengDialect createMetaDataDialect(Dialect dialect, Properties cf
5643
public static RevengDialect fromClassName(String property) {
5744
if ( property != null ) {
5845
try {
59-
Class<?> revengDialectClass = ReflectHelper.classForName(
46+
Class<?> revengDialectClass = ReflectHelper.classForName(
6047
property,
6148
RevengDialectFactory.class );
6249
Constructor<?> revengDialectConstructor = revengDialectClass.getConstructor(
@@ -67,28 +54,33 @@ public static RevengDialect fromClassName(String property) {
6754
throw new RuntimeException(
6855
"Could not load MetaDataDialect: " + property, e );
6956
}
70-
} else {
57+
}
58+
else {
7159
return null;
7260
}
7361
}
74-
62+
7563
public static RevengDialect fromDialect(Dialect dialect) {
76-
if(dialect!=null) {
64+
if(dialect!=null) {
7765
if(dialect instanceof OracleDialect) {
7866
return new OracleMetaDataDialect();
79-
} else if (dialect instanceof H2Dialect) {
67+
}
68+
else if (dialect instanceof H2Dialect) {
8069
return new H2MetaDataDialect();
81-
} else if (dialect instanceof MySQLDialect) {
70+
}
71+
else if (dialect instanceof MySQLDialect) {
8272
return new MySQLMetaDataDialect();
83-
} else if (dialect instanceof HSQLDialect) {
73+
}
74+
else if (dialect instanceof HSQLDialect) {
8475
return new HSQLMetaDataDialect();
85-
}else if (dialect instanceof SQLServerDialect) {
76+
}
77+
else if (dialect instanceof SQLServerDialect) {
8678
return new SQLServerMetaDataDialect();
87-
}
79+
}
8880
}
8981
return null;
9082
}
91-
83+
9284
public static RevengDialect fromDialectName(String dialect) {
9385
if (dialect.toLowerCase().contains("oracle")) {
9486
return new OracleMetaDataDialect();
Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,46 @@
11
/*
2-
* Hibernate Tools, Tooling for your Hibernate Projects
3-
*
4-
* Copyright 2010-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.
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
174
*/
185
package org.hibernate.tool.reveng.api.core;
196

207
public class RevengSettings {
218

22-
9+
2310
final RevengStrategy rootStrategy;
24-
11+
2512
private String defaultPackageName = "";
2613
private boolean detectOptimisticLock = true;
2714
private boolean createCollectionForForeignKey = true;
2815
private boolean createManyToOneForForeignKey = true;
2916
private boolean detectManyToMany = true;
3017
private boolean detectOneToOne = true;
3118

32-
19+
3320
public RevengSettings(RevengStrategy rootStrategy) {
3421
this.rootStrategy = rootStrategy;
3522
}
36-
23+
3724
public RevengSettings setDefaultPackageName(String defaultPackageName) {
3825
if(defaultPackageName==null) {
3926
this.defaultPackageName = "";
40-
} else {
27+
}
28+
else {
4129
this.defaultPackageName= defaultPackageName.trim();
4230
}
4331
return this;
4432
}
45-
33+
4634
/** return the default packageName. Never null, at least the empty string */
4735
public String getDefaultPackageName() {
4836
return defaultPackageName;
4937
}
50-
38+
5139
/** If true, reverse engineering strategy will try and autodetect columns for optimistc locking, e.g. VERSION and TIMESTAMP */
5240
public boolean getDetectOptimsticLock() {
5341
return detectOptimisticLock ;
5442
}
55-
43+
5644
public RevengSettings setDetectOptimisticLock(
5745
boolean optimisticLockSupportEnabled) {
5846
this.detectOptimisticLock = optimisticLockSupportEnabled;
@@ -63,8 +51,8 @@ public RevengSettings setDetectOptimisticLock(
6351
public boolean createCollectionForForeignKey() {
6452
return createCollectionForForeignKey;
6553
}
66-
67-
54+
55+
6856
public RevengSettings setCreateCollectionForForeignKey(
6957
boolean createCollectionForForeignKey) {
7058
this.createCollectionForForeignKey = createCollectionForForeignKey;
@@ -75,7 +63,7 @@ public RevengSettings setCreateCollectionForForeignKey(
7563
public boolean createManyToOneForForeignKey() {
7664
return createManyToOneForForeignKey;
7765
}
78-
66+
7967
public RevengSettings setCreateManyToOneForForeignKey(
8068
boolean createManyToOneForForeignKey) {
8169
this.createManyToOneForForeignKey = createManyToOneForForeignKey;
@@ -86,11 +74,11 @@ public RevengSettings setDetectManyToMany(boolean b) {
8674
this.detectManyToMany = b;
8775
return this;
8876
}
89-
77+
9078
public boolean getDetectManyToMany() {
9179
return detectManyToMany;
9280
}
93-
81+
9482
public RevengSettings setDetectOneToOne(boolean b) {
9583
this.detectOneToOne = b;
9684
return this;
@@ -99,12 +87,12 @@ public RevengSettings setDetectOneToOne(boolean b) {
9987
public boolean getDetectOneToOne() {
10088
return detectOneToOne;
10189
}
102-
90+
10391
/** return the top/root strategy. Allows a lower strategy to ask another question. Be aware of possible recursive loops; e.g. do not call the root.tableToClassName in tableToClassName of a custom reversengineeringstrategy. */
10492
public RevengStrategy getRootStrategy() {
10593
return rootStrategy;
10694
}
10795

108-
109-
96+
97+
11098
}

0 commit comments

Comments
 (0)