小编Pau*_*aul的帖子

DBunit生成java.lang.ClassCastException:尝试加载CLOB字段时,java.lang.String无法强制转换为oracle.sql.CLOB

我在Oracle 11GR2上使用最新版本的DBUnit(2.4.7).我正在使用Java 6(1.6.0_15)和最新版本的Oracle客户端jar(jdbc6.jar)

我无法将XML文件中CLOB Oracle字段引用的任何数据成功加载到数据库中.

我已经使用了各种版本的组合:

  • Oracle JDBC库ojdbc5.jar,ojdbc6.jar,oracle 10 jars
  • Hibernate库等...我认为问题出在DBUnit上.请参阅下面的堆栈跟踪.

    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.5.0-CR-2</version>
    
    Run Code Online (Sandbox Code Playgroud)

    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>3.4.0.GA</version>
    
    Run Code Online (Sandbox Code Playgroud)

我正在运行Java 6,1.6.0_15.

我试过了:

1)使用此定义的FlatXmlDataSet

<MESSAGE msg_id="1" mtp_id="1" msg_detail="asadds" />
Run Code Online (Sandbox Code Playgroud)

2)使用此定义的XmlDataSet

<table name="MESSAGE">
    <column>MSG_ID</column>
    <column>MTP_ID</column>
    <column>MSG_DETAIL</column>
    <row>
        <value>1</value>
        <value>1</value>
        <value>dsad</value>
    </row>
</table>
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激!

堆栈跟踪如下:

        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:980)
ERROR [10032010 14:15:13,031] - exception creating EntityManager:  [] (MessageDAOTest.java:97)
java.lang.RuntimeException: Exception in JpaDBTestCase
        at com.ert.commons.junit4.hibernate.JpaDBTestCase.loadDbunitFiles(JpaDBTestCase.java:97)
        at com.ert.ertmon.dao.ejb.impl.MessageDAOTest.setUpBeforeClass(MessageDAOTest.java:94)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at …

java orm dbunit hibernate clob

7
推荐指数
1
解决办法
6711
查看次数

标签 统计

clob ×1

dbunit ×1

hibernate ×1

java ×1

orm ×1