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

📄 producttest.java

📁 网上购物系统struts+spring+hibernate实现
💻 JAVA
字号:
package com.sdi0708.bdifn.bookstore.domain;import junit.framework.TestCase;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class ProductTest extends TestCase {	Session session = null;	@Override	protected void setUp() throws Exception {		super.setUp();		String config = "com/sdi0708/bdifn/bookstore/domain/applicationContext.xml";		ApplicationContext context = new ClassPathXmlApplicationContext(config);		SessionFactory sessionFactory = (SessionFactory) context				.getBean("sessionFactory");		session = sessionFactory.openSession();	}	@Override	protected void tearDown() throws Exception {		super.tearDown();		session.close();	}		public void testSave() {		Catalog c = new Catalog();		c.setId(1000L);		c.setDescription("计算机类书");		c.setName("计算机");				Product p = new Product();		p.setCatalog(c);		p.setDescription("编程类书藉");		p.setProductName("java 编程思想");		p.setUnitPrice(108.00);		session.beginTransaction();		session.save(p);		session.getTransaction().commit();			}}

⌨️ 快捷键说明

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