
org.jtransfo.hibernate.HibernateObjectReplacer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtransfo-hibernate Show documentation
Show all versions of jtransfo-hibernate Show documentation
jTransfo Hibernate specific module
/*
* This file is part of jTransfo, a library for converting to and from transfer objects.
* Copyright (c) PROGS bvba, Belgium
*
* The program is available in open source according to the Apache License, Version 2.0.
* For full licensing details, see LICENSE.txt in the project root.
*/
package org.jtransfo.hibernate;
import org.hibernate.proxy.HibernateProxy;
import org.jtransfo.ObjectReplacer;
/**
* ObjectClassDeterminator which recognizes Hibernate proxies.
*
* This allows jTransfo to properly recognize Hibernate proxies without forcing the object to be initialised.
*/
public class HibernateObjectReplacer implements ObjectReplacer {
/**
* Convert an object to something jTransfo should convert.
*
* If the object is not replaced, the object itself should be returned.
*
*
* @param object object which may need to be replaced
* @return replacement object or the object itself
*/
@Override
public Object replaceObject(Object object) {
if (object instanceof HibernateProxy) {
return ((HibernateProxy) object).getHibernateLazyInitializer().getImplementation();
}
return object;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy