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

📄 timestamptest.java

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 JAVA
字号:
//$Id: TimestampTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $package org.hibernate.test.timestamp;import java.util.Date;import junit.framework.Test;import org.hibernate.Session;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import org.hibernate.cfg.Environment;import org.hibernate.junit.functional.FunctionalTestCase;import org.hibernate.junit.functional.FunctionalTestClassTestSuite;/** * @author Gavin King */public class TimestampTest extends FunctionalTestCase {		public TimestampTest(String str) {		super(str);	}	public String[] getMappings() {		return new String[] { "timestamp/User.hbm.xml" };	}	public void configure(Configuration cfg) {		cfg.setProperty(Environment.GENERATE_STATISTICS, "true");	}	public static Test suite() {		return new FunctionalTestClassTestSuite( TimestampTest.class );	}		public void testUpdateFalse() {		getSessions().getStatistics().clear();				Session s = openSession();		Transaction t = s.beginTransaction();		User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );		s.persist(u);		s.flush();		u.getPerson().setName("XXXXYYYYY");		t.commit();		s.close();				assertEquals( 1, getSessions().getStatistics().getEntityInsertCount() );		assertEquals( 0, getSessions().getStatistics().getEntityUpdateCount() );		s = openSession();		t = s.beginTransaction();		u = (User) s.get(User.class, "gavin");		assertEquals( u.getPerson().getName(), "Gavin King" );		s.delete(u);		t.commit();		s.close();				assertEquals( 1, getSessions().getStatistics().getEntityDeleteCount() );	}		public void testComponent() {				Session s = openSession();		Transaction t = s.beginTransaction();		User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );		s.persist(u);		s.flush();		u.getPerson().setCurrentAddress("Peachtree Rd");		t.commit();		s.close();				s = openSession();		t = s.beginTransaction();		u = (User) s.get(User.class, "gavin");		u.setPassword("$ecret");		t.commit();		s.close();		s = openSession();		t = s.beginTransaction();		u = (User) s.get(User.class, "gavin");		assertEquals( u.getPassword(), "$ecret" );		s.delete(u);		t.commit();		s.close();	}}

⌨️ 快捷键说明

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