|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| JdoServiceImpl.java | 0% | 0% | 2.6% | 0.3% |
|
||||||||||||||
| 1 |
/**
|
|
| 2 |
* @(#)JDOServiceImpl.java
|
|
| 3 |
*
|
|
| 4 |
* JFoxSOAF, Service-Oriented Application Framework
|
|
| 5 |
*
|
|
| 6 |
* Copyright(c) JFoxSOAF Team
|
|
| 7 |
*
|
|
| 8 |
* Licensed under the GNU LGPL, Version 2.1 (the "License");
|
|
| 9 |
* you may not use this file except in compliance with the License.
|
|
| 10 |
* You may obtain a copy of the License at
|
|
| 11 |
*
|
|
| 12 |
* http://www.gnu.org/copyleft/lesser.html
|
|
| 13 |
*
|
|
| 14 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 15 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 17 |
* See the License for the specific language governing permissions and
|
|
| 18 |
* limitations under the License.
|
|
| 19 |
*
|
|
| 20 |
* For more information, please visit:
|
|
| 21 |
* http://www.jfox.cn/confluence/display/JFoxSOAF/Home
|
|
| 22 |
* http://www.huihoo.org/jfox/jfoxsoaf
|
|
| 23 |
*/
|
|
| 24 |
|
|
| 25 |
package org.huihoo.jfox.soaf.services.persistence;
|
|
| 26 |
|
|
| 27 |
import java.util.Collection;
|
|
| 28 |
import java.util.Map;
|
|
| 29 |
|
|
| 30 |
import javax.jdo.JDOException;
|
|
| 31 |
import javax.jdo.PersistenceManager;
|
|
| 32 |
import javax.jdo.PersistenceManagerFactory;
|
|
| 33 |
import javax.jdo.Query;
|
|
| 34 |
import javax.jdo.Transaction;
|
|
| 35 |
|
|
| 36 |
import org.apache.commons.logging.Log;
|
|
| 37 |
import org.apache.commons.logging.LogFactory;
|
|
| 38 |
import org.huihoo.jfox.soaf.exception.DAOException;
|
|
| 39 |
|
|
| 40 |
/**
|
|
| 41 |
* <p>
|
|
| 42 |
* JDO persistence service wrapper implementation
|
|
| 43 |
* </p>
|
|
| 44 |
*
|
|
| 45 |
* @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
|
|
| 46 |
* @version $Revision:$ $Date:$
|
|
| 47 |
* @version Revision: 1.0
|
|
| 48 |
*/
|
|
| 49 |
|
|
| 50 |
public class JdoServiceImpl implements JdoService { |
|
| 51 |
|
|
| 52 |
private final Log logger = LogFactory.getLog(getClass());
|
|
| 53 |
|
|
| 54 |
private PersistenceManagerFactory pmFactory;
|
|
| 55 |
|
|
| 56 |
private Transaction transaction;
|
|
| 57 |
|
|
| 58 |
private PersistenceManager pm;
|
|
| 59 |
|
|
| 60 |
/**
|
|
| 61 |
* Default Constructor.
|
|
| 62 |
*/
|
|
| 63 | 1 |
public JdoServiceImpl() {
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
/**
|
|
| 67 |
* Set SessionFactory
|
|
| 68 |
* @param sessionFactory
|
|
| 69 |
*/
|
|
| 70 | 0 |
public void setPersistenceManagerFactory(PersistenceManagerFactory pmFactory) { |
| 71 | 0 |
this.pmFactory = pmFactory;
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
/**
|
|
| 75 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getPersistenceManager()
|
|
| 76 |
*/
|
|
| 77 | 0 |
private PersistenceManager getPersistenceManager() throws JDOException { |
| 78 | 0 |
if (pm == null) { |
| 79 | 0 |
pm = pmFactory.getPersistenceManager(); |
| 80 |
} |
|
| 81 | 0 |
return pm;
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
/**
|
|
| 85 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#openTransaction()
|
|
| 86 |
*/
|
|
| 87 | 0 |
public void beginTransaction() throws JDOException { |
| 88 | 0 |
if (pm == null && transaction == null) { |
| 89 | 0 |
pm = getPersistenceManager(); |
| 90 | 0 |
transaction = pm.currentTransaction(); |
| 91 | 0 |
transaction.begin(); |
| 92 |
} |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
/**
|
|
| 96 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#commit()
|
|
| 97 |
*/
|
|
| 98 | 0 |
public void commit() throws JDOException { |
| 99 | 0 |
if (pm != null && !pm.isClosed() && transaction != null |
| 100 |
&& transaction.isActive()) {
|
|
| 101 | 0 |
transaction.commit(); |
| 102 |
} |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
/**
|
|
| 106 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#rollback()
|
|
| 107 |
*/
|
|
| 108 | 0 |
public void rollback() throws JDOException { |
| 109 | 0 |
if (pm != null && !pm.isClosed() && transaction != null |
| 110 |
&& transaction.isActive()) {
|
|
| 111 | 0 |
transaction.rollback(); |
| 112 |
} |
|
| 113 |
} |
|
| 114 |
|
|
| 115 |
/**
|
|
| 116 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#close()
|
|
| 117 |
*/
|
|
| 118 | 0 |
public void close() throws JDOException { |
| 119 | 0 |
if (pm != null && !pm.isClosed()) { |
| 120 | 0 |
pm.close(); |
| 121 | 0 |
pm = null;
|
| 122 |
} |
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
/**
|
|
| 126 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectById(Object)
|
|
| 127 |
*/
|
|
| 128 | 0 |
public Object getObjectById(Object oid) throws JDOException, DAOException { |
| 129 | 0 |
Object obj; |
| 130 | 0 |
PersistenceManager pm; |
| 131 | 0 |
try {
|
| 132 | 0 |
pm = getPersistenceManager(); |
| 133 | 0 |
beginTransaction(); |
| 134 | 0 |
obj = pm.getObjectById(oid); |
| 135 | 0 |
commit(); |
| 136 |
} catch (Exception e) {
|
|
| 137 | 0 |
rollback(); |
| 138 | 0 |
throw new DAOException(e); |
| 139 |
} finally {
|
|
| 140 | 0 |
pm = null;
|
| 141 | 0 |
close(); |
| 142 |
} |
|
| 143 | 0 |
return obj;
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
/**
|
|
| 147 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectById(Class, Object)
|
|
| 148 |
*/
|
|
| 149 | 0 |
public Object getObjectById(Class clazz, Object oid) throws JDOException, |
| 150 |
DAOException {
|
|
| 151 | 0 |
Object obj; |
| 152 | 0 |
PersistenceManager pm; |
| 153 | 0 |
try {
|
| 154 | 0 |
pm = getPersistenceManager(); |
| 155 | 0 |
beginTransaction(); |
| 156 | 0 |
obj = pm.getObjectById(clazz, oid); |
| 157 | 0 |
commit(); |
| 158 |
} catch (Exception e) {
|
|
| 159 | 0 |
rollback(); |
| 160 | 0 |
throw new DAOException(e); |
| 161 |
} finally {
|
|
| 162 | 0 |
pm = null;
|
| 163 | 0 |
close(); |
| 164 |
} |
|
| 165 | 0 |
return obj;
|
| 166 |
} |
|
| 167 |
|
|
| 168 |
/**
|
|
| 169 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectById(Object, boolean)
|
|
| 170 |
*/
|
|
| 171 | 0 |
public Object getObjectById(Object oid, boolean validate) |
| 172 |
throws JDOException, DAOException {
|
|
| 173 | 0 |
Object obj; |
| 174 | 0 |
PersistenceManager pm; |
| 175 | 0 |
try {
|
| 176 | 0 |
pm = getPersistenceManager(); |
| 177 | 0 |
beginTransaction(); |
| 178 | 0 |
obj = pm.getObjectById(oid, validate); |
| 179 | 0 |
commit(); |
| 180 |
} catch (Exception e) {
|
|
| 181 | 0 |
rollback(); |
| 182 | 0 |
throw new DAOException(e); |
| 183 |
} finally {
|
|
| 184 | 0 |
pm = null;
|
| 185 | 0 |
close(); |
| 186 |
} |
|
| 187 | 0 |
return obj;
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
/**
|
|
| 191 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectById(Object)
|
|
| 192 |
*/
|
|
| 193 | 0 |
public Object getObjectId(Object pc) throws JDOException, DAOException { |
| 194 | 0 |
Object obj; |
| 195 | 0 |
PersistenceManager pm; |
| 196 | 0 |
try {
|
| 197 | 0 |
pm = getPersistenceManager(); |
| 198 | 0 |
beginTransaction(); |
| 199 | 0 |
obj = pm.getObjectById(pc); |
| 200 | 0 |
commit(); |
| 201 |
} catch (Exception e) {
|
|
| 202 | 0 |
rollback(); |
| 203 | 0 |
throw new DAOException(e); |
| 204 |
} finally {
|
|
| 205 | 0 |
pm = null;
|
| 206 | 0 |
close(); |
| 207 |
} |
|
| 208 | 0 |
return obj;
|
| 209 |
} |
|
| 210 |
|
|
| 211 |
/**
|
|
| 212 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectById(Class)
|
|
| 213 |
*/
|
|
| 214 | 0 |
public Class getObjectIdClass(Class clazz) throws JDOException, |
| 215 |
DAOException {
|
|
| 216 | 0 |
Class claz; |
| 217 | 0 |
PersistenceManager pm; |
| 218 | 0 |
try {
|
| 219 | 0 |
pm = getPersistenceManager(); |
| 220 | 0 |
beginTransaction(); |
| 221 | 0 |
claz = pm.getObjectIdClass(clazz); |
| 222 | 0 |
commit(); |
| 223 |
} catch (Exception e) {
|
|
| 224 | 0 |
rollback(); |
| 225 | 0 |
throw new DAOException(e); |
| 226 |
} finally {
|
|
| 227 | 0 |
pm = null;
|
| 228 | 0 |
close(); |
| 229 |
} |
|
| 230 | 0 |
return claz;
|
| 231 |
} |
|
| 232 |
|
|
| 233 |
/**
|
|
| 234 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectsById(Collection)
|
|
| 235 |
*/
|
|
| 236 | 0 |
public Collection getObjectsById(Collection oids) throws JDOException, |
| 237 |
DAOException {
|
|
| 238 | 0 |
Collection coll; |
| 239 | 0 |
PersistenceManager pm; |
| 240 | 0 |
try {
|
| 241 | 0 |
pm = getPersistenceManager(); |
| 242 | 0 |
beginTransaction(); |
| 243 | 0 |
coll = pm.getObjectsById(oids); |
| 244 | 0 |
commit(); |
| 245 |
} catch (Exception e) {
|
|
| 246 | 0 |
rollback(); |
| 247 | 0 |
throw new DAOException(e); |
| 248 |
} finally {
|
|
| 249 | 0 |
pm = null;
|
| 250 | 0 |
close(); |
| 251 |
} |
|
| 252 | 0 |
return coll;
|
| 253 |
} |
|
| 254 |
|
|
| 255 |
/**
|
|
| 256 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectById(Object, boolean)
|
|
| 257 |
*/
|
|
| 258 | 0 |
public Collection getObjectsById(Collection oids, boolean validate) |
| 259 |
throws JDOException, DAOException {
|
|
| 260 | 0 |
Collection coll; |
| 261 | 0 |
PersistenceManager pm; |
| 262 | 0 |
try {
|
| 263 | 0 |
pm = getPersistenceManager(); |
| 264 | 0 |
beginTransaction(); |
| 265 | 0 |
coll = pm.getObjectsById(oids, validate); |
| 266 | 0 |
commit(); |
| 267 |
} catch (Exception e) {
|
|
| 268 | 0 |
rollback(); |
| 269 | 0 |
throw new DAOException(e); |
| 270 |
} finally {
|
|
| 271 | 0 |
pm = null;
|
| 272 | 0 |
close(); |
| 273 |
} |
|
| 274 | 0 |
return coll;
|
| 275 |
} |
|
| 276 |
|
|
| 277 |
/**
|
|
| 278 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectsById(Object[])
|
|
| 279 |
*/
|
|
| 280 | 0 |
public Object[] getObjectsById(Object[] oids) throws JDOException, |
| 281 |
DAOException {
|
|
| 282 | 0 |
Object[] objects; |
| 283 | 0 |
PersistenceManager pm; |
| 284 | 0 |
try {
|
| 285 | 0 |
pm = getPersistenceManager(); |
| 286 | 0 |
beginTransaction(); |
| 287 | 0 |
objects = pm.getObjectsById(oids); |
| 288 | 0 |
commit(); |
| 289 |
} catch (Exception e) {
|
|
| 290 | 0 |
rollback(); |
| 291 | 0 |
throw new DAOException(e); |
| 292 |
} finally {
|
|
| 293 | 0 |
pm = null;
|
| 294 | 0 |
close(); |
| 295 |
} |
|
| 296 | 0 |
return objects;
|
| 297 |
} |
|
| 298 |
|
|
| 299 |
/**
|
|
| 300 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#getObjectsById(Object[], boolean)
|
|
| 301 |
*/
|
|
| 302 | 0 |
public Object[] getObjectsById(Object[] oids, boolean validate) |
| 303 |
throws JDOException, DAOException {
|
|
| 304 | 0 |
Object[] objects; |
| 305 | 0 |
PersistenceManager pm; |
| 306 | 0 |
try {
|
| 307 | 0 |
pm = getPersistenceManager(); |
| 308 | 0 |
beginTransaction(); |
| 309 | 0 |
objects = pm.getObjectsById(oids, validate); |
| 310 | 0 |
commit(); |
| 311 |
} catch (Exception e) {
|
|
| 312 | 0 |
rollback(); |
| 313 | 0 |
throw new DAOException(e); |
| 314 |
} finally {
|
|
| 315 | 0 |
pm = null;
|
| 316 | 0 |
close(); |
| 317 |
} |
|
| 318 | 0 |
return objects;
|
| 319 |
} |
|
| 320 |
|
|
| 321 |
/**
|
|
| 322 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#query(Class)
|
|
| 323 |
*/
|
|
| 324 | 0 |
public Collection query(Class clazz) throws JDOException, DAOException { |
| 325 | 0 |
Collection coll; |
| 326 | 0 |
PersistenceManager pm; |
| 327 | 0 |
Query query; |
| 328 | 0 |
try {
|
| 329 | 0 |
pm = getPersistenceManager(); |
| 330 | 0 |
beginTransaction(); |
| 331 | 0 |
query = pm.newQuery(clazz); |
| 332 | 0 |
coll = (Collection) query.execute(); |
| 333 | 0 |
commit(); |
| 334 |
} catch (Exception e) {
|
|
| 335 | 0 |
rollback(); |
| 336 | 0 |
throw new DAOException(e); |
| 337 |
} finally {
|
|
| 338 | 0 |
pm = null;
|
| 339 | 0 |
close(); |
| 340 |
} |
|
| 341 | 0 |
return coll;
|
| 342 |
} |
|
| 343 |
|
|
| 344 |
/**
|
|
| 345 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#query(Class, String)
|
|
| 346 |
*/
|
|
| 347 | 0 |
public Collection query(Class clazz, String filter) throws JDOException, |
| 348 |
DAOException {
|
|
| 349 | 0 |
return query(clazz, filter, null); |
| 350 |
} |
|
| 351 |
|
|
| 352 |
/**
|
|
| 353 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#query(Class, String)
|
|
| 354 |
*/
|
|
| 355 | 0 |
public Collection query(Class clazz, String filter, String ordering)
|
| 356 |
throws JDOException, DAOException {
|
|
| 357 | 0 |
Collection coll; |
| 358 | 0 |
PersistenceManager pm; |
| 359 | 0 |
Query query; |
| 360 | 0 |
try {
|
| 361 | 0 |
pm = getPersistenceManager(); |
| 362 | 0 |
beginTransaction(); |
| 363 | 0 |
query = pm.newQuery(clazz, filter); |
| 364 | 0 |
if (ordering != null) { |
| 365 | 0 |
query.setOrdering(ordering); |
| 366 |
} |
|
| 367 | 0 |
coll = (Collection) query.execute(); |
| 368 | 0 |
commit(); |
| 369 |
} catch (Exception e) {
|
|
| 370 | 0 |
rollback(); |
| 371 | 0 |
throw new DAOException(e); |
| 372 |
} finally {
|
|
| 373 | 0 |
pm = null;
|
| 374 | 0 |
close(); |
| 375 |
} |
|
| 376 | 0 |
return coll;
|
| 377 |
} |
|
| 378 |
|
|
| 379 |
/**
|
|
| 380 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#queryWithMap(Class, String, String, Map)
|
|
| 381 |
*/
|
|
| 382 | 0 |
public Collection queryWithMap(Class clazz, String filter,
|
| 383 |
String parameters, Map values) throws JDOException, DAOException {
|
|
| 384 | 0 |
return queryWithMap(clazz, filter, null, parameters, values); |
| 385 |
} |
|
| 386 |
|
|
| 387 |
/**
|
|
| 388 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#queryWithMap(Class, String, String, String, Map)
|
|
| 389 |
*/
|
|
| 390 | 0 |
public Collection queryWithMap(Class clazz, String filter, String ordering,
|
| 391 |
String parameters, Map values) throws JDOException, DAOException {
|
|
| 392 | 0 |
Collection coll; |
| 393 | 0 |
PersistenceManager pm; |
| 394 | 0 |
Query query; |
| 395 | 0 |
try {
|
| 396 | 0 |
pm = getPersistenceManager(); |
| 397 | 0 |
beginTransaction(); |
| 398 | 0 |
query = pm.newQuery(clazz, filter); |
| 399 | 0 |
if (ordering != null) { |
| 400 | 0 |
query.setOrdering(ordering); |
| 401 |
} |
|
| 402 | 0 |
query.declareParameters(parameters); |
| 403 | 0 |
coll = (Collection) query.executeWithMap(values); |
| 404 | 0 |
commit(); |
| 405 |
} catch (Exception e) {
|
|
| 406 | 0 |
rollback(); |
| 407 | 0 |
throw new DAOException(e); |
| 408 |
} finally {
|
|
| 409 | 0 |
pm = null;
|
| 410 | 0 |
close(); |
| 411 |
} |
|
| 412 | 0 |
return coll;
|
| 413 |
} |
|
| 414 |
|
|
| 415 |
/**
|
|
| 416 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#queryWithMap(Class, String, String, Object[])
|
|
| 417 |
*/
|
|
| 418 | 0 |
public Collection queryWithMap(Class clazz, String filter,
|
| 419 |
String parameters, Object[] values) throws JDOException,
|
|
| 420 |
DAOException {
|
|
| 421 | 0 |
return queryWithMap(clazz, filter, null, parameters, values); |
| 422 |
} |
|
| 423 |
|
|
| 424 |
/**
|
|
| 425 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#queryWithMap(Class, String, String, String, Object[])
|
|
| 426 |
*/
|
|
| 427 | 0 |
public Collection queryWithMap(Class clazz, String filter, String ordering,
|
| 428 |
String parameters, Object[] values) throws JDOException,
|
|
| 429 |
DAOException {
|
|
| 430 | 0 |
Collection coll; |
| 431 | 0 |
PersistenceManager pm; |
| 432 | 0 |
Query query; |
| 433 | 0 |
try {
|
| 434 | 0 |
pm = getPersistenceManager(); |
| 435 | 0 |
beginTransaction(); |
| 436 | 0 |
query = pm.newQuery(clazz, filter); |
| 437 | 0 |
if (ordering != null) { |
| 438 | 0 |
query.setOrdering(ordering); |
| 439 |
} |
|
| 440 | 0 |
query.declareParameters(parameters); |
| 441 | 0 |
coll = (Collection) query.executeWithArray(values); |
| 442 | 0 |
commit(); |
| 443 |
} catch (Exception e) {
|
|
| 444 | 0 |
rollback(); |
| 445 | 0 |
throw new DAOException(e); |
| 446 |
} finally {
|
|
| 447 | 0 |
pm = null;
|
| 448 | 0 |
close(); |
| 449 |
} |
|
| 450 | 0 |
return coll;
|
| 451 |
} |
|
| 452 |
|
|
| 453 |
/**
|
|
| 454 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#query(Class, Collection)
|
|
| 455 |
*/
|
|
| 456 | 0 |
public Collection query(Class clazz, Collection coll) throws JDOException, |
| 457 |
DAOException {
|
|
| 458 | 0 |
Collection cln; |
| 459 | 0 |
PersistenceManager pm; |
| 460 | 0 |
Query query; |
| 461 | 0 |
try {
|
| 462 | 0 |
pm = getPersistenceManager(); |
| 463 | 0 |
beginTransaction(); |
| 464 | 0 |
query = pm.newQuery(clazz, coll); |
| 465 | 0 |
cln = (Collection) query.execute(); |
| 466 | 0 |
commit(); |
| 467 |
} catch (Exception e) {
|
|
| 468 | 0 |
rollback(); |
| 469 | 0 |
throw new DAOException(e); |
| 470 |
} finally {
|
|
| 471 | 0 |
pm = null;
|
| 472 | 0 |
close(); |
| 473 |
} |
|
| 474 | 0 |
return cln;
|
| 475 |
|
|
| 476 |
} |
|
| 477 |
|
|
| 478 |
/**
|
|
| 479 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#query(Class, Collection, String)
|
|
| 480 |
*/
|
|
| 481 | 0 |
public Collection query(Class clazz, Collection coll, String filter)
|
| 482 |
throws JDOException, DAOException {
|
|
| 483 | 0 |
Collection cln; |
| 484 | 0 |
PersistenceManager pm; |
| 485 | 0 |
Query query; |
| 486 | 0 |
try {
|
| 487 | 0 |
pm = getPersistenceManager(); |
| 488 | 0 |
beginTransaction(); |
| 489 | 0 |
query = pm.newQuery(clazz, coll, filter); |
| 490 | 0 |
cln = (Collection) query.execute(); |
| 491 | 0 |
commit(); |
| 492 |
} catch (Exception e) {
|
|
| 493 | 0 |
rollback(); |
| 494 | 0 |
throw new DAOException(e); |
| 495 |
} finally {
|
|
| 496 | 0 |
pm = null;
|
| 497 | 0 |
close(); |
| 498 |
} |
|
| 499 | 0 |
return cln;
|
| 500 |
} |
|
| 501 |
|
|
| 502 |
/**
|
|
| 503 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#query(Object)
|
|
| 504 |
*/
|
|
| 505 | 0 |
public Collection query(Object object) throws JDOException, DAOException { |
| 506 | 0 |
Collection cln; |
| 507 | 0 |
PersistenceManager pm; |
| 508 | 0 |
Query query; |
| 509 | 0 |
try {
|
| 510 | 0 |
pm = getPersistenceManager(); |
| 511 | 0 |
beginTransaction(); |
| 512 | 0 |
query = pm.newQuery(object); |
| 513 | 0 |
cln = (Collection) query.execute(); |
| 514 | 0 |
commit(); |
| 515 |
} catch (Exception e) {
|
|
| 516 | 0 |
rollback(); |
| 517 | 0 |
throw new DAOException(e); |
| 518 |
} finally {
|
|
| 519 | 0 |
pm = null;
|
| 520 | 0 |
close(); |
| 521 |
} |
|
| 522 | 0 |
return cln;
|
| 523 |
} |
|
| 524 |
|
|
| 525 |
/**
|
|
| 526 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#query(String)
|
|
| 527 |
*/
|
|
| 528 | 0 |
public Collection query(String queryStr) throws JDOException, DAOException { |
| 529 | 0 |
Collection cln; |
| 530 | 0 |
PersistenceManager pm; |
| 531 | 0 |
Query query; |
| 532 | 0 |
try {
|
| 533 | 0 |
pm = getPersistenceManager(); |
| 534 | 0 |
beginTransaction(); |
| 535 | 0 |
query = pm.newQuery(queryStr); |
| 536 | 0 |
cln = (Collection) query.execute(); |
| 537 | 0 |
commit(); |
| 538 |
} catch (Exception e) {
|
|
| 539 | 0 |
rollback(); |
| 540 | 0 |
throw new DAOException(e); |
| 541 |
} finally {
|
|
| 542 | 0 |
pm = null;
|
| 543 | 0 |
close(); |
| 544 |
} |
|
| 545 | 0 |
return cln;
|
| 546 |
} |
|
| 547 |
|
|
| 548 |
/**
|
|
| 549 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#evict(Object)
|
|
| 550 |
*/
|
|
| 551 | 0 |
public void evict(Object object) throws JDOException, DAOException { |
| 552 | 0 |
PersistenceManager pm; |
| 553 | 0 |
try {
|
| 554 | 0 |
pm = getPersistenceManager(); |
| 555 | 0 |
pm.evict(object); |
| 556 |
} catch (Exception e) {
|
|
| 557 | 0 |
throw new DAOException(e); |
| 558 |
} finally {
|
|
| 559 | 0 |
pm = null;
|
| 560 | 0 |
close(); |
| 561 |
} |
|
| 562 |
} |
|
| 563 |
|
|
| 564 |
/**
|
|
| 565 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#evictAll()
|
|
| 566 |
*/
|
|
| 567 | 0 |
public void evictAll() throws JDOException, DAOException { |
| 568 | 0 |
PersistenceManager pm; |
| 569 | 0 |
try {
|
| 570 | 0 |
pm = getPersistenceManager(); |
| 571 | 0 |
pm.evictAll(); |
| 572 |
} catch (Exception e) {
|
|
| 573 | 0 |
throw new DAOException(e); |
| 574 |
} finally {
|
|
| 575 | 0 |
pm = null;
|
| 576 | 0 |
close(); |
| 577 |
} |
|
| 578 |
} |
|
| 579 |
|
|
| 580 |
/**
|
|
| 581 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#evictAll(Collection)
|
|
| 582 |
*/
|
|
| 583 | 0 |
public void evictAll(Collection coll) throws JDOException, DAOException { |
| 584 | 0 |
PersistenceManager pm; |
| 585 | 0 |
try {
|
| 586 | 0 |
pm = getPersistenceManager(); |
| 587 | 0 |
pm.evictAll(coll); |
| 588 |
} catch (Exception e) {
|
|
| 589 | 0 |
throw new DAOException(e); |
| 590 |
} finally {
|
|
| 591 | 0 |
pm = null;
|
| 592 | 0 |
close(); |
| 593 |
} |
|
| 594 |
} |
|
| 595 |
|
|
| 596 |
/**
|
|
| 597 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#evictAll(Object[])
|
|
| 598 |
*/
|
|
| 599 | 0 |
public void evictAll(Object[] objects) throws JDOException, DAOException { |
| 600 | 0 |
PersistenceManager pm; |
| 601 | 0 |
try {
|
| 602 | 0 |
pm = getPersistenceManager(); |
| 603 | 0 |
pm.evictAll(objects); |
| 604 |
} catch (Exception e) {
|
|
| 605 | 0 |
rollback(); |
| 606 | 0 |
throw new DAOException(e); |
| 607 |
} finally {
|
|
| 608 | 0 |
pm = null;
|
| 609 | 0 |
close(); |
| 610 |
} |
|
| 611 |
} |
|
| 612 |
|
|
| 613 |
/**
|
|
| 614 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#flush()
|
|
| 615 |
*/
|
|
| 616 | 0 |
public void flush() throws JDOException, DAOException { |
| 617 | 0 |
PersistenceManager pm; |
| 618 | 0 |
try {
|
| 619 | 0 |
pm = getPersistenceManager(); |
| 620 | 0 |
pm.flush(); |
| 621 |
} catch (Exception e) {
|
|
| 622 | 0 |
rollback(); |
| 623 | 0 |
throw new DAOException(e); |
| 624 |
} finally {
|
|
| 625 | 0 |
pm = null;
|
| 626 | 0 |
close(); |
| 627 |
} |
|
| 628 |
} |
|
| 629 |
|
|
| 630 |
/**
|
|
| 631 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#makePersistent(Object)
|
|
| 632 |
*/
|
|
| 633 | 0 |
public void makePersistent(Object object) throws JDOException, DAOException { |
| 634 | 0 |
PersistenceManager pm; |
| 635 | 0 |
try {
|
| 636 | 0 |
pm = getPersistenceManager(); |
| 637 | 0 |
pm.makePersistent(object); |
| 638 |
} catch (Exception e) {
|
|
| 639 | 0 |
rollback(); |
| 640 | 0 |
throw new DAOException(e); |
| 641 |
} finally {
|
|
| 642 | 0 |
pm = null;
|
| 643 | 0 |
close(); |
| 644 |
} |
|
| 645 |
} |
|
| 646 |
|
|
| 647 |
/**
|
|
| 648 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#makePersistentAll(Collection)
|
|
| 649 |
*/
|
|
| 650 | 0 |
public void makePersistentAll(Collection coll) throws JDOException, |
| 651 |
DAOException {
|
|
| 652 | 0 |
PersistenceManager pm; |
| 653 | 0 |
try {
|
| 654 | 0 |
pm = getPersistenceManager(); |
| 655 | 0 |
pm.makePersistentAll(coll); |
| 656 |
} catch (Exception e) {
|
|
| 657 | 0 |
rollback(); |
| 658 | 0 |
throw new DAOException(e); |
| 659 |
} finally {
|
|
| 660 | 0 |
pm = null;
|
| 661 | 0 |
close(); |
| 662 |
} |
|
| 663 |
} |
|
| 664 |
|
|
| 665 |
/**
|
|
| 666 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#makePersistentAll(Object[])
|
|
| 667 |
*/
|
|
| 668 | 0 |
public void makePersistentAll(Object[] objects) throws JDOException, |
| 669 |
DAOException {
|
|
| 670 | 0 |
PersistenceManager pm; |
| 671 | 0 |
try {
|
| 672 | 0 |
pm = getPersistenceManager(); |
| 673 | 0 |
pm.makePersistentAll(objects); |
| 674 |
} catch (Exception e) {
|
|
| 675 | 0 |
rollback(); |
| 676 | 0 |
throw new DAOException(e); |
| 677 |
} finally {
|
|
| 678 | 0 |
pm = null;
|
| 679 | 0 |
close(); |
| 680 |
} |
|
| 681 |
} |
|
| 682 |
|
|
| 683 |
/**
|
|
| 684 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#deletePersistent(Object)
|
|
| 685 |
*/
|
|
| 686 | 0 |
public void deletePersistent(Object object) throws JDOException, |
| 687 |
DAOException {
|
|
| 688 | 0 |
PersistenceManager pm; |
| 689 | 0 |
try {
|
| 690 | 0 |
pm = getPersistenceManager(); |
| 691 | 0 |
pm.deletePersistent(object); |
| 692 |
} catch (Exception e) {
|
|
| 693 | 0 |
rollback(); |
| 694 | 0 |
throw new DAOException(e); |
| 695 |
} finally {
|
|
| 696 | 0 |
pm = null;
|
| 697 | 0 |
close(); |
| 698 |
} |
|
| 699 |
} |
|
| 700 |
|
|
| 701 |
/**
|
|
| 702 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#deletePersistentAll(Collection)
|
|
| 703 |
*/
|
|
| 704 | 0 |
public void deletePersistentAll(Collection coll) throws JDOException, |
| 705 |
DAOException {
|
|
| 706 | 0 |
PersistenceManager pm; |
| 707 | 0 |
try {
|
| 708 | 0 |
pm = getPersistenceManager(); |
| 709 | 0 |
pm.deletePersistent(coll); |
| 710 |
} catch (Exception e) {
|
|
| 711 | 0 |
rollback(); |
| 712 | 0 |
throw new DAOException(e); |
| 713 |
} finally {
|
|
| 714 | 0 |
pm = null;
|
| 715 | 0 |
close(); |
| 716 |
} |
|
| 717 |
} |
|
| 718 |
|
|
| 719 |
/**
|
|
| 720 |
* @see org.huihoo.jfox.soaf.services.persistence.JdoService#deletePersistentAll(Object[])
|
|
| 721 |
*/
|
|
| 722 | 0 |
public void deletePersistentAll(Object[] objects) { |
| 723 | 0 |
PersistenceManager pm; |
| 724 | 0 |
try {
|
| 725 | 0 |
pm = getPersistenceManager(); |
| 726 | 0 |
pm.deletePersistent(objects); |
| 727 |
} catch (Exception e) {
|
|
| 728 | 0 |
rollback(); |
| 729 | 0 |
throw new DAOException(e); |
| 730 |
} finally {
|
|
| 731 | 0 |
pm = null;
|
| 732 | 0 |
close(); |
| 733 |
} |
|
| 734 |
} |
|
| 735 |
} |
|
||||||||||