KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > pobjects > inheritance > ejboo2 > CataloguePersistantImpl


1 /*
2  * Created on 27 mai 2004
3  *
4  * To change the template for this generated file go to
5  * Window - Preferences - Java - Code Generation - Code and Comments
6  */

7 package org.objectweb.speedo.pobjects.inheritance.ejboo2;
8
9
10 import java.util.Collection JavaDoc;
11 import java.util.HashSet JavaDoc;
12
13 import javax.jdo.JDOHelper;
14 import javax.jdo.PersistenceManager;
15
16
17 /**
18  * Persistent Data
19  */

20
21 public class CataloguePersistantImpl implements CataloguePersistant {
22     
23     private Long JavaDoc id;
24
25     private String JavaDoc nom;
26
27     private String JavaDoc description;
28     
29     /**
30      * Constructor
31      * @param id
32      */

33     public CataloguePersistantImpl() {
34         this.articles = new HashSet JavaDoc();
35     }
36
37     public CataloguePersistantImpl(long idcat) {
38         this();
39         id = new Long JavaDoc(idcat);
40     }
41
42     /**
43     * one many relation, reverse = catalogue
44     */

45     private Collection JavaDoc articles;
46     /**
47      * @return Returns the articles.
48      */

49     public Collection JavaDoc getArticles() {
50         return articles;
51     }
52     /**
53      * @param articles The articles to set.
54      */

55     public void setArticles(Collection JavaDoc articles) {
56         this.articles = articles;
57     }
58     /**
59      * @return Returns the description.
60      */

61     public String JavaDoc getDescription() {
62         return description;
63     }
64     /**
65      * @param description The description to set.
66      */

67     public void setDescription(String JavaDoc description) {
68         this.description = description;
69     }
70     /**
71      * @return Returns the id.
72      */

73     public Long JavaDoc getId() {
74         return id;
75     }
76     /**
77      * @param id The id to set.
78      */

79     public void setId(Long JavaDoc id) {
80         this.id = id;
81     }
82     /**
83      * @return Returns the nom.
84      */

85     public String JavaDoc getNom() {
86         return nom;
87     }
88     /**
89      * @param nom The nom to set.
90      */

91     public void setNom(String JavaDoc nom) {
92         this.nom = nom;
93     }
94
95     public void supprimer() {
96         System.out.println("CataloguePersistantImpl.supprimer");
97         PersistenceManager pm = JDOHelper.getPersistenceManager(this);
98         
99         System.out.println("pm.deletePersistentAll(articles)");
100         // remove articles-catalogue relations
101
pm.deletePersistentAll(articles);
102         
103         // remove catalogue-articles relations
104
articles.clear();
105
106         System.out.println("pm.deletePersistent(this)");
107         pm.deletePersistent(this);
108
109     }
110
111     
112     public String JavaDoc toString() {
113         String JavaDoc s = new String JavaDoc(this.getClass().getName());
114         s += " id="+id;
115         s += " nom="+nom;
116         s += " description="+description;
117         return s;
118     }
119 }
120
Popular Tags