Package org.hibernate.proxy

Examples of org.hibernate.proxy.HibernateProxy


        setIdentifierMethod,
        componentIdType,
        session
      );

    final HibernateProxy proxy;
    try {
      proxy = getProxyInstance(factory, instance);
    }
    catch (Exception e) {
      throw new HibernateException( "CGLIB Enhancement failed: " + persistentClass.getName(), e );
View Full Code Here


    return proxy;
  }

    private static HibernateProxy getProxyInstance(Class factory, CGLIBLazyInitializer instance) throws InstantiationException, IllegalAccessException {
    HibernateProxy proxy;
    try {
      Enhancer.registerCallbacks(factory, new Callback[]{ instance, null });
      proxy = (HibernateProxy)factory.newInstance();
    } finally {
      // HHH-2481 make sure the callback gets cleared, otherwise the instance stays in a static thread local.
View Full Code Here

      ProxyFactory factory = new ProxyFactory();
      factory.setSuperclass( interfaces.length == 1 ? persistentClass : null );
      factory.setInterfaces( interfaces );
      factory.setFilter( FINALIZE_FILTER );
      Class cl = factory.createClass();
      final HibernateProxy proxy = ( HibernateProxy ) cl.newInstance();
      ( ( ProxyObject ) proxy ).setHandler( instance );
      instance.constructed = true;
      return proxy;
    }
    catch ( Throwable t ) {
View Full Code Here

            setIdentifierMethod,
            componentIdType,
            session
    );

    final HibernateProxy proxy;
    try {
      proxy = ( HibernateProxy ) factory.newInstance();
    }
    catch ( Exception e ) {
      throw new HibernateException(
View Full Code Here

    if (obj == null) {
      return null;
    }

    if (obj instanceof HibernateProxy) {
      HibernateProxy hibernateProxy = (HibernateProxy) obj;
      return hibernateProxy.getHibernateLazyInitializer().getIdentifier();
    }


    return session.getEntityPersister(null, obj).getIdentifier(obj, session.getEntityMode());
  }
View Full Code Here

                        // of subclasses, this will be root class, no the actual class. So it can't be used here.
                        String toEntityName;
            Serializable id;

                        if (newValue instanceof HibernateProxy) {
                          HibernateProxy hibernateProxy = (HibernateProxy) newValue;
                          toEntityName = session.bestGuessEntityName(newValue);
                          id = hibernateProxy.getHibernateLazyInitializer().getIdentifier();
              // We've got to initialize the object from the proxy to later read its state.  
              newValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
                      } else {
                        toEntityName =  session.guessEntityName(newValue);

              IdMapper idMapper = verCfg.getEntCfg().get(toEntityName).getIdMapper();
                           id = (Serializable) idMapper.mapToIdFromEntity(newValue);
                      }

                        verSync.addWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, verCfg, id, newValue));
                    }

                    if (oldValue != null) {
                      String toEntityName;
            Serializable id;

                      if(oldValue instanceof HibernateProxy) {
                          HibernateProxy hibernateProxy = (HibernateProxy) oldValue;
                          toEntityName = session.bestGuessEntityName(oldValue);
                          id = hibernateProxy.getHibernateLazyInitializer().getIdentifier();
              // We've got to initialize the object as we'll read it's state anyway.
              oldValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
                      } else {
                        toEntityName =  session.guessEntityName(oldValue);
View Full Code Here

    if (obj == null) {
      return null;
    }

    if (obj instanceof HibernateProxy) {
      HibernateProxy hibernateProxy = (HibernateProxy) obj;
      return hibernateProxy.getHibernateLazyInitializer().getIdentifier();
    }

    return session.getEntityPersister(entityName, obj).getIdentifier(obj, session);
  }     
View Full Code Here

      ProxyFactory factory = new ProxyFactory();
      factory.setSuperclass( interfaces.length == 1 ? persistentClass : null );
      factory.setInterfaces( interfaces );
      factory.setFilter( FINALIZE_FILTER );
      Class cl = factory.createClass();
      final HibernateProxy proxy = ( HibernateProxy ) cl.newInstance();
      ( ( ProxyObject ) proxy ).setHandler( instance );
      instance.constructed = true;
      return proxy;
    }
    catch ( Throwable t ) {
View Full Code Here

            setIdentifierMethod,
            componentIdType,
            session
    );

    final HibernateProxy proxy;
    try {
      proxy = ( HibernateProxy ) factory.newInstance();
    }
    catch ( Exception e ) {
      throw new HibernateException(
View Full Code Here

          setIdentifierMethod,
          componentIdType,
          session
        );
     
      final HibernateProxy proxy;
      Class factory = getProxyFactory(persistentClass,  interfaces);
      proxy = getProxyInstance(factory, instance);
      instance.constructed = true;
      return proxy;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.proxy.HibernateProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.