KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > bean > HibernatePersister


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.spring.bean;
5
6 import org.springframework.orm.hibernate3.HibernateTemplate;
7
8 public class HibernatePersister {
9
10   private PersistentSubobject root;
11
12   private transient HibernateTemplate template;
13
14   public HibernatePersister(HibernateTemplate template) {
15     this.template = template;
16   }
17
18   public PersistentObject make() {
19     synchronized (this) {
20       root = new PersistentSubobject(PersistentSubobject.DELIVERED);
21     }
22     
23     PersistentObject po = new PersistentObject();
24     template.save(po);
25     return po;
26
27   }
28
29   public void changeStatus(int id) {
30     PersistentObject po = (PersistentObject) template.load(PersistentObject.class, new Integer JavaDoc(id));
31     po.noteMessageStatus(root);
32     template.saveOrUpdate(po);
33   }
34
35 }
36
Popular Tags