-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #871 from xael-fry/1944_hibernateUpdateMaster
[#1944] hibernate update to v4.2.19
- Loading branch information
Showing
15 changed files
with
643 additions
and
535 deletions.
There are no files selected for viewing
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
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
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+4.47 MB
...ework/lib/hibernate-core-4.2.15.Final.jar → ...ework/lib/hibernate-core-4.2.19.Final.jar
Binary file not shown.
Binary file not shown.
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
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,102 @@ | ||
package play.db.jpa; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.MappedSuperclass; | ||
|
||
import org.hibernate.CallbackException; | ||
import org.hibernate.EmptyInterceptor; | ||
import org.hibernate.collection.spi.PersistentCollection; | ||
import org.hibernate.type.Type; | ||
|
||
//Explicit SAVE for JPABase is implemented here | ||
// ~~~~~~ | ||
// We've hacked the org.hibernate.event.def.AbstractFlushingEventListener line 271, to flush collection update,remove,recreation | ||
// only if the owner will be saved or if the targeted entity will be saved (avoid the org.hibernate.HibernateException: Found two representations of same collection) | ||
// As is: | ||
// if (session.getInterceptor().onCollectionUpdate(coll, ce.getLoadedKey())) { | ||
// actionQueue.addAction(...); | ||
// } | ||
// | ||
// This is really hacky. We should move to something better than Hibernate like EBEAN | ||
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 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); | ||
} | ||
|
||
@Override | ||
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); | ||
} | ||
|
||
@Override | ||
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(); | ||
} | ||
|
||
} |
Oops, something went wrong.