| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| TrailsInterceptor |
|
| 1.380952380952381;1.381 |
| 1 | /* |
|
| 2 | * Copyright 2004 Chris Nelson |
|
| 3 | * |
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | * you may not use this file except in compliance with the License. |
|
| 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
|
| 7 | * Unless required by applicable law or agreed to in writing, |
|
| 8 | * software distributed under the License is distributed on an "AS IS" BASIS, |
|
| 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 10 | * See the License for the specific language governing permissions and limitations under the License. |
|
| 11 | */ |
|
| 12 | /* |
|
| 13 | * Created on Apr 27, 2004 |
|
| 14 | * |
|
| 15 | * To change the template for this generated file go to |
|
| 16 | * Window>Preferences>Java>Code Generation>Code and Comments |
|
| 17 | */ |
|
| 18 | package org.trails.hibernate; |
|
| 19 | ||
| 20 | import java.io.Serializable; |
|
| 21 | import java.util.Iterator; |
|
| 22 | ||
| 23 | import org.hibernate.CallbackException; |
|
| 24 | import org.hibernate.EntityMode; |
|
| 25 | import org.hibernate.Interceptor; |
|
| 26 | import org.hibernate.Transaction; |
|
| 27 | import org.hibernate.type.Type; |
|
| 28 | ||
| 29 | ||
| 30 | /** |
|
| 31 | * <b>Created:<b> Apr 27, 2004<br><br> |
|
| 32 | * <p/> |
|
| 33 | * <b>Description:</b><br> |
|
| 34 | * Class required by Hibernate when you have an object with composite primary key. |
|
| 35 | * The isUnsaved() method is what we're interested in here. |
|
| 36 | * <p/> |
|
| 37 | * <br> |
|
| 38 | * <d>Revision History:</b><br> |
|
| 39 | * ----------------------------------------------------------------------------------<br> |
|
| 40 | * Version Date Author Comments<br> |
|
| 41 | * ----------------------------------------------------------------------------------<br> |
|
| 42 | * 1.0 Apr 27, 2004 CRD3036 Initial Version. |
|
| 43 | * <br> <br> |
|
| 44 | * |
|
| 45 | * @author CRD3036 |
|
| 46 | * @version 1.0 |
|
| 47 | */ |
|
| 48 | public class TrailsInterceptor implements Interceptor, Serializable |
|
| 49 | { |
|
| 50 | /** |
|
| 51 | * |
|
| 52 | */ |
|
| 53 | public TrailsInterceptor() |
|
| 54 | { |
|
| 55 | 12 | super(); |
| 56 | 12 | } |
| 57 | ||
| 58 | /* (non-Javadoc) |
|
| 59 | * @see org.hibernate.Interceptor#onLoad(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[]) |
|
| 60 | */ |
|
| 61 | public boolean onLoad(Object entity, Serializable id, Object[] state, |
|
| 62 | String[] propertyNames, Type[] types) |
|
| 63 | { |
|
| 64 | 2 | if (entity instanceof Interceptable) |
| 65 | { |
|
| 66 | 0 | return ((Interceptable) entity).onLoad(id, state, propertyNames, types); |
| 67 | } |
|
| 68 | ||
| 69 | 2 | return false; |
| 70 | } |
|
| 71 | ||
| 72 | /* (non-Javadoc) |
|
| 73 | * @see org.hibernate.Interceptor#onFlushDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[]) |
|
| 74 | */ |
|
| 75 | public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, |
|
| 76 | Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException |
|
| 77 | { |
|
| 78 | 1 | if (entity instanceof Interceptable) |
| 79 | { |
|
| 80 | 0 | return ((Interceptable) entity).onUpdate(id, currentState, previousState, propertyNames, types); |
| 81 | } |
|
| 82 | 1 | return false; |
| 83 | } |
|
| 84 | ||
| 85 | /* (non-Javadoc) |
|
| 86 | * @see org.hibernate.Interceptor#onSave(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[]) |
|
| 87 | */ |
|
| 88 | public boolean onSave(Object entity, Serializable id, Object[] state, |
|
| 89 | String[] propertyNames, Type[] types) throws CallbackException |
|
| 90 | { |
|
| 91 | 36 | if (entity instanceof Interceptable) |
| 92 | { |
|
| 93 | 9 | return ((Interceptable) entity).onInsert(id, state, propertyNames, types); |
| 94 | } |
|
| 95 | ||
| 96 | 27 | return false; |
| 97 | } |
|
| 98 | ||
| 99 | /* (non-Javadoc) |
|
| 100 | * @see org.hibernate.Interceptor#onDelete(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[]) |
|
| 101 | */ |
|
| 102 | public void onDelete(Object entity, Serializable id, Object[] state, |
|
| 103 | String[] propertyNames, Type[] types) throws CallbackException |
|
| 104 | { |
|
| 105 | 1 | } |
| 106 | ||
| 107 | /* (non-Javadoc) |
|
| 108 | * @see org.hibernate.Interceptor#preFlush(java.util.Iterator) |
|
| 109 | */ |
|
| 110 | public void preFlush(Iterator arg0) throws CallbackException |
|
| 111 | { |
|
| 112 | 30 | } |
| 113 | ||
| 114 | /* (non-Javadoc) |
|
| 115 | * @see org.hibernate.Interceptor#postFlush(java.util.Iterator) |
|
| 116 | */ |
|
| 117 | public void postFlush(Iterator arg0) throws CallbackException |
|
| 118 | { |
|
| 119 | 10 | } |
| 120 | ||
| 121 | /* (non-Javadoc) |
|
| 122 | * @see org.hibernate.Interceptor#isUnsaved(java.lang.Object) |
|
| 123 | */ |
|
| 124 | public Boolean isUnsaved(Object arg0) |
|
| 125 | { |
|
| 126 | 0 | if (arg0 instanceof Interceptable) |
| 127 | { |
|
| 128 | 0 | return new Boolean((!((Interceptable) arg0).isSaved())); |
| 129 | } else |
|
| 130 | { |
|
| 131 | 0 | return null; |
| 132 | } |
|
| 133 | } |
|
| 134 | ||
| 135 | /* (non-Javadoc) |
|
| 136 | * @see org.hibernate.Interceptor#findDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[]) |
|
| 137 | */ |
|
| 138 | public int[] findDirty(Object arg0, Serializable arg1, Object[] arg2, |
|
| 139 | Object[] arg3, String[] arg4, Type[] arg5) |
|
| 140 | { |
|
| 141 | 59 | return null; |
| 142 | } |
|
| 143 | ||
| 144 | /* (non-Javadoc) |
|
| 145 | * @see org.hibernate.Interceptor#instantiate(java.lang.Class, java.io.Serializable) |
|
| 146 | */ |
|
| 147 | public Object instantiate(Class arg0, Serializable arg1) |
|
| 148 | throws CallbackException |
|
| 149 | { |
|
| 150 | 0 | return null; |
| 151 | } |
|
| 152 | ||
| 153 | public Boolean isTransient(Object arg0) |
|
| 154 | { |
|
| 155 | // TODO Auto-generated method stub |
|
| 156 | 40 | return null; |
| 157 | } |
|
| 158 | ||
| 159 | public Object instantiate(String arg0, EntityMode arg1, Serializable arg2) throws CallbackException |
|
| 160 | { |
|
| 161 | // TODO Auto-generated method stub |
|
| 162 | 2 | return null; |
| 163 | } |
|
| 164 | ||
| 165 | public String getEntityName(Object arg0) throws CallbackException |
|
| 166 | { |
|
| 167 | // TODO Auto-generated method stub |
|
| 168 | 95 | return null; |
| 169 | } |
|
| 170 | ||
| 171 | public Object getEntity(String arg0, Serializable arg1) throws CallbackException |
|
| 172 | { |
|
| 173 | // TODO Auto-generated method stub |
|
| 174 | 10 | return null; |
| 175 | } |
|
| 176 | ||
| 177 | public void afterTransactionBegin(Transaction arg0) |
|
| 178 | { |
|
| 179 | // TODO Auto-generated method stub |
|
| 180 | ||
| 181 | 28 | } |
| 182 | ||
| 183 | public void beforeTransactionCompletion(Transaction arg0) |
|
| 184 | { |
|
| 185 | // TODO Auto-generated method stub |
|
| 186 | ||
| 187 | 2 | } |
| 188 | ||
| 189 | public void afterTransactionCompletion(Transaction arg0) |
|
| 190 | { |
|
| 191 | // TODO Auto-generated method stub |
|
| 192 | ||
| 193 | 28 | } |
| 194 | ||
| 195 | public void onCollectionRecreate(Object arg0, Serializable arg1) throws CallbackException |
|
| 196 | { |
|
| 197 | // TODO Auto-generated method stub |
|
| 198 | ||
| 199 | 29 | } |
| 200 | ||
| 201 | public void onCollectionRemove(Object arg0, Serializable arg1) throws CallbackException |
|
| 202 | { |
|
| 203 | // TODO Auto-generated method stub |
|
| 204 | ||
| 205 | 0 | } |
| 206 | ||
| 207 | public void onCollectionUpdate(Object arg0, Serializable arg1) throws CallbackException |
|
| 208 | { |
|
| 209 | // TODO Auto-generated method stub |
|
| 210 | ||
| 211 | 0 | } |
| 212 | ||
| 213 | public String onPrepareStatement(String statement) |
|
| 214 | { |
|
| 215 | 121 | return statement; |
| 216 | } |
|
| 217 | } |