protected FrozenLazyInitializerImpl(HibernateProxy owner) { ProxyObject proxyObject = (ProxyObject) owner; MethodHandler handler = proxyObject.getHandler(); if (!(handler instanceof LazyInitializer)) { Arguments.mustBeInstanceOfValue( "((" + ProxyObject.class.getName() + ")owner).getHandler()", handler, LazyInitializer.class); } Class<?> persistentClass = getPersistentClass((BasicLazyInitializer) handler); LazyInitializer lazyInitializer = owner.getHibernateLazyInitializer(); if (lazyInitializer instanceof FrozenLazyInitializer) { throw new AssertionError(); } this.owner = owner; this.lazyInitializer = lazyInitializer; this.objectModelMetadata = HibernateMetadatas.of(persistentClass); this.initTransient(persistentClass); proxyObject.setHandler(this); }
@SuppressWarnings("unchecked") private void initTransient(Class<?> persistentClass) { LazyInitializer rawLazyInitializer = this.lazyInitializer; if (persistentClass == null) { persistentClass = getPersistentClass((BasicLazyInitializer) rawLazyInitializer); } HibernateObjectModelMetadata objectModelMetadata = HibernateMetadatas.of(persistentClass); this.objectModelMetadata = objectModelMetadata; this.omFactory = (ObjectModelFactory<ObjectModel>) ObjectModelFactoryFactory.factoryOf(objectModelMetadata.getObjectModelClass()); try { this.getIdentifierMethod = (Method) GET_IDENTIFIER_METHOD_FIELD.get(rawLazyInitializer); this.setIdentifierMethod = (Method) SET_IDENTIFIER_METHOD_FIELD.get(rawLazyInitializer); } catch (IllegalArgumentException | IllegalAccessException e) { throw new AssertionError(); } if (!rawLazyInitializer.isUninitialized()) { ObjectModel targetOM = this.omFactory.get(rawLazyInitializer.getImplementation()); ScalarListener listener = this.new TargetScalarListener(); targetOM.removeScalarListener(listener); targetOM.addScalarListener(listener); } }