Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 使用arquillian/hibernate进行JPA测试时,如何查看插入的行?_Sql Server_Hibernate_Jpa - Fatal编程技术网

Sql server 使用arquillian/hibernate进行JPA测试时,如何查看插入的行?

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

我有一个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="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 {
 ...
}