Best code examples for Hibernate ORM LazyInitializer class (org.hibernate.proxy.LazyInitializer)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM LazyInitializer class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Hibernate ORM LazyInitializer examples from Open Source projects
This code example shows how to use the following methods: getEntityName, getImplementation, getPersistentClass, isUninitialized, getClass
        if (o instanceof HibernateProxy) {
            HibernateProxy proxy = (HibernateProxy)o;
            LazyInitializer initializer = proxy.getHibernateLazyInitializer();
             
            String className = (
            	initializer.isUninitialized() ?
            	initializer.getEntityName() :
            	initializer.getImplementation().getClass().getName()
            );  
             
            if (className != null && className.length() > 0) {
                try { 
                    return TypeUtil.forName(className);
                } catch (Exception e) {
                    log.warn(e, "Could not get class with initializer: %s for: %s", initializer.getClass().getName(), className);
                } 
            } 
            // fallback... 
            return initializer.getPersistentClass();
        } 

7
CodeRank
This code example shows how to use the following methods: getEntityName, getImplementation, getPersistentClass, isUninitialized, getClass
        if (o instanceof HibernateProxy) {
            HibernateProxy proxy = (HibernateProxy)o;
            LazyInitializer initializer = proxy.getHibernateLazyInitializer();
             
            String className = (
            	initializer.isUninitialized() ?
            	initializer.getEntityName() :
            	initializer.getImplementation().getClass().getName()
            );  
             
            if (className != null && className.length() > 0) {
                try { 
                    return TypeUtil.forName(className);
                } catch (Exception e) {
                    log.warn(e, "Could not get class with initializer: %s for: %s", initializer.getClass().getName(), className);
                } 
            } 
            // fallback... 
            return initializer.getPersistentClass();
        } 

7
CodeRank
This code example shows how to use the following methods: getImplementation
This code example shows how to use the following methods: getImplementation
	@Override 
	public Object unproxy(Object instance) { 
		if ( instance instanceof HibernateProxy ) {
			final HibernateProxy proxy = (HibernateProxy) instance;
			final LazyInitializer lazyInitializer = proxy.getHibernateLazyInitializer();
			Object initialized = lazyInitializer.getImplementation( hibernateSession );
			if ( initialized != null ) { 
				return initialized; 
			} 
			else { 
				// This is the case in which the proxy was created by a different session. 
				// unproxyAndReassociate is the ultimate bomb, 
				// able to deal with a Session change: 
				return hibernateSession.getPersistenceContext().unproxyAndReassociate( proxy );
			} 
		} 
		return instance; 
	} 
 
	@Override 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getIdentifier, isUninitialized
        assert rev1.getReference() instanceof HibernateProxy;
 
        HibernateProxy proxyCreateByEnvers = (HibernateProxy) rev1.getReference();
        LazyInitializer lazyInitializer = proxyCreateByEnvers.getHibernateLazyInitializer();
 
        assert lazyInitializer.isUninitialized();
        assert lazyInitializer.getIdentifier() != null;
        assert lazyInitializer.getIdentifier().equals(tnae1.getId());
        assert lazyInitializer.isUninitialized();
 
        assert rev1.getReference().getId().equals(uste1.getId());
        assert rev1.getReference().getStr().equals(uste1.getStr());
        assert !lazyInitializer.isUninitialized();
    } 
} 
Full Snippet Info
4
CodeRank
See Code Examples for Hibernate ORM LazyInitializer Methods: