📄 strategytest.java
字号:
//$Id: StrategyTest.java 11282 2007-03-14 22:05:59Z epbernard $package org.hibernate.test.annotations.strategy;import org.hibernate.Session;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import org.hibernate.cfg.DefaultComponentSafeNamingStrategy;import org.hibernate.test.annotations.TestCase;/** * @author Emmanuel Bernard */public class StrategyTest extends TestCase { public void testComponentSafeStrategy() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); Location start = new Location(); start.setCity( "Paris" ); start.setCountry( "France" ); Location end = new Location(); end.setCity( "London" ); end.setCountry( "UK" ); Storm storm = new Storm(); storm.setEnd( end ); storm.setStart( start ); s.persist( storm ); s.flush(); tx.rollback(); s.close(); } protected void configure(Configuration cfg) { cfg.setNamingStrategy( DefaultComponentSafeNamingStrategy.INSTANCE ); //cfg.getSessionEventListenerConfig().setFlushEventListener( new EJB3FlushEventListener() ); //cfg.getSessionEventListenerConfig().setAutoFlushEventListener( new EJB3AutoFlushEventListener() ); } protected Class[] getMappings() { return new Class[]{ Storm.class }; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -