Search in sources :

Example 1 with JavassistProxyFactory

use of org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory in project mybatis-3 by mybatis.

the class JavassistProxyTest method shouldSerizalizeADeserlizaliedProxy.

@Test
public void shouldSerizalizeADeserlizaliedProxy() throws Exception {
    Object proxy = ((JavassistProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<String, ResultLoaderMap.LoadPair>(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
    Author author2 = (Author) deserialize(serialize((Serializable) proxy));
    assertEquals(author, author2);
    assertFalse(author.getClass().equals(author2.getClass()));
}
Also used : JavassistProxyFactory(org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) Author(org.apache.ibatis.domain.blog.Author) Test(org.junit.Test)

Example 2 with JavassistProxyFactory

use of org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory in project mybatis-3 by mybatis.

the class LazyPropertiesTest method shouldInvokingSetterNotTriggerLazyLoading_Javassist.

@Test
public void shouldInvokingSetterNotTriggerLazyLoading_Javassist() {
    Configuration config = sqlSessionFactory.getConfiguration();
    config.setProxyFactory(new JavassistProxyFactory());
    config.setAggressiveLazyLoading(false);
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        Mapper mapper = sqlSession.getMapper(Mapper.class);
        User user = mapper.getUser(1);
        user.setLazy1(new User());
        assertNotNull(user.getLazy1().getId());
    } finally {
        sqlSession.close();
    }
}
Also used : JavassistProxyFactory(org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory) Configuration(org.apache.ibatis.session.Configuration) SqlSession(org.apache.ibatis.session.SqlSession) Test(org.junit.Test)

Aggregations

JavassistProxyFactory (org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory)2 Test (org.junit.Test)2 Author (org.apache.ibatis.domain.blog.Author)1 DefaultObjectFactory (org.apache.ibatis.reflection.factory.DefaultObjectFactory)1 Configuration (org.apache.ibatis.session.Configuration)1 SqlSession (org.apache.ibatis.session.SqlSession)1