KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javabb > dao > hibernate > PrivMsgSentHibernateDAO


1 /*
2  * Copyright 2004 JavaFree.org
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.javabb.dao.hibernate;
18
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.javabb.dao.entity.IPrivMsgSentDAO;
23 import org.javabb.vo.PrivMsg;
24 import org.javabb.vo.PrivMsgSent;
25 import org.javabb.vo.User;
26
27 /**
28  * @author Lucas Teixeira - <a HREF="mailto:lucas@javabb.org">lucas@javabb.org</a>
29  */

30
31 public class PrivMsgSentHibernateDAO extends HibernateDAO implements IPrivMsgSentDAO {
32
33     public List JavaDoc retrieveUserOutbox(User u) throws Exception JavaDoc {
34         return find(PrivMsgSent.class, "o.userFrom.idUser=?", new Object JavaDoc[] { u.getId() },
35                 "o.data DESC", ALL_PAGES, 0);
36     }
37
38     public PrivMsgSent load(Long JavaDoc id) throws Exception JavaDoc {
39         return (PrivMsgSent) getHibernateTemplate().load(PrivMsgSent.class, id);
40     }
41
42     public void save(PrivMsgSent p) throws Exception JavaDoc {
43         getHibernateTemplate().save(p);
44     }
45
46     public void delete(PrivMsgSent p) throws Exception JavaDoc {
47         getHibernateTemplate().delete(p);
48     }
49     
50     public void delete(List JavaDoc l) throws Exception JavaDoc {
51         String JavaDoc sql = "delete from jbb_privmsg_outbox where id_privmsg in (";
52         for (Iterator JavaDoc i=l.iterator(); i.hasNext(); )
53             sql+= ((PrivMsg) i.next()).getId() + ",";
54         sql = sql.substring(0, sql.length()-1);
55         sql += ");";
56         this.executeSQL(sql);
57     }
58 }
59
Popular Tags