~eloisant/play/httpcommons

« back to all changes in this revision

Viewing changes to framework/src/play/db/jpa/JPAPlugin.java

  • Committer: guillaume
  • Date: 2010-05-21 12:19:29 UTC
  • mfrom: (907.1.2 play)
  • Revision ID: guillaume@gbo-mac-20100521121929-mbyp8sjr63pbw7cm
Fix JPAPlugin to work with JPABase

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
            cfg.setProperty("hibernate.dialect", getDefaultDialect(Play.configuration.getProperty("db.driver")));
80
80
            cfg.setProperty("javax.persistence.transaction", "RESOURCE_LOCAL");
81
81
 
82
 
            // Explicit SAVE for JPASupport is implemented here
 
82
            // Explicit SAVE for JPABase is implemented here
83
83
            // ~~~~~~
84
84
            // We've hacked the org.hibernate.event.def.AbstractFlushingEventListener line 271, to flush collection update,remove,recreation
85
85
            // only if the owner will be saved.
93
93
 
94
94
                @Override
95
95
                public int[] findDirty(Object o, Serializable id, Object[] arg2, Object[] arg3, String[] arg4, Type[] arg5) {
96
 
                    if (o instanceof JPASupport && !((JPASupport) o).willBeSaved) {
 
96
                    if (o instanceof JPABase && !((JPABase) o).willBeSaved) {
97
97
                        return new int[0];
98
98
                    }
99
99
                    return null;
103
103
                public boolean onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
104
104
                    if (collection instanceof PersistentCollection) {
105
105
                        Object o = ((PersistentCollection) collection).getOwner();
106
 
                        if (o instanceof JPASupport) {
107
 
                            return ((JPASupport) o).willBeSaved;
 
106
                        if (o instanceof JPABase) {
 
107
                            return ((JPABase) o).willBeSaved;
108
108
                        }
109
109
                    } else {
110
110
                        System.out.println("HOO: Case not handled !!!");
116
116
                public boolean onCollectionRecreate(Object collection, Serializable key) throws CallbackException {
117
117
                    if (collection instanceof PersistentCollection) {
118
118
                        Object o = ((PersistentCollection) collection).getOwner();
119
 
                        if (o instanceof JPASupport) {
120
 
                            return ((JPASupport) o).willBeSaved;
 
119
                        if (o instanceof JPABase) {
 
120
                            return ((JPABase) o).willBeSaved;
121
121
                        }
122
122
                    } else {
123
123
                        System.out.println("HOO: Case not handled !!!");
129
129
                public boolean onCollectionRemove(Object collection, Serializable key) throws CallbackException {
130
130
                    if (collection instanceof PersistentCollection) {
131
131
                        Object o = ((PersistentCollection) collection).getOwner();
132
 
                        if (o instanceof JPASupport) {
133
 
                            return ((JPASupport) o).willBeSaved;
 
132
                        if (o instanceof JPABase) {
 
133
                            return ((JPABase) o).willBeSaved;
134
134
                        }
135
135
                    } else {
136
136
                        System.out.println("HOO: Case not handled !!!");