Skip to content

Commit 9caca0c

Browse files
committed
HHH-9490 - Migrate from dom4j to jaxb for XML processing;
HHH-9492 - Migrate to new bootstrap API (MetadataSources, etc); HHH-7078 - Split NamingStrategy into ImplicitNamingStrategy/PhysicalNamingStrategy; HHH-6005 - Better handling of implicit column naming with @ElementCollection of @embeddables; HHH-9633 - Add tests that explicitly test the "main" NamingStrategy impls
1 parent aa31b26 commit 9caca0c

File tree

1,284 files changed

+64856
-21747
lines changed

Some content is hidden

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

1,284 files changed

+64856
-21747
lines changed

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ subprojects { subProject ->
137137
dependencies {
138138
compile( libraries.logging )
139139
compile( libraries.logging_annotations )
140+
compile( libraries.logging_processor )
140141

141142
testCompile( libraries.junit )
142143
testCompile( libraries.byteman )
@@ -154,6 +155,8 @@ subprojects { subProject ->
154155
}
155156
jaxb( libraries.jaxb2_basics )
156157
jaxb( libraries.jaxb2_ant )
158+
jaxb( libraries.jaxb2_jaxb )
159+
jaxb( libraries.jaxb2_jaxb_xjc )
157160

158161
animalSniffer ( libraries.animal_sniffer )
159162
javaApiSignature ( libraries.java16_signature )
@@ -181,15 +184,12 @@ subprojects { subProject ->
181184
tasks.withType( JavaCompile.class ).all { task->
182185
task.options.compilerArgs += [
183186
"-nowarn",
184-
"-proc:none",
185187
"-encoding", "UTF-8",
186188
"-source", rootProject.javaLanguageLevel,
187189
"-target", rootProject.javaLanguageLevel
188190
]
189191
}
190192

191-
addLoggingProcessor( sourceSets.main )
192-
193193
jar {
194194
manifest = osgiManifest {
195195
// GRADLE-1411: Even if we override Imports and Exports

hibernate-core/hibernate-core.gradle

+21-24
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ idea {
109109
task jaxb {
110110
ext {
111111
// input schemas
112-
cfgXsd = file( 'src/main/resources/org/hibernate/hibernate-configuration-4.0.xsd')
113-
hbmXsd = file( 'src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd' )
112+
cfgXsd = file( 'src/main/resources/org/hibernate/xsd/cfg/legacy-configuration-4.0.xsd')
113+
hbmXsd = file( 'src/main/resources/org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd' )
114114
ormXsd = file( 'src/main/resources/org/hibernate/jpa/orm_2_0.xsd' )
115115

116116
// input bindings
@@ -133,33 +133,30 @@ task jaxb {
133133
// hibernate-configuration
134134
ant.xjc(
135135
destdir: '${jaxbTargetDir}',
136-
package: 'org.hibernate.internal.jaxb.cfg',
137136
binding: 'src/main/xjb/hbm-configuration-bindings.xjb',
138137
schema: cfgXsd.path
139138
)
140139

141-
// hibernate-mapping
142-
ant.xjc(
143-
destdir: '${jaxbTargetDir}',
144-
package: 'org.hibernate.internal.jaxb.mapping.hbm',
145-
binding: hbmXjb.path,
146-
schema: hbmXsd.path,
147-
extension: 'true'
148-
) {
149-
arg line: '-Xinheritance'
150-
}
151-
152-
// orm.xml (jpa)
153-
ant.xjc(
154-
destdir: '${jaxbTargetDir}',
155-
package: 'org.hibernate.internal.jaxb.mapping.orm',
156-
binding: 'src/main/xjb/orm-bindings.xjb',
157-
schema: ormXsd.path
158-
)
140+
// hibernate-mapping
141+
ant.xjc(
142+
destdir: '${jaxbTargetDir}',
143+
binding: 'src/main/xjb/hbm-mapping-bindings.xjb',
144+
schema: hbmXsd.path,
145+
extension: 'true'
146+
) {
147+
arg line: '-Xinheritance -Xsimplify'
148+
}
149+
150+
// // orm.xml (jpa)
151+
// ant.xjc(
152+
// destdir: '${jaxbTargetDir}',
153+
// package: 'org.hibernate.internal.jaxb.mapping.orm',
154+
// binding: 'src/main/xjb/orm-bindings.xjb',
155+
// schema: ormXsd.path
156+
// )
159157
}
160158

161159
}
162160

163-
runSourceGenerators.dependsOn jaxb
164-
runSourceGenerators.dependsOn generateGrammarSource
165-
161+
sourceSets.main.sourceGeneratorsTask.dependsOn jaxb
162+
sourceSets.main.sourceGeneratorsTask.dependsOn generateGrammarSource

hibernate-core/src/main/java/org/hibernate/DuplicateMappingException.java

+35-5
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,49 @@ public static enum Type {
3737
/**
3838
* A duplicate entity definition was encountered.
3939
*/
40-
ENTITY,
40+
ENTITY( "entity" ),
41+
/**
42+
* A duplicate collection role was encountered
43+
*/
44+
COLLECTION( "collection" ),
4145
/**
4246
* A duplicate table definition was encountered.
4347
*/
44-
TABLE,
48+
TABLE( "table" ),
4549
/**
4650
* A duplicate property/attribute definition was encountered.
4751
*/
48-
PROPERTY,
52+
PROPERTY( "property" ),
53+
/**
54+
* A duplicate column definition was encountered.
55+
*/
56+
COLUMN( "column" ),
4957
/**
5058
* A duplicate column definition was encountered.
5159
*/
52-
COLUMN
60+
COLUMN_BINDING( "column-binding" ),
61+
/**
62+
* A duplicate named entity graph was encountered
63+
*/
64+
NAMED_ENTITY_GRAPH( "NamedEntityGraph" ),
65+
/**
66+
* A duplicate named query (ql or native) was encountered
67+
*/
68+
QUERY( "query" ),
69+
/**
70+
* A duplicate ResultSetMapping was encountered
71+
*/
72+
RESULT_SET_MAPPING( "ResultSetMapping" ),
73+
/**
74+
* A duplicate NamedStoredProcedureQuery was encountered
75+
*/
76+
PROCEDURE( "NamedStoredProcedureQuery" );
77+
78+
private final String text;
79+
80+
Type(String text) {
81+
this.text = text;
82+
}
5383
}
5484

5585
private final String name;
@@ -62,7 +92,7 @@ public static enum Type {
6292
* @param name The name of the duplicated thing.
6393
*/
6494
public DuplicateMappingException(Type type, String name) {
65-
this( type.name(), name );
95+
this( type.text, name );
6696
}
6797

6898
/**

hibernate-core/src/main/java/org/hibernate/EntityMode.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
package org.hibernate;
2525

26+
import java.util.Locale;
27+
2628
/**
2729
* Defines the representation modes available for entities.
2830
*
@@ -40,19 +42,21 @@ public enum EntityMode {
4042
*/
4143
MAP( "dynamic-map" );
4244

43-
private final String name;
45+
private final String externalName;
46+
47+
private EntityMode(String externalName) {
48+
this.externalName = externalName;
49+
}
4450

45-
private EntityMode(String name) {
46-
this.name = name;
51+
public String getExternalName() {
52+
return externalName;
4753
}
4854

4955
@Override
5056
public String toString() {
51-
return name;
57+
return externalName;
5258
}
5359

54-
private static final String DYNAMIC_MAP_NAME = MAP.name.toUpperCase();
55-
5660
/**
5761
* Legacy-style entity-mode name parsing. <b>Case insensitive</b>
5862
*
@@ -65,11 +69,10 @@ public static EntityMode parse(String entityMode) {
6569
if ( entityMode == null ) {
6670
return POJO;
6771
}
68-
entityMode = entityMode.toUpperCase();
69-
if ( DYNAMIC_MAP_NAME.equals( entityMode ) ) {
72+
if ( MAP.externalName.equalsIgnoreCase( entityMode ) ) {
7073
return MAP;
7174
}
72-
return valueOf( entityMode );
75+
return valueOf( entityMode.toUpperCase( Locale.ENGLISH ) );
7376
}
7477

7578
}

hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
package org.hibernate;
2525

26-
import org.hibernate.internal.jaxb.Origin;
26+
import org.hibernate.boot.jaxb.Origin;
2727
import org.hibernate.internal.util.xml.XmlDocument;
2828

2929
/**
@@ -94,7 +94,7 @@ public InvalidMappingException(String customMessage, XmlDocument xmlDocument) {
9494
* @param origin The origin of the invalid mapping document
9595
*/
9696
public InvalidMappingException(String customMessage, Origin origin) {
97-
this( customMessage, origin.getType().toString(), origin.getName() );
97+
this( customMessage, origin.getType().getLegacyTypeText(), origin.getName() );
9898
}
9999

100100
/**

hibernate-core/src/main/java/org/hibernate/LockMode.java

+35-13
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* levels.
3434
*
3535
* @author Gavin King
36+
*
3637
* @see Session#lock(Object, LockMode)
3738
*/
3839
public enum LockMode {
@@ -44,44 +45,44 @@ public enum LockMode {
4445
* <br>
4546
* This is the "default" lock mode.
4647
*/
47-
NONE( 0 ),
48+
NONE( 0, "none" ),
4849
/**
4950
* A shared lock. Objects in this lock mode were read from
5051
* the database in the current transaction, rather than being
5152
* pulled from a cache.
5253
*/
53-
READ( 5 ),
54+
READ( 5, "read" ),
5455
/**
5556
* An upgrade lock. Objects loaded in this lock mode are
5657
* materialized using an SQL <tt>select ... for update</tt>.
5758
*
5859
* @deprecated instead use PESSIMISTIC_WRITE
5960
*/
6061
@Deprecated
61-
UPGRADE( 10 ),
62+
UPGRADE( 10, "upgrade" ),
6263
/**
6364
* Attempt to obtain an upgrade lock, using an Oracle-style
6465
* <tt>select for update nowait</tt>. The semantics of
6566
* this lock mode, once obtained, are the same as
6667
* <tt>UPGRADE</tt>.
6768
*/
68-
UPGRADE_NOWAIT( 10 ),
69+
UPGRADE_NOWAIT( 10, "upgrade-nowait" ),
6970

7071
/**
7172
* Attempt to obtain an upgrade lock, using an Oracle-style
7273
* <tt>select for update skip locked</tt>. The semantics of
7374
* this lock mode, once obtained, are the same as
7475
* <tt>UPGRADE</tt>.
7576
*/
76-
UPGRADE_SKIPLOCKED( 10 ),
77+
UPGRADE_SKIPLOCKED( 10, "upgrade-skiplocked" ),
7778

7879
/**
7980
* A <tt>WRITE</tt> lock is obtained when an object is updated
8081
* or inserted. This lock mode is for internal use only and is
8182
* not a valid mode for <tt>load()</tt> or <tt>lock()</tt> (both
8283
* of which throw exceptions if WRITE is specified).
8384
*/
84-
WRITE( 10 ),
85+
WRITE( 10, "write" ),
8586

8687
/**
8788
* Similar to {@link #UPGRADE} except that, for versioned entities,
@@ -90,7 +91,7 @@ public enum LockMode {
9091
* @deprecated instead use PESSIMISTIC_FORCE_INCREMENT
9192
*/
9293
@Deprecated
93-
FORCE( 15 ),
94+
FORCE( 15, "force" ),
9495

9596
/**
9697
* start of javax.persistence.LockModeType equivalent modes
@@ -100,34 +101,37 @@ public enum LockMode {
100101
* Optimistically assume that transaction will not experience contention for
101102
* entities. The entity version will be verified near the transaction end.
102103
*/
103-
OPTIMISTIC( 6 ),
104+
OPTIMISTIC( 6, "optimistic" ),
104105

105106
/**
106107
* Optimistically assume that transaction will not experience contention for
107108
* entities. The entity version will be verified and incremented near the transaction end.
108109
*/
109-
OPTIMISTIC_FORCE_INCREMENT( 7 ),
110+
OPTIMISTIC_FORCE_INCREMENT( 7, "optimistic_force_increment" ),
110111

111112
/**
112113
* Implemented as PESSIMISTIC_WRITE.
113114
* TODO: introduce separate support for PESSIMISTIC_READ
114115
*/
115-
PESSIMISTIC_READ( 12 ),
116+
PESSIMISTIC_READ( 12, "pessimistic_read" ),
116117

117118
/**
118119
* Transaction will obtain a database lock immediately.
119120
* TODO: add PESSIMISTIC_WRITE_NOWAIT
120121
*/
121-
PESSIMISTIC_WRITE( 13 ),
122+
PESSIMISTIC_WRITE( 13, "pessimistic_write" ),
122123

123124
/**
124125
* Transaction will immediately increment the entity version.
125126
*/
126-
PESSIMISTIC_FORCE_INCREMENT( 17 );
127+
PESSIMISTIC_FORCE_INCREMENT( 17, "pessimistic_force_increment" );
128+
127129
private final int level;
130+
private final String externalForm;
128131

129-
private LockMode(int level) {
132+
private LockMode(int level, String externalForm) {
130133
this.level = level;
134+
this.externalForm = externalForm;
131135
}
132136

133137
/**
@@ -151,4 +155,22 @@ public boolean greaterThan(LockMode mode) {
151155
public boolean lessThan(LockMode mode) {
152156
return level < mode.level;
153157
}
158+
159+
public String toExternalForm() {
160+
return externalForm;
161+
}
162+
163+
public static LockMode fromExternalForm(String externalForm) {
164+
if ( externalForm == null ) {
165+
return NONE;
166+
}
167+
168+
for ( LockMode lockMode : LockMode.values() ) {
169+
if ( lockMode.externalForm.equalsIgnoreCase( externalForm ) ) {
170+
return lockMode;
171+
}
172+
}
173+
174+
throw new IllegalArgumentException( "Unable to interpret LockMode reference from incoming external form : " + externalForm );
175+
}
154176
}

hibernate-core/src/main/java/org/hibernate/MappingNotFoundException.java

+3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
* Thrown when a resource for a mapping could not be found.
2828
*
2929
* @author Max Rydahl Andersen
30+
*
31+
* @deprecated Use {@link org.hibernate.boot.MappingNotFoundException} instead.
3032
*/
33+
@Deprecated
3134
public class MappingNotFoundException extends MappingException {
3235
private final String path;
3336
private final String type;

0 commit comments

Comments
 (0)