/** * {@inheritDoc} */ @Override public void write(Kryo kryo, Output output, Object object) { delegateSerializer.write(kryo, output, hibernateUtil.getUnproxiedObject(object)); }
/** * {@inheritDoc} */ @Override @SuppressWarnings("rawtypes") public void write(Kryo kryo, Output output, Collection collection) { if (null != hibernateUtil) { if (hibernateUtil.isPersistentCollection(collection.getClass()) && !hibernateUtil.isInitialized(collection)) { // if Hibernate collection is not initialized just write the empty collection int length = 0; output.writeInt(length, true); return; } } super.write(kryo, output, collection); }
/** * {@inheritDoc} */ @SuppressWarnings("rawtypes") @Override public void write(Kryo kryo, Output output, Map map) { if (null != hibernateUtil) { if (hibernateUtil.isPersistentMap(map.getClass()) && !hibernateUtil.isInitialized(map)) { // if Hibernate map is not initialized just write the empty map int length = 0; output.writeInt(length, true); return; } } super.write(kryo, output, map); } }
/** * {@inheritDoc} */ @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public Registration writeClass(Output output, Class type) { Class<?> writeType = type; if (null != type) { if (hibernateUtil.isPersistentList(type)) { writeType = ArrayList.class; // NOPMD } else if (hibernateUtil.isPersistentSet(type)) { writeType = HashSet.class; // NOPMD } else if (hibernateUtil.isPersistentMap(type)) { writeType = HashMap.class; // NOPMD } else if (hibernateUtil.isProxy(writeType)) { writeType = writeType.getSuperclass(); Registration registration = super.writeClass(output, writeType); Registration returnRegistration = hibernateProxiesRegistrations.get(writeType); if (null == returnRegistration) { returnRegistration = new Registration(registration.getType(), new HibernateProxySerializer(hibernateUtil, registration.getSerializer()), registration.getId()); hibernateProxiesRegistrations.put(writeType, returnRegistration); } return returnRegistration; } } return super.writeClass(output, writeType); } }