23
23
*/
24
24
package org .hibernate .cfg .annotations ;
25
25
26
+ import static org .hibernate .cfg .BinderHelper .toAliasEntityMap ;
27
+ import static org .hibernate .cfg .BinderHelper .toAliasTableMap ;
28
+
26
29
import java .util .ArrayList ;
27
30
import java .util .HashMap ;
28
31
import java .util .Iterator ;
29
32
import java .util .List ;
33
+
30
34
import javax .persistence .Access ;
31
35
import javax .persistence .Entity ;
32
36
import javax .persistence .JoinColumn ;
35
39
import javax .persistence .SecondaryTable ;
36
40
import javax .persistence .SecondaryTables ;
37
41
38
- import org .jboss .logging .Logger ;
39
-
40
42
import org .hibernate .AnnotationException ;
41
43
import org .hibernate .AssertionFailure ;
42
44
import org .hibernate .EntityMode ;
86
88
import org .hibernate .engine .spi .ExecuteUpdateResultCheckStyle ;
87
89
import org .hibernate .engine .spi .FilterDefinition ;
88
90
import org .hibernate .internal .CoreMessageLogger ;
89
- import org .hibernate .internal .util .ReflectHelper ;
90
91
import org .hibernate .internal .util .StringHelper ;
91
92
import org .hibernate .mapping .DependantValue ;
92
93
import org .hibernate .mapping .Join ;
96
97
import org .hibernate .mapping .Table ;
97
98
import org .hibernate .mapping .TableOwner ;
98
99
import org .hibernate .mapping .Value ;
99
-
100
- import static org .hibernate .cfg .BinderHelper .toAliasEntityMap ;
101
- import static org .hibernate .cfg .BinderHelper .toAliasTableMap ;
100
+ import org .jboss .logging .Logger ;
102
101
103
102
104
103
/**
@@ -119,7 +118,6 @@ public class EntityBinder {
119
118
private Boolean insertableDiscriminator ;
120
119
private boolean dynamicInsert ;
121
120
private boolean dynamicUpdate ;
122
- private boolean explicitHibernateEntityAnnotation ;
123
121
private OptimisticLockType optimisticLockType ;
124
122
private PolymorphismType polymorphismType ;
125
123
private boolean selectBeforeUpdate ;
@@ -152,59 +150,52 @@ public EntityBinder() {
152
150
153
151
public EntityBinder (
154
152
Entity ejb3Ann ,
155
- org .hibernate .annotations .Entity hibAnn ,
156
153
XClass annotatedClass ,
157
154
PersistentClass persistentClass ,
158
155
Mappings mappings ) {
159
156
this .mappings = mappings ;
160
157
this .persistentClass = persistentClass ;
161
158
this .annotatedClass = annotatedClass ;
162
159
bindEjb3Annotation ( ejb3Ann );
163
- bindHibernateAnnotation ( hibAnn );
160
+ bindHibernateAnnotation ();
164
161
}
165
162
166
163
@ SuppressWarnings ("SimplifiableConditionalExpression" )
167
- private void bindHibernateAnnotation (org . hibernate . annotations . Entity hibAnn ) {
164
+ private void bindHibernateAnnotation () {
168
165
{
169
166
final DynamicInsert dynamicInsertAnn = annotatedClass .getAnnotation ( DynamicInsert .class );
170
167
this .dynamicInsert = dynamicInsertAnn == null
171
- ? ( hibAnn == null ? false : hibAnn . dynamicInsert () )
168
+ ? false
172
169
: dynamicInsertAnn .value ();
173
170
}
174
171
175
172
{
176
173
final DynamicUpdate dynamicUpdateAnn = annotatedClass .getAnnotation ( DynamicUpdate .class );
177
174
this .dynamicUpdate = dynamicUpdateAnn == null
178
- ? ( hibAnn == null ? false : hibAnn . dynamicUpdate () )
175
+ ? false
179
176
: dynamicUpdateAnn .value ();
180
177
}
181
178
182
179
{
183
180
final SelectBeforeUpdate selectBeforeUpdateAnn = annotatedClass .getAnnotation ( SelectBeforeUpdate .class );
184
181
this .selectBeforeUpdate = selectBeforeUpdateAnn == null
185
- ? ( hibAnn == null ? false : hibAnn . selectBeforeUpdate () )
182
+ ? false
186
183
: selectBeforeUpdateAnn .value ();
187
184
}
188
185
189
186
{
190
187
final OptimisticLocking optimisticLockingAnn = annotatedClass .getAnnotation ( OptimisticLocking .class );
191
188
this .optimisticLockType = optimisticLockingAnn == null
192
- ? ( hibAnn == null ? OptimisticLockType .VERSION : hibAnn . optimisticLock () )
189
+ ? OptimisticLockType .VERSION
193
190
: optimisticLockingAnn .type ();
194
191
}
195
192
196
193
{
197
194
final Polymorphism polymorphismAnn = annotatedClass .getAnnotation ( Polymorphism .class );
198
195
this .polymorphismType = polymorphismAnn == null
199
- ? ( hibAnn == null ? PolymorphismType .IMPLICIT : hibAnn . polymorphism () )
196
+ ? PolymorphismType .IMPLICIT
200
197
: polymorphismAnn .type ();
201
198
}
202
-
203
- if ( hibAnn != null ) {
204
- // used later in bind for logging
205
- explicitHibernateEntityAnnotation = true ;
206
- //persister handled in bind
207
- }
208
199
}
209
200
210
201
private void bindEjb3Annotation (Entity ejb3Ann ) {
@@ -257,13 +248,6 @@ public void bindEntity() {
257
248
if ( annotatedClass .isAnnotationPresent ( Immutable .class ) ) {
258
249
mutable = false ;
259
250
}
260
- else {
261
- org .hibernate .annotations .Entity entityAnn =
262
- annotatedClass .getAnnotation ( org .hibernate .annotations .Entity .class );
263
- if ( entityAnn != null ) {
264
- mutable = entityAnn .mutable ();
265
- }
266
- }
267
251
rootClass .setMutable ( mutable );
268
252
rootClass .setExplicitPolymorphism ( isExplicitPolymorphism ( polymorphismType ) );
269
253
if ( StringHelper .isNotEmpty ( where ) ) rootClass .setWhere ( where );
@@ -282,9 +266,6 @@ public void bindEntity() {
282
266
}
283
267
}
284
268
else {
285
- if (explicitHibernateEntityAnnotation ) {
286
- LOG .entityAnnotationOnNonRoot (annotatedClass .getName ());
287
- }
288
269
if (annotatedClass .isAnnotationPresent (Immutable .class )) {
289
270
LOG .immutableAnnotationOnNonRoot (annotatedClass .getName ());
290
271
}
@@ -299,14 +280,9 @@ public void bindEntity() {
299
280
persister = persisterAnn .impl ();
300
281
}
301
282
else {
302
- org .hibernate .annotations .Entity entityAnn = annotatedClass .getAnnotation ( org .hibernate .annotations .Entity .class );
303
- if ( entityAnn != null && !BinderHelper .isEmptyAnnotationValue ( entityAnn .persister () ) ) {
304
- try {
305
- persister = ReflectHelper .classForName ( entityAnn .persister () );
306
- }
307
- catch (ClassNotFoundException cnfe ) {
308
- throw new AnnotationException ( "Could not find persister class: " + persister );
309
- }
283
+ Persister perAnn = annotatedClass .getAnnotation ( Persister .class );
284
+ if ( perAnn != null ) {
285
+ persister = perAnn .impl ();
310
286
}
311
287
}
312
288
if ( persister != null ) {
0 commit comments