@Test public void isLazyInitializedTrue() { final PersistentBag bag = new PersistentBag() { private static final long serialVersionUID = 1L; { setInitialized(); } }; Assert.assertTrue(super.isLazyInitialized(bag)); }
@SuppressWarnings("rawtypes") @Override public Serializer getSerializer(Class cl) throws HessianProtocolException{ if (PersistentMap.class.isAssignableFrom(cl) || PersistentBag.class.isAssignableFrom(cl)) { return serializer ; } return super.getSerializer(cl); }
@Override public void postBootHook(AbstractApplicationContext ctx) { if(ctx.containsBean("xstream")){ XStream xStream = (XStream)ctx.getBean("xstream"); xStream.registerConverter(new HibernateProxyConverter()); xStream.registerConverter(new HibernatePersistentCollectionConverter(xStream.getMapper())); xStream.alias("list", PersistentList.class); xStream.alias("list", PersistentBag.class); xStream.alias("set", PersistentSet.class); } }
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) throws HibernateException { return new PersistentBag(session); }
public PersistentCollection wrap(SessionImplementor session, Object collection) { return new PersistentBag( session, (Collection) collection ); }
public boolean canConvert(Class type) { return type == PersistentBag.class; }
public boolean canConvert(Class clazz) { return !ClassUtils.isSystemType(clazz) && clazz != PersistentBag.class; }
@Test public void isLazyInitializedFalse() { Assert.assertFalse(super.isLazyInitialized(new PersistentBag())); }
public boolean canConvert(final Class type) { return type == PersistentBag.class || type == PersistentList.class || type == PersistentSet.class; }
/** * Test a collection is a {@link PersistentBag} and is initialized. * * @param bag * the JPA bag to test. * @return <code>true</code> if the given collection is a {@link PersistentBag} and is initialized. */ protected boolean isLazyInitialized(final Collection<?> bag) { return bag instanceof PersistentBag && ((PersistentBag) bag).wasInitialized(); }