4 * Copyright (C) 2001, 2002, 2003 The Mir-coders group
6 * This file is part of Mir.
8 * Mir is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Mir is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Mir; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * In addition, as a special exception, The Mir-coders gives permission to link
23 * the code of this program with any library licensed under the Apache Software License,
24 * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
25 * (or with modified versions of the above that use the same license as the above),
26 * and distribute linked combinations including the two. You must obey the
27 * GNU General Public License in all respects for all of the code used other than
28 * the above mentioned libraries. If you modify this file, you may extend this
29 * exception to your version of the file, but you are not obligated to do so.
30 * If you do not wish to do so, delete this exception statement from your version.
32 package mir.core.test;
34 import java.util.Iterator;
35 import java.util.List;
37 import org.apache.log4j.BasicConfigurator;
39 import mir.core.model.Audio;
40 import mir.core.model.Content;
41 import mir.core.model.Image;
42 import mir.core.model.Media;
43 import mir.core.model.Topic;
44 import mir.core.model.UploadedMedia;
45 import mir.core.model.Video;
46 import net.sf.hibernate.Criteria;
47 import net.sf.hibernate.HibernateException;
48 import net.sf.hibernate.Session;
49 import net.sf.hibernate.SessionFactory;
50 import net.sf.hibernate.Transaction;
51 import net.sf.hibernate.cfg.Configuration;
55 * @version $Id: Test.java,v 1.1 2003/08/16 19:15:27 idfx Exp $
60 public static void main(String[] args) {
61 //BasicConfigurator.configure();
63 SessionFactory factory = new Configuration().configure().buildSessionFactory();
64 Session session = factory.openSession();
65 Transaction transaction = session.beginTransaction();
66 Criteria criteria = session.createCriteria(Topic.class);
67 List list = criteria.setMaxResults(10).list();
68 for(Iterator iterator = list.iterator(); iterator.hasNext();){
69 Topic media = (Topic)iterator.next();
70 System.out.println(media.toString());
72 criteria = session.createCriteria(Media.class);
73 list = criteria.setMaxResults(10).list();
74 for(Iterator iterator = list.iterator(); iterator.hasNext();){
75 Media media = (Media)iterator.next();
76 System.out.println(media.toString());
78 criteria = session.createCriteria(Content.class);
79 list = criteria.setMaxResults(10).list();
80 for(Iterator iterator = list.iterator(); iterator.hasNext();){
81 Content media = (Content)iterator.next();
82 System.out.println(media.getTitle());
84 criteria = session.createCriteria(UploadedMedia.class);
85 list = criteria.setMaxResults(10).list();
86 System.out.println("****** uploaded media");
87 for(Iterator iterator = list.iterator(); iterator.hasNext();){
88 UploadedMedia media = (UploadedMedia)iterator.next();
89 System.out.println(media.toString() + media.getIconPath());
91 criteria = session.createCriteria(Image.class);
92 list = criteria.setMaxResults(10).list();
93 System.out.println("****** image media");
94 for(Iterator iterator = list.iterator(); iterator.hasNext();){
95 Image media = (Image)iterator.next();
96 System.out.println(media.toString() + media.getIconPath());
98 criteria = session.createCriteria(Audio.class);
99 list = criteria.setMaxResults(10).list();
100 System.out.println("****** audio media");
101 for(Iterator iterator = list.iterator(); iterator.hasNext();){
102 Audio media = (Audio)iterator.next();
103 System.out.println(media.toString() + media.getIconPath());
105 criteria = session.createCriteria(Video.class);
106 list = criteria.setMaxResults(10).list();
107 System.out.println("****** video media");
108 for(Iterator iterator = list.iterator(); iterator.hasNext();){
109 Video media = (Video)iterator.next();
110 System.out.println(media.toString() + media.getIconPath());
112 transaction.commit();
114 } catch (HibernateException e) {
115 // TODO Auto-generated catch block