Sql server 使用arquillian/hibernate进行JPA测试时,如何查看插入的行?
我有一个arquillian单元测试,写一个注释并通过单元测试 现在,我想实际查看正在持久化到SQLServer数据库中的内容 当我打开SQLServer时,我看到了我的“Note”表,其中包含所有必需的列……但没有数据Sql server 使用arquillian/hibernate进行JPA测试时,如何查看插入的行?,sql-server,hibernate,jpa,Sql Server,Hibernate,Jpa,我有一个arquillian单元测试,写一个注释并通过单元测试 现在,我想实际查看正在持久化到SQLServer数据库中的内容 当我打开SQLServer时,我看到了我的“Note”表,其中包含所有必需的列……但没有数据 <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="ht
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="noteUnit"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jdbc/datasources/notes</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2005Dialect" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
</persistence>
通常,jUnit被配置为使其事务处于
defaultrollback=true
模式。这样做是为了避免在数据库中插入测试数据。您可能会在类定义或扩展类中找到配置
具有Spring IOC配置的jUnit示例:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:myPath/spring*Context.xml")
@TransactionConfiguration(defaultRollback = true)
@Transactional
public abstract class AbstactSpringTestCase {
...
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:myPath/spring*Context.xml")
@TransactionConfiguration(defaultRollback = true)
@Transactional
public abstract class AbstactSpringTestCase {
...
}