Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch back to standard play save() behaviour
- Loading branch information
Showing
6 changed files
with
92 additions
and
92 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
---- | ||
Download Hibernate 4.2.19.Final source code, apply the patch, and build with gradle (tip use export GRADLE_OPTS=-Xmx1G -XX:MaxPermSize=512m) | ||
---- | ||
|
||
DRY RUN -> patch --dry-run -p1 -i hibernate-4.2.19-patch-play.patch | ||
APPLY -> patch -p1 -i hibernate-4.2.19-patch-play.patch |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,85 @@ | ||
//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() { | ||
// | ||
// } | ||
// 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; | ||
// } | ||
// | ||
// public boolean 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 ((JPABase) o).willBeSaved || ((JPABase) entities.get()).willBeSaved; | ||
// } else { | ||
// return ((JPABase) o).willBeSaved; | ||
// } | ||
// } | ||
// } else { | ||
// System.out.println("HOO: Case not handled !!!"); | ||
// } | ||
// return super.onCollectionUpdate(collection, key); | ||
//} | ||
// | ||
//public boolean 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 ((JPABase) o).willBeSaved || ((JPABase) entities.get()).willBeSaved; | ||
// } else { | ||
// return ((JPABase) o).willBeSaved; | ||
// } | ||
// } | ||
// } else { | ||
// System.out.println("HOO: Case not handled !!!"); | ||
// } | ||
// | ||
// return super.onCollectionRecreate(collection, key); | ||
//} | ||
// | ||
//public boolean 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 ((JPABase) o).willBeSaved || ((JPABase) entities.get()).willBeSaved; | ||
// } else { | ||
// return ((JPABase) o).willBeSaved; | ||
// } | ||
// } | ||
//} else { | ||
// System.out.println("HOO: Case not handled !!!"); | ||
//} | ||
//return super.onCollectionRemove(collection, key); | ||
//} | ||
// | ||
//protected ThreadLocal<Object> entities = new ThreadLocal<Object>(); | ||
// | ||
//@Override | ||
//public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { | ||
// entities.set(entity); | ||
// return super.onSave(entity, id, state, propertyNames, types); | ||
//} | ||
// | ||
//@Override | ||
//public void afterTransactionCompletion(org.hibernate.Transaction tx) { | ||
// entities.remove(); | ||
//} | ||
// | ||
//} | ||
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() { | ||
|
||
} | ||
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; | ||
} | ||
|
||
public boolean 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 ((JPABase) o).willBeSaved || ((JPABase) entities.get()).willBeSaved; | ||
} else { | ||
return ((JPABase) o).willBeSaved; | ||
} | ||
} | ||
} else { | ||
System.out.println("HOO: Case not handled !!!"); | ||
} | ||
return super.onCollectionUpdate(collection, key); | ||
} | ||
|
||
public boolean 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 ((JPABase) o).willBeSaved || ((JPABase) entities.get()).willBeSaved; | ||
} else { | ||
return ((JPABase) o).willBeSaved; | ||
} | ||
} | ||
} else { | ||
System.out.println("HOO: Case not handled !!!"); | ||
} | ||
|
||
return super.onCollectionRecreate(collection, key); | ||
} | ||
|
||
public boolean 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 ((JPABase) o).willBeSaved || ((JPABase) entities.get()).willBeSaved; | ||
} else { | ||
return ((JPABase) o).willBeSaved; | ||
} | ||
} | ||
} else { | ||
System.out.println("HOO: Case not handled !!!"); | ||
} | ||
return super.onCollectionRemove(collection, key); | ||
} | ||
|
||
protected ThreadLocal<Object> entities = new ThreadLocal<Object>(); | ||
|
||
@Override | ||
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { | ||
entities.set(entity); | ||
return super.onSave(entity, id, state, propertyNames, types); | ||
} | ||
|
||
@Override | ||
public void afterTransactionCompletion(org.hibernate.Transaction tx) { | ||
entities.remove(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters