@@ -178,13 +178,13 @@ private static Element dereference(AccessType defaultAccessType, Element symbol,
178178 }
179179 }
180180
181- static Type propertyType (Element member , String entityName , String path , AccessType defaultAccessType ) {
181+ private Type propertyType (Element member , String entityName , String path , AccessType defaultAccessType ) {
182182 final TypeMirror memberType = memberType (member );
183183 if (isEmbeddedProperty (member )) {
184- return component .make (asElement (memberType ), entityName , path , defaultAccessType );
184+ return component .make (asElement (memberType ), entityName , path , defaultAccessType , this );
185185 }
186186 else if (isToOneAssociation (member )) {
187- return new ManyToOneType (typeConfiguration , getToOneTargetEntity (member ));
187+ return new ManyToOneType (getTypeConfiguration () , getToOneTargetEntity (member ));
188188 }
189189 else if (isToManyAssociation (member )) {
190190 return collectionType (memberType , qualify (entityName , path ));
@@ -193,10 +193,10 @@ else if (isElementCollectionProperty(member)) {
193193 return collectionType (memberType , qualify (entityName , path ));
194194 }
195195 else if (isEnumProperty (member )) {
196- return enumType ( member , memberType );
196+ return enumType (member , memberType );
197197 }
198198 else {
199- return typeConfiguration .getBasicTypeRegistry ()
199+ return getTypeConfiguration () .getBasicTypeRegistry ()
200200 .getRegisteredType (qualifiedName (memberType ));
201201 }
202202 }
@@ -255,12 +255,13 @@ Set<String> getEnumTypesForValue(String value) {
255255
256256 private static Type elementCollectionElementType (TypeElement elementType ,
257257 String role , String path ,
258- AccessType defaultAccessType ) {
258+ AccessType defaultAccessType ,
259+ MockSessionFactory factory ) {
259260 if (isEmbeddableType (elementType )) {
260- return component .make (elementType , role , path , defaultAccessType );
261+ return component .make (elementType , role , path , defaultAccessType , factory );
261262 }
262263 else {
263- return typeConfiguration .getBasicTypeRegistry ()
264+ return factory . getTypeConfiguration () .getBasicTypeRegistry ()
264265 .getRegisteredType (qualifiedName (elementType .asType ()));
265266 }
266267 }
@@ -277,7 +278,8 @@ public static abstract class Component implements CompositeType {
277278
278279 public Component (TypeElement type ,
279280 String entityName , String path ,
280- AccessType defaultAccessType ) {
281+ AccessType defaultAccessType ,
282+ ProcessorSessionFactory factory ) {
281283 this .type = type ;
282284
283285 List <String > names = new ArrayList <>();
@@ -290,7 +292,7 @@ public Component(TypeElement type,
290292 if (isPersistable (member , accessType )) {
291293 String name = propertyName (member );
292294 Type propertyType =
293- propertyType (member , entityName ,
295+ factory . propertyType (member , entityName ,
294296 qualify (path , name ), defaultAccessType );
295297 if (propertyType != null ) {
296298 names .add (name );
@@ -358,11 +360,13 @@ public int getColumnSpan(MappingContext mapping) {
358360 public static abstract class EntityPersister extends MockEntityPersister {
359361 private final TypeElement type ;
360362 private final Types typeUtil ;
363+ private final ProcessorSessionFactory factory ;
361364
362- public EntityPersister (String entityName , TypeElement type , ProcessorSessionFactory that ) {
363- super (entityName , getDefaultAccessType (type ), that );
365+ public EntityPersister (String entityName , TypeElement type , ProcessorSessionFactory factory ) {
366+ super (entityName , getDefaultAccessType (type ), factory );
364367 this .type = type ;
365- this .typeUtil = that .typeUtil ;
368+ this .typeUtil = factory .typeUtil ;
369+ this .factory = factory ;
366370 initSubclassPersisters ();
367371 }
368372
@@ -397,7 +401,7 @@ boolean isSubclassPersister(MockEntityPersister entityPersister) {
397401 Type createPropertyType (String propertyPath ) {
398402 Element symbol = findPropertyByPath (type , propertyPath , defaultAccessType );
399403 return symbol == null ? null :
400- propertyType (symbol , getEntityName (), propertyPath , defaultAccessType );
404+ factory . propertyType (symbol , getEntityName (), propertyPath , defaultAccessType );
401405 }
402406
403407 @ Override
@@ -414,7 +418,7 @@ public String identifierPropertyName() {
414418 public Type identifierType () {
415419 for (Element element : type .getEnclosedElements ()) {
416420 if ( hasAnnotation (element , "Id" )|| hasAnnotation (element , "EmbeddedId" ) ) {
417- return propertyType (element , getEntityName (), EntityIdentifierMapping .ID_ROLE_NAME , defaultAccessType );
421+ return factory . propertyType (element , getEntityName (), EntityIdentifierMapping .ID_ROLE_NAME , defaultAccessType );
418422 }
419423 }
420424 return null ;
@@ -424,7 +428,7 @@ public Type identifierType() {
424428 public BasicType <?> versionType () {
425429 for (Element element : type .getEnclosedElements ()) {
426430 if ( hasAnnotation (element , "Version" ) ) {
427- return (BasicType <?>) propertyType (element , getEntityName (), "{version}" , defaultAccessType );
431+ return (BasicType <?>) factory . propertyType (element , getEntityName (), "{version}" , defaultAccessType );
428432 }
429433 }
430434 return null ;
@@ -434,7 +438,7 @@ public BasicType<?> versionType() {
434438 public abstract static class ToManyAssociationPersister extends MockCollectionPersister {
435439 public ToManyAssociationPersister (String role , CollectionType collectionType , String targetEntityName , ProcessorSessionFactory that ) {
436440 super (role , collectionType ,
437- new ManyToOneType (typeConfiguration , targetEntityName ),
441+ new ManyToOneType (that . getTypeConfiguration () , targetEntityName ),
438442 that );
439443 }
440444
@@ -447,26 +451,29 @@ Type getElementPropertyType(String propertyPath) {
447451 public abstract static class ElementCollectionPersister extends MockCollectionPersister {
448452 private final TypeElement elementType ;
449453 private final AccessType defaultAccessType ;
454+ private final ProcessorSessionFactory factory ;
450455
451456 public ElementCollectionPersister (String role ,
452457 CollectionType collectionType ,
453458 TypeElement elementType ,
454459 String propertyPath ,
455460 AccessType defaultAccessType ,
456- ProcessorSessionFactory that ) {
461+ ProcessorSessionFactory factory ) {
457462 super (role , collectionType ,
458463 elementCollectionElementType (elementType , role ,
459- propertyPath , defaultAccessType ),
460- that );
464+ propertyPath , defaultAccessType ,
465+ factory ),
466+ factory );
461467 this .elementType = elementType ;
462468 this .defaultAccessType = defaultAccessType ;
469+ this .factory = factory ;
463470 }
464471
465472 @ Override
466473 Type getElementPropertyType (String propertyPath ) {
467474 Element symbol = findPropertyByPath (elementType , propertyPath , defaultAccessType );
468475 return symbol == null ? null :
469- propertyType (symbol , getOwnerEntityName (), propertyPath , defaultAccessType );
476+ factory . propertyType (symbol , getOwnerEntityName (), propertyPath , defaultAccessType );
470477 }
471478 }
472479
0 commit comments