X-Git-Url: http://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=blobdiff_plain;f=src%2Fit%2Ftutorials%2Fbasic%2Fsrc%2Ftest%2Fjava%2Forg%2Fhibernate%2Ftutorial%2Fhbm%2FNativeApiIllustrationTest.java;fp=src%2Fit%2Ftutorials%2Fbasic%2Fsrc%2Ftest%2Fjava%2Forg%2Fhibernate%2Ftutorial%2Fhbm%2FNativeApiIllustrationTest.java;h=0000000000000000000000000000000000000000;hp=c714f7067fe659406b314f3fcd93e895f0764082;hb=0b6b9a1bd8950880713885618d8e31c772a085ec;hpb=9e37fd1049f8a6794396cd7c8879dc413fbcb87c diff --git a/src/it/tutorials/basic/src/test/java/org/hibernate/tutorial/hbm/NativeApiIllustrationTest.java b/src/it/tutorials/basic/src/test/java/org/hibernate/tutorial/hbm/NativeApiIllustrationTest.java deleted file mode 100644 index c714f706..00000000 --- a/src/it/tutorials/basic/src/test/java/org/hibernate/tutorial/hbm/NativeApiIllustrationTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.tutorial.hbm; - -import java.util.Date; -import java.util.List; - -import junit.framework.TestCase; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; - -/** - * Illustrates use of Hibernate native APIs. - * - * @author Steve Ebersole - */ -public class NativeApiIllustrationTest extends TestCase { - private SessionFactory sessionFactory; - - @Override - protected void setUp() throws Exception { - // A SessionFactory is set up once for an application - sessionFactory = new Configuration() - .configure() // configures settings from hibernate.cfg.xml - .buildSessionFactory(); - } - - @Override - protected void tearDown() throws Exception { - if ( sessionFactory != null ) { - sessionFactory.close(); - } - } - - public void testBasicUsage() { - // create a couple of events... - Session session = sessionFactory.openSession(); - session.beginTransaction(); - session.save( new Event( "Our very first event!", new Date() ) ); - session.save( new Event( "A follow up event", new Date() ) ); - session.getTransaction().commit(); - session.close(); - - // now lets pull events from the database and list them - session = sessionFactory.openSession(); - session.beginTransaction(); - List result = session.createQuery( "from Event" ).list(); - for ( Event event : (List) result ) { - System.out.println( "Event (" + event.getDate() + ") : " + event.getTitle() ); - } - session.getTransaction().commit(); - session.close(); - } -}