play.db.jpa.HibernateInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
RePlay is a fork of the Play1 framework, created by Codeborne.
package play.db.jpa;
import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.type.Type;
import java.io.Serializable;
public class HibernateInterceptor extends EmptyInterceptor {
public HibernateInterceptor() {
}
@Override
public int[] findDirty(Object o, Serializable id, Object[] arg2, Object[] arg3, String[] arg4, Type[] arg5) {
if (o instanceof JPABase && !((JPABase) o).willBeSaved) {
return new int[0];
}
return null;
}
@Override
public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
if (collection instanceof PersistentCollection) {
Object o = ((PersistentCollection) collection).getOwner();
if (o instanceof JPABase) {
if (entities.get() != null) {
return;
} else {
return;
}
}
} else {
System.out.println("HOO: Case not handled !!!");
}
super.onCollectionUpdate(collection, key);
}
@Override
public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {
if (collection instanceof PersistentCollection) {
Object o = ((PersistentCollection) collection).getOwner();
if (o instanceof JPABase) {
if (entities.get() != null) {
return;
} else {
return;
}
}
} else {
System.out.println("HOO: Case not handled !!!");
}
super.onCollectionRecreate(collection, key);
}
@Override
public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
if (collection instanceof PersistentCollection) {
Object o = ((PersistentCollection) collection).getOwner();
if (o instanceof JPABase) {
if (entities.get() != null) {
return;
} else {
return;
}
}
} else {
System.out.println("HOO: Case not handled !!!");
}
super.onCollectionRemove(collection, key);
}
protected final ThreadLocal