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