-
Notifications
You must be signed in to change notification settings - Fork 155
/
MappedSuperclassAccessor.java
1911 lines (1700 loc) · 75.5 KB
/
MappedSuperclassAccessor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
// 05/16/2008-1.0M8 Guy Pelletier
// - 218084: Implement metadata merging functionality between mapping files
// 05/23/2008-1.0M8 Guy Pelletier
// - 211330: Add attributes-complete support to the EclipseLink-ORM.XML Schema
// 09/23/2008-1.1 Guy Pelletier
// - 241651: JPA 2.0 Access Type support
// 12/12/2008-1.1 Guy Pelletier
// - 249860: Implement table per class inheritance support.
// 01/28/2009-2.0 Guy Pelletier
// - 248293: JPA 2.0 Element Collections (part 1)
// 02/06/2009-2.0 Guy Pelletier
// - 248293: JPA 2.0 Element Collections (part 2)
// 03/27/2009-2.0 Guy Pelletier
// - 241413: JPA 2.0 Add EclipseLink support for Map type attributes
// 04/24/2009-2.0 Guy Pelletier
// - 270011: JPA 2.0 MappedById support
// 06/16/2009-2.0 Guy Pelletier
// - 277039: JPA 2.0 Cache Usage Settings
// 06/25/2009-2.0 Michael O'Brien
// - 266912: change MappedSuperclass handling in stage2 to pre process accessors
// in support of the custom descriptors holding mappings required by the Metamodel
// 09/24//2009-2.0 Michael O'Brien
// - 266912: In initIdClass() store IdClass names for use by the Metamodel API
// 10/21/2009-2.0 Guy Pelletier
// - 290567: mappedbyid support incomplete
// 12/2/2009-2.1 Guy Pelletier
// - 296289: Add current annotation metadata support on mapped superclasses to EclipseLink-ORM.XML Schema
// 01/19/2010-2.1 Guy Pelletier
// - 211322: Add fetch-group(s) support to the EclipseLink-ORM.XML Schema
// 05/04/2010-2.1 Guy Pelletier
// - 309373: Add parent class attribute to EclipseLink-ORM
// 06/01/2010-2.1 Guy Pelletier
// - 315195: Add new property to avoid reading XML during the canonical model generation
// 06/09/2010-2.0.3 Guy Pelletier
// - 313401: shared-cache-mode defaults to NONE when the element value is unrecognized
// 06/14/2010-2.2 Guy Pelletier
// - 264417: Table generation is incorrect for JoinTables in AssociationOverrides
// 06/22/2010-2.2 Guy Pelletier
// - 308729: Persistent Unit deployment exception when mappedsuperclass has no annotations but has lifecycle callbacks
// 07/05/2010-2.1.1 Guy Pelletier
// - 317708: Exception thrown when using LAZY fetch on VIRTUAL mapping
// 08/04/2010-2.1.1 Guy Pelletier
// - 315782: JPA2 derived identity metadata processing validation doesn't account for autoboxing
// 10/15/2010-2.2 Guy Pelletier
// - 322008: Improve usability of additional criteria applied to queries at the session/EM
// 10/28/2010-2.2 Guy Pelletier
// - 3223850: Primary key metadata issues
// 12/01/2010-2.2 Guy Pelletier
// - 331234: xml-mapping-metadata-complete overriden by metadata-complete specification
// 03/08/2011-2.3 Guy Pelletier
// - 337323: Multi-tenant with shared schema support
// 03/24/2011-2.3 Guy Pelletier
// - 337323: Multi-tenant with shared schema support (part 1)
// 03/24/2011-2.3 Guy Pelletier
// - 337323: Multi-tenant with shared schema support (part 8)
// 07/03/2011-2.3.1 Guy Pelletier
// - 348756: m_cascadeOnDelete boolean should be changed to Boolean
// 02/08/2012-2.4 Guy Pelletier
// - 350487: JPA 2.1 Specification defined support for Stored Procedure Calls
// 11/19/2012-2.5 Guy Pelletier
// - 389090: JPA 2.1 DDL Generation Support (foreign key metadata support)
// 11/29/2012-2.5 Guy Pelletier
// - 395406: Fix nightly static weave test errors
// 06/12/2017-2.7 Lukas Jungmann
// - 518155: [jpa22] add support for repeatable annotations
// 02/26/2018-2.7.2 Lukas Jungmann
// - 531528: IdentifiableType.hasSingleIdAttribute() returns true when IdClass references an inner class
package org.eclipse.persistence.internal.jpa.metadata.accessors.classes;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_ACCESS_FIELD;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_ACCESS_PROPERTY;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_CACHEABLE;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_ENTITY_LISTENERS;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_EXCLUDE_DEFAULT_LISTENERS;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_EXCLUDE_SUPERCLASS_LISTENERS;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_ID_CLASS;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_NAMED_NATIVE_QUERIES;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_NAMED_NATIVE_QUERY;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_NAMED_QUERIES;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_NAMED_QUERY;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_NAMED_STORED_PROCEDURE_QUERIES;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_NAMED_STORED_PROCEDURE_QUERY;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_SEQUENCE_GENERATOR;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_SEQUENCE_GENERATORS;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_SQL_RESULT_SET_MAPPING;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_SQL_RESULT_SET_MAPPINGS;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_TABLE_GENERATOR;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_TABLE_GENERATORS;
import static org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_TRANSIENT;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.persistence.annotations.AdditionalCriteria;
import org.eclipse.persistence.annotations.Cache;
import org.eclipse.persistence.annotations.CacheIndex;
import org.eclipse.persistence.annotations.CacheIndexes;
import org.eclipse.persistence.annotations.CacheInterceptor;
import org.eclipse.persistence.annotations.ExistenceChecking;
import org.eclipse.persistence.annotations.FetchGroup;
import org.eclipse.persistence.annotations.FetchGroups;
import org.eclipse.persistence.annotations.Multitenant;
import org.eclipse.persistence.annotations.NamedStoredFunctionQueries;
import org.eclipse.persistence.annotations.NamedStoredFunctionQuery;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.PrimaryKey;
import org.eclipse.persistence.annotations.QueryRedirectors;
import org.eclipse.persistence.annotations.ReadOnly;
import org.eclipse.persistence.annotations.SerializedObject;
import org.eclipse.persistence.annotations.UuidGenerator;
import org.eclipse.persistence.annotations.UuidGenerators;
import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
import org.eclipse.persistence.internal.jpa.metadata.MetadataProject;
import org.eclipse.persistence.internal.jpa.metadata.ORMetadata;
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation;
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataField;
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod;
import org.eclipse.persistence.internal.jpa.metadata.additionalcriteria.AdditionalCriteriaMetadata;
import org.eclipse.persistence.internal.jpa.metadata.cache.CacheIndexMetadata;
import org.eclipse.persistence.internal.jpa.metadata.cache.CacheInterceptorMetadata;
import org.eclipse.persistence.internal.jpa.metadata.cache.CacheMetadata;
import org.eclipse.persistence.internal.jpa.metadata.columns.PrimaryKeyMetadata;
import org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListenerMetadata;
import org.eclipse.persistence.internal.jpa.metadata.locking.OptimisticLockingMetadata;
import org.eclipse.persistence.internal.jpa.metadata.multitenant.MultitenantMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.FetchGroupMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.NamedNativeQueryMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.NamedPLSQLStoredFunctionQueryMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.NamedPLSQLStoredProcedureQueryMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.NamedStoredFunctionQueryMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.NamedStoredProcedureQueryMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.QueryRedirectorsMetadata;
import org.eclipse.persistence.internal.jpa.metadata.queries.SQLResultSetMappingMetadata;
import org.eclipse.persistence.internal.jpa.metadata.sequencing.SequenceGeneratorMetadata;
import org.eclipse.persistence.internal.jpa.metadata.sequencing.TableGeneratorMetadata;
import org.eclipse.persistence.internal.jpa.metadata.sequencing.UuidGeneratorMetadata;
import org.eclipse.persistence.internal.jpa.metadata.sop.SerializedObjectPolicyMetadata;
import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings;
import org.eclipse.persistence.platform.database.oracle.annotations.NamedPLSQLStoredFunctionQueries;
import org.eclipse.persistence.platform.database.oracle.annotations.NamedPLSQLStoredFunctionQuery;
import org.eclipse.persistence.platform.database.oracle.annotations.NamedPLSQLStoredProcedureQueries;
import org.eclipse.persistence.platform.database.oracle.annotations.NamedPLSQLStoredProcedureQuery;
import org.eclipse.persistence.queries.FetchGroupTracker;
/**
* INTERNAL:
* A mapped superclass accessor.
*
* When adding new metadata objects, be sure to include their initialization in
* initXMLObject. This sets the accessible object and the location of the
* ORMetadata which is used when merging. Also new member metadata variables
* need to be added to the merge method.
*
* Key notes:
* - any metadata mapped from XML to this class must be compared in the
* equals method.
* - any metadata mapped from XML to this class must be handled in the merge
* method. (merging is done at the accessor/mapping level)
* - any metadata mapped from XML to this class must be initialized in the
* initXMLObject method.
* - methods should be preserved in alphabetical order.
*
* @author Guy Pelletier
* @since TopLink EJB 3.0 Reference Implementation
*/
public class MappedSuperclassAccessor extends ClassAccessor {
private Boolean m_excludeDefaultListeners;
private Boolean m_excludeSuperclassListeners;
private AdditionalCriteriaMetadata m_additionalCriteria;
private Boolean m_cacheable;
private Boolean m_readOnly;
private CacheMetadata m_cache;
private CacheInterceptorMetadata m_cacheInterceptor;
private List<CacheIndexMetadata> m_cacheIndexes = new ArrayList<CacheIndexMetadata>();
private List<EntityListenerMetadata> m_entityListeners = new ArrayList<EntityListenerMetadata>();
private List<FetchGroupMetadata> m_fetchGroups = new ArrayList<FetchGroupMetadata>();
private List<NamedQueryMetadata> m_namedQueries = new ArrayList<NamedQueryMetadata>();
private List<NamedNativeQueryMetadata> m_namedNativeQueries = new ArrayList<NamedNativeQueryMetadata>();
private List<NamedStoredFunctionQueryMetadata> m_namedStoredFunctionQueries = new ArrayList<NamedStoredFunctionQueryMetadata>();
private List<NamedStoredProcedureQueryMetadata> m_namedStoredProcedureQueries = new ArrayList<NamedStoredProcedureQueryMetadata>();
private List<NamedPLSQLStoredFunctionQueryMetadata> m_namedPLSQLStoredFunctionQueries = new ArrayList<NamedPLSQLStoredFunctionQueryMetadata>();
private List<NamedPLSQLStoredProcedureQueryMetadata> m_namedPLSQLStoredProcedureQueries = new ArrayList<NamedPLSQLStoredProcedureQueryMetadata>();
private List<SQLResultSetMappingMetadata> m_sqlResultSetMappings = new ArrayList<SQLResultSetMappingMetadata>();
private MetadataClass m_idClass;
private MultitenantMetadata m_multitenant;
private OptimisticLockingMetadata m_optimisticLocking;
private PrimaryKeyMetadata m_primaryKey;
private QueryRedirectorsMetadata m_queryRedirectors;
private SequenceGeneratorMetadata m_sequenceGenerator;
private TableGeneratorMetadata m_tableGenerator;
private UuidGeneratorMetadata m_uuidGenerator;
private SerializedObjectPolicyMetadata m_serializedObjectPolicy;
private String m_existenceChecking;
private String m_idClassName;
private String m_prePersist;
private String m_postPersist;
private String m_preRemove;
private String m_postRemove;
private String m_preUpdate;
private String m_postUpdate;
private String m_postLoad;
/**
* INTERNAL:
* Used for OX mapping.
*/
public MappedSuperclassAccessor() {
super("<mapped-superclass>");
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public MappedSuperclassAccessor(String xmlElement) {
super(xmlElement);
}
/**
* INTERNAL:
*/
public MappedSuperclassAccessor(MetadataAnnotation annotation, MetadataClass cls, MetadataProject project) {
super(annotation, cls, project);
}
/**
* INTERNAL:
*/
public MappedSuperclassAccessor(MetadataAnnotation annotation, MetadataClass cls, MetadataDescriptor descriptor) {
super(annotation, cls, descriptor);
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public boolean excludeDefaultListeners() {
return m_excludeDefaultListeners != null && m_excludeDefaultListeners;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public boolean excludeSuperclassListeners() {
return m_excludeSuperclassListeners != null && m_excludeSuperclassListeners;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public AdditionalCriteriaMetadata getAdditionalCriteria() {
return m_additionalCriteria;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public CacheMetadata getCache() {
return m_cache;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<CacheIndexMetadata> getCacheIndexes() {
return m_cacheIndexes;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public Boolean getCacheable() {
return m_cacheable;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public CacheInterceptorMetadata getCacheInterceptor() {
return m_cacheInterceptor;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<EntityListenerMetadata> getEntityListeners() {
return m_entityListeners;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public Boolean getExcludeDefaultListeners() {
return m_excludeDefaultListeners;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public Boolean getExcludeSuperclassListeners() {
return m_excludeSuperclassListeners;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getExistenceChecking() {
return m_existenceChecking;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<FetchGroupMetadata> getFetchGroups() {
return m_fetchGroups;
}
/**
* INTERNAL:
*/
protected MetadataClass getIdClass() {
return m_idClass;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getIdClassName() {
return m_idClassName;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public MultitenantMetadata getMultitenant() {
return m_multitenant;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<NamedNativeQueryMetadata> getNamedNativeQueries() {
return m_namedNativeQueries;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<NamedPLSQLStoredFunctionQueryMetadata> getNamedPLSQLStoredFunctionQueries() {
return m_namedPLSQLStoredFunctionQueries;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<NamedPLSQLStoredProcedureQueryMetadata> getNamedPLSQLStoredProcedureQueries() {
return m_namedPLSQLStoredProcedureQueries;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<NamedQueryMetadata> getNamedQueries() {
return m_namedQueries;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<NamedStoredFunctionQueryMetadata> getNamedStoredFunctionQueries() {
return m_namedStoredFunctionQueries;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<NamedStoredProcedureQueryMetadata> getNamedStoredProcedureQueries() {
return m_namedStoredProcedureQueries;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public OptimisticLockingMetadata getOptimisticLocking() {
return m_optimisticLocking;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getPostLoad() {
return m_postLoad;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getPostPersist() {
return m_postPersist;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getPostRemove() {
return m_postRemove;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getPostUpdate() {
return m_postUpdate;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getPrePersist() {
return m_prePersist;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getPreRemove() {
return m_preRemove;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public String getPreUpdate() {
return m_preUpdate;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public PrimaryKeyMetadata getPrimaryKey() {
return m_primaryKey;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public QueryRedirectorsMetadata getQueryRedirectors() {
return m_queryRedirectors;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public Boolean getReadOnly() {
return m_readOnly;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public SequenceGeneratorMetadata getSequenceGenerator() {
return m_sequenceGenerator;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public List<SQLResultSetMappingMetadata> getSqlResultSetMappings() {
return m_sqlResultSetMappings;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public SerializedObjectPolicyMetadata getSerializedObjectPolicy() {
return m_serializedObjectPolicy;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public TableGeneratorMetadata getTableGenerator() {
return m_tableGenerator;
}
/**
* INTERNAL:
* Used for OX mapping.
*/
public UuidGeneratorMetadata getUuidGenerator() {
return m_uuidGenerator;
}
/**
* INTERNAL:
* Return true if any given field defines object relational persistence
* mapping annotations. This method is used when determining the access type
* of this accessor. Note: Through the annotation target, it is invalid to
* specify a lifecycle annotation on a field so we don't need to check as we
* do when checking the methods.
*
* @see processAccessType()
*/
protected boolean hasObjectRelationalFieldMappingAnnotationsDefined() {
Collection<MetadataField> fields = getJavaClass().getFields().values();
for (MetadataField field : fields) {
if (field.hasDeclaredAnnotations(this) && !field.isEclipseLinkWeavedField()) {
return true;
}
}
return false;
}
/**
* INTERNAL:
* Return true if any given method defines object relational persistence
* mapping annotations. This method is used when determining the access type
* of this accessor. Note: life cycle annotations are NOT object relational
* mappings therefore should not influence the decision.
*
* @see processAccessType()
*/
protected boolean hasObjectRelationalMethodMappingAnnotationsDefined() {
Collection<MetadataMethod> methods = getJavaClass().getMethods().values();
for (MetadataMethod method : methods) {
if (method.hasDeclaredAnnotations(this) && ! method.isALifeCycleCallbackMethod()) {
return true;
}
}
return false;
}
/**
* INTERNAL:
* This method is called in the pre-processing stage since we want to
* gather a list of id classes used throughout the persistence unit. This
* will help us build accessors, namely, mappedById accessors that can
* reference an id class type.
*/
protected void initIdClass() {
if (m_idClass == null || m_idClass.isClass(void.class)) {
// Check for an IdClass annotation.
if (isAnnotationPresent(JPA_ID_CLASS)) {
m_idClass = getMetadataClass(getAnnotation(JPA_ID_CLASS).getAttributeString("value"));
}
} else {
// We have an XML specification. Log a message if an annotation has also been defined.
if (isAnnotationPresent(JPA_ID_CLASS)) {
getLogger().logConfigMessage(MetadataLogger.OVERRIDE_ANNOTATION_WITH_XML, getAnnotation(JPA_ID_CLASS), getJavaClassName(), getLocation());
}
}
// Add the id class to the known list of id classes for this project.
if (m_idClass != null && ! m_idClass.isClass(void.class)) {
getProject().addIdClass(m_idClass.getName());
// 266912: We store the IdClass (not an EmbeddableId) for use by the Metamodel API
getProject().getProject().addMetamodelIdClassMapEntry(getAccessibleObject().getName(), m_idClass.getName().replace('$', '.'));
}
}
/**
* INTERNAL:
*/
@Override
public void initXMLObject(MetadataAccessibleObject accessibleObject, XMLEntityMappings entityMappings) {
super.initXMLObject(accessibleObject, entityMappings);
// Initialize single objects.
initXMLObject(m_additionalCriteria, accessibleObject);
initXMLObject(m_cache, accessibleObject);
initXMLObject(m_cacheInterceptor, accessibleObject);
initXMLObject(m_optimisticLocking, accessibleObject);
initXMLObject(m_primaryKey, accessibleObject);
initXMLObject(m_queryRedirectors, accessibleObject);
initXMLObject(m_sequenceGenerator, accessibleObject);
initXMLObject(m_serializedObjectPolicy, accessibleObject);
initXMLObject(m_tableGenerator, accessibleObject);
initXMLObject(m_uuidGenerator, accessibleObject);
initXMLObject(m_multitenant, accessibleObject);
// Initialize lists of objects.
initXMLObjects(m_entityListeners, accessibleObject);
initXMLObjects(m_fetchGroups, accessibleObject);
initXMLObjects(m_namedQueries, accessibleObject);
initXMLObjects(m_namedNativeQueries, accessibleObject);
initXMLObjects(m_namedStoredFunctionQueries, accessibleObject);
initXMLObjects(m_namedStoredProcedureQueries, accessibleObject);
initXMLObjects(m_namedPLSQLStoredFunctionQueries, accessibleObject);
initXMLObjects(m_namedPLSQLStoredProcedureQueries, accessibleObject);
initXMLObjects(m_sqlResultSetMappings, accessibleObject);
// Simple class object
m_idClass = initXMLClassName(m_idClassName);
}
/**
* INTERNAL:
* Return whether this accessor represents a MappedSuperclass
*/
@Override
public boolean isMappedSuperclass() {
return true;
}
/**
* INTERNAL:
* Mapped-superclass level merging details. Merging is only done on
* accessors from XML. Since entities and embeddables are initialized
* before merging, for any class name specifications we can not only merge
* the class names but must also merge the initialized classes since we
* do not re-initialize class accessors after a merge. Mapped superclasses
* are not initialized till they are reloaded therefore merging only the
* class names is needed, however merging their respective MetadataClasses
* will do nothing since merging null with null yields null.
*/
@Override
public void merge(ORMetadata metadata) {
super.merge(metadata);
MappedSuperclassAccessor accessor = (MappedSuperclassAccessor) metadata;
// Simple object merging.
m_excludeDefaultListeners = (Boolean) mergeSimpleObjects(m_excludeDefaultListeners, accessor.excludeDefaultListeners(), accessor, "<exclude-default-listeners>");
m_excludeSuperclassListeners = (Boolean) mergeSimpleObjects(m_excludeSuperclassListeners, accessor.excludeSuperclassListeners(), accessor, "<exclude-superclass-listeners>");
m_cacheable = (Boolean) mergeSimpleObjects(m_cacheable, accessor.getCacheable(), accessor, "@cacheable");
m_readOnly = (Boolean) mergeSimpleObjects(m_readOnly, accessor.getReadOnly(), accessor, "@read-only");
m_idClass = (MetadataClass) mergeSimpleObjects(m_idClass, accessor.getIdClass(), accessor, "<id-class>");
m_idClassName = (String) mergeSimpleObjects(m_idClassName, accessor.getIdClassName(), accessor, "<id-class>");
m_prePersist = (String) mergeSimpleObjects(m_prePersist, accessor.getPrePersist(), accessor, "<pre-persist>");
m_postPersist = (String) mergeSimpleObjects(m_postPersist, accessor.getPostPersist(), accessor, "<post-persist>");
m_preRemove = (String) mergeSimpleObjects(m_preRemove, accessor.getPreRemove(), accessor, "<pre-remove>");
m_postRemove = (String) mergeSimpleObjects(m_postRemove, accessor.getPostRemove(), accessor, "<post-remove>");
m_preUpdate = (String) mergeSimpleObjects(m_preUpdate, accessor.getPreUpdate(), accessor, "<pre-update>");
m_postUpdate = (String) mergeSimpleObjects(m_postUpdate, accessor.getPostUpdate(), accessor, "<post-update>");
m_postLoad = (String) mergeSimpleObjects(m_postLoad, accessor.getPostLoad(), accessor, "<post-load>");
m_existenceChecking = (String) mergeSimpleObjects(m_existenceChecking, accessor.getExistenceChecking(), accessor, "@existence-checking");
// ORMetadata object merging.
m_additionalCriteria = (AdditionalCriteriaMetadata) mergeORObjects(m_additionalCriteria, accessor.getAdditionalCriteria());
m_cache = (CacheMetadata) mergeORObjects(m_cache, accessor.getCache());
m_cacheInterceptor = (CacheInterceptorMetadata) mergeORObjects(m_cacheInterceptor, accessor.getCacheInterceptor());
m_optimisticLocking = (OptimisticLockingMetadata) mergeORObjects(m_optimisticLocking, accessor.getOptimisticLocking());
m_primaryKey = (PrimaryKeyMetadata) mergeORObjects(m_primaryKey, accessor.getPrimaryKey());
m_queryRedirectors = (QueryRedirectorsMetadata) mergeORObjects(m_queryRedirectors, accessor.getQueryRedirectors());
m_sequenceGenerator = (SequenceGeneratorMetadata) mergeORObjects(m_sequenceGenerator, accessor.getSequenceGenerator());
m_serializedObjectPolicy = (SerializedObjectPolicyMetadata) mergeORObjects(m_serializedObjectPolicy, accessor.getSerializedObjectPolicy());
m_tableGenerator = (TableGeneratorMetadata) mergeORObjects(m_tableGenerator, accessor.getTableGenerator());
m_uuidGenerator = (UuidGeneratorMetadata) mergeORObjects(m_uuidGenerator, accessor.getUuidGenerator());
m_multitenant = (MultitenantMetadata) mergeORObjects(m_multitenant, accessor.getMultitenant());
// ORMetadata list merging.
m_entityListeners = mergeORObjectLists(m_entityListeners, accessor.getEntityListeners());
m_fetchGroups = mergeORObjectLists(m_fetchGroups, accessor.getFetchGroups());
m_namedQueries = mergeORObjectLists(m_namedQueries, accessor.getNamedQueries());
m_namedNativeQueries = mergeORObjectLists(m_namedNativeQueries, accessor.getNamedNativeQueries());
m_namedStoredFunctionQueries = mergeORObjectLists(m_namedStoredFunctionQueries, accessor.getNamedStoredFunctionQueries());
m_namedStoredProcedureQueries = mergeORObjectLists(m_namedStoredProcedureQueries, accessor.getNamedStoredProcedureQueries());
m_namedPLSQLStoredFunctionQueries = mergeORObjectLists(m_namedPLSQLStoredFunctionQueries, accessor.getNamedPLSQLStoredFunctionQueries());
m_namedPLSQLStoredProcedureQueries = mergeORObjectLists(m_namedPLSQLStoredProcedureQueries, accessor.getNamedPLSQLStoredProcedureQueries());
m_sqlResultSetMappings = mergeORObjectLists(m_sqlResultSetMappings, accessor.getSqlResultSetMappings());
}
/**
* INTERNAL:
* The pre-process method is called during regular deployment and metadata
* processing.
*
* This method will pre-process the items of interest on this mapped
* superclass for each entity class that inherits from it. The order of
* processing is important, care must be taken if changes must be made.
*/
@Override
public void preProcess() {
// Add any id class definition to the project.
initIdClass();
// Set a cacheable flag if specified on the entity's descriptor.
processCacheable();
// Process our parents metadata after processing our own.
super.preProcess();
}
/**
* INTERNAL:
* Process the items of interest on a mapped superclass.
*/
@Override
public void process() {
// Process the fetch group metadata.
processFetchGroups();
// Process the named query metadata.
processNamedQueries();
// Process the named native query metadata.
processNamedNativeQueries();
// Process the named stored procedure query metadata
processNamedStoredProcedureQueries();
// Process the named stored function query metadata
processNamedStoredFunctionQueries();
// Process the named PLSQL stored procedure query metadata
processNamedPLSQLStoredProcedureQueries();
// Process the named PLSQL stored function query metadata
processNamedPLSQLStoredFunctionQueries();
// Process the sql result set mapping metadata
processSqlResultSetMappings();
// Process the table generator metadata.
processTableGenerator();
// Process the uuid generator metadata.
processUuidGenerator();
// Process the sequence generator metadata.
processSequenceGenerator();
// Process serialized object policy metadata
processSerializedObjectPolicy();
// Process the id class metadata.
processIdClass();
// Process the primary key metadata.
processPrimaryKey();
// Process the exclude default listeners metadata.
processExcludeDefaultListeners();
// Process the exclude superclass listeners metadata.
processExcludeSuperclassListeners();
// Process the optimistic locking policy metadata.
processOptimisticLocking();
// Process any cache metadata (Cache and CacheInterceptor) taking the
// cacheable and persistence unit global setting into consideration.
processCaching();
// Process the Default Redirectors
processDefaultRedirectors();
// Process the read only metadata.
processReadOnly();
// Process the existence checking metadata.
processExistenceChecking();
// Process the additional criteria metadata.
processAdditionalCriteria();
// Process the multitenant metadata
processMultitenant();
// Process our parents metadata after processing our own.
super.process();
}
/**
* INTERNAL:
* Process the additional criteria metadata specified on an entity or
* mapped superclass. Once the additional criteria are processed from
* XML process the additional criteria from annotations. This order of
* processing must be maintained.
*/
protected void processAdditionalCriteria() {
if (m_additionalCriteria != null || isAnnotationPresent(AdditionalCriteria.class)) {
// We have additional criteria available. If the descriptor already
// has additional criteria, then we are processing a mapped
// superclass and should ignore the additional criteria for this
// descriptor.
if (getDescriptor().hasAdditionalCriteria()) {
// Ignore additional criteria on mapped superclass if additional
// criteria is already defined on the entity.
getLogger().logConfigMessage(MetadataLogger.IGNORE_MAPPED_SUPERCLASS_ADDITIONAL_CRITERIA, getDescriptor().getJavaClass(), getJavaClass());
} else if (m_additionalCriteria != null) {
// Process the additional criteria that was specified in XML.
m_additionalCriteria.process(getDescriptor());
} else {
// Process the additional criteria from the annotation.
new AdditionalCriteriaMetadata(getAnnotation(AdditionalCriteria.class), this).process(getDescriptor());
}
}
}
/**
* INTERNAL:
* Process the accessType for a MappedSuperclass.
* This function is referenced by MetadataProject.addMetamodelMappedSuperclass().
* The overridden function on the subclass must be used in all other cases.
* @since EclipseLink 1.2 for the JPA 2.0 Reference Implementation
*/
@Override
public void processAccessType() {
// 266912: Note: this function is a port of the subclass protected EntityAccessor.processAccessType() minus step 1 and 2
String explicitAccessType = getAccess();
String defaultAccessType = null;
// 1 - If there are no mapped superclasses or no mapped superclasses
// without an explicit access type. Check where the annotations are
// defined on this entity class.
if (hasObjectRelationalFieldMappingAnnotationsDefined()) {
defaultAccessType = JPA_ACCESS_FIELD;
} else if (hasObjectRelationalMethodMappingAnnotationsDefined()) {
defaultAccessType = JPA_ACCESS_PROPERTY;
} else {
// 2 - If there are no annotations defined on either the
// fields or properties, check for an xml default from
// persistence-unit-metadata-defaults or entity-mappings.
if (getDescriptor().getDefaultAccess() != null) {
defaultAccessType = getDescriptor().getDefaultAccess();
} else {
// 3 - We've exhausted our search, set the access type to FIELD.
defaultAccessType = JPA_ACCESS_FIELD;
}
}
// Finally set the default access type on the descriptor and log a
// message to the user if we are defaulting the access type for this
// entity to use that default.
getDescriptor().setDefaultAccess(defaultAccessType);
if (explicitAccessType == null) {
getLogger().logConfigMessage(MetadataLogger.ACCESS_TYPE, defaultAccessType, getJavaClass());
}
// This access type setting on the class descriptor will be used to
// weave the class properly.
getDescriptor().setAccessTypeOnClassDescriptor(getAccessType());
}
/**
* INTERNAL:
* Process a cache metadata.
*/
protected void processCache() {
if (m_cache != null || isAnnotationPresent(Cache.class)) {
if (getDescriptor().isInheritanceSubclass()) {
// Ignore cache if specified on an inheritance subclass.
getLogger().logWarningMessage(MetadataLogger.IGNORE_INHERITANCE_SUBCLASS_CACHE, getJavaClass());
} else if (getDescriptor().hasCache()) {
// Ignore cache on mapped superclass if cache is already
// defined on the entity.
getLogger().logConfigMessage(MetadataLogger.IGNORE_MAPPED_SUPERCLASS_CACHE, getDescriptor().getJavaClass(), getJavaClass());
} else {
if (m_cache == null) {
new CacheMetadata(getAnnotation(Cache.class), this).process(getDescriptor(), getJavaClass());
} else {
m_cache.process(getDescriptor(), getJavaClass());
}
}
}
}
/**
* INTERNAL:
* Called in pre-process. It is called from an entity accessor and in
* turn is called on the mapped-superclasses of that entity.
*/
protected void processCacheable() {
if (m_cacheable != null || isAnnotationPresent(JPA_CACHEABLE)) {
if (getDescriptor().hasCacheable()) {
// Ignore cacheable on mapped superclass if cacheable is already
// defined on the entity.
getLogger().logConfigMessage(MetadataLogger.IGNORE_MAPPED_SUPERCLASS_CACHE, getDescriptor().getJavaClass(), getJavaClass());
} else {
// Set the cacheable setting on the descriptor.
if (m_cacheable == null) {
m_cacheable = getAnnotation(JPA_CACHEABLE).getAttributeBooleanDefaultTrue("value");
}
getDescriptor().setCacheable(m_cacheable);
}
}
}
/**
* INTERNAL:
* Process a cache interceptor metadata.
*/
protected void processCacheInterceptor() {
if (m_cacheInterceptor != null || isAnnotationPresent(CacheInterceptor.class)) {
if (getDescriptor().isInheritanceSubclass()) {
// Ignore cache interceptor if specified on an inheritance subclass.
getLogger().logWarningMessage(MetadataLogger.IGNORE_INHERITANCE_SUBCLASS_CACHE_INTERCEPTOR, getJavaClass());
} else if (getDescriptor().hasCacheInterceptor()) {
// Ignore cache interceptor on mapped superclass if cache
// interceptor is already defined on the entity.
getLogger().logConfigMessage(MetadataLogger.IGNORE_MAPPED_SUPERCLASS_CACHE_INTERCEPTOR, getDescriptor().getJavaClass(), getJavaClass());
} else {
if (m_cacheInterceptor == null) {
new CacheInterceptorMetadata(getAnnotation(CacheInterceptor.class), this).process(getDescriptor(), getJavaClass());
} else {
m_cacheInterceptor.process(getDescriptor(), getJavaClass());
}
}
}
}
/**
* INTERNAL:
* Process a caching metadata. This method will be called on an entity's
* mapped superclasses (bottom --> up). We go through the mapped
* superclasses to not only apply a cache setting but log ignore messages.
*/
protected void processCaching() {
// The settings for processing cache metadata are as follows:
// ALL or no setting
// ENABLE_SELECTIVE and Cacheable(true)
// DISABLE_SELECTIVE and Cacheable(true)
if (getProject().isSharedCacheModeAll() ||
getProject().isSharedCacheModeEnableSelective()||
getProject().isSharedCacheModeDisableSelective()) {
processCachingMetadata();
}
}
/**
* INTERNAL:
* Process a caching metadata. These are the items we process to configure
* the entity's cache settings.
*/
protected void processCachingMetadata() {
processCache();
processCacheInterceptor();
processCacheIndexes();
}
/**