⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configurationtest.java

📁 hibernate方便的操作数据库相当不错的 请各位下载看看啊
💻 JAVA
字号:
//$Id: ConfigurationTest.java,v 1.2 2005/01/18 00:50:16 epbernard Exp $package org.hibernate.test.metadata;import org.hibernate.cfg.AnnotationConfiguration;import org.hibernate.cfg.Environment;import org.hibernate.cfg.Configuration;import org.hibernate.SessionFactory;import org.hibernate.Session;import org.hibernate.Query;import org.hibernate.Transaction;import org.hibernate.MappingException;/** * @author Emmanuel Bernard */public class ConfigurationTest extends junit.framework.TestCase {	public void testDeclarativeMix() throws Exception {		AnnotationConfiguration cfg = new AnnotationConfiguration();		cfg.configure("org/hibernate/test/metadata/hibernate.cfg.xml");		cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");		SessionFactory sf = cfg.buildSessionFactory();		assertNotNull(sf);		Session s = sf.openSession();		Transaction tx = s.beginTransaction();		Query q = s.createQuery("from Boat");		assertEquals(0, q.list().size());		q = s.createQuery("from Plane");		assertEquals(0, q.list().size());		tx.commit();		s.close();		sf.close();	}	public void testDeclarativeAnnWoAnnConfig() throws Exception {		Configuration cfg = new Configuration ();		try {			cfg.configure("org/hibernate/test/metadata/hibernate.cfg.xml");			fail("Configuration object should fail when finding annotated elements declarations");		} catch (MappingException e) {			//success		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -