开发者

Testing inserts over Mule JDBC transport to embedded HSQLDB, subsequent query returns no results

My test attempts to show that a SQL statement sent over a Mule JDBC outbound endpoint executes successfully. The problem: after inserting over Mule, querying the same table returns no results.

I'm using Spring JDBC to test the results of that statement.

In my setup method I create the schema with a DDL statement sent over Spring JDBC:

final JdbcTemplate _jdbcTemplate = new JdbcTemplate(new
SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:mydb"));

Mule JDBC outbound connector is also configured to point to jdbc:hsqldb:mem:mydb

<spring:bean id="myDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
    <spring:property name="driverName" value="org.hsq开发者_运维技巧ldb.jdbc.JDBCDriver"/>
    <spring:property name="url" value="jdbc:hsqldb:mem:mydb"/>
</spring:bean>

<jdbc:connector name="insertionConnector" dataSource-ref="myDataSource">
    <jdbc:query key="insertion"
                value="INSERT INTO mytable (TEST_KEY) VALUES (#[map-payload:_testkey])"/>
</jdbc:connector>

<custom-transformer name="objectFieldsToMap" class="com.mydomain.ObjectFieldsToMap"/>

<flow name="sendInsertion">
    <vm:inbound-endpoint address="vm://insert"/>
    <jdbc:outbound-endpoint queryKey="insertion" transformer-refs="objectFieldsToMap" connector-ref="insertionConnector"/>
</flow>

I verified that inserting a test row and querying for it using Spring JDBC both ways works.

I verified that sending the same insert statement over the outbound endpoint returns 1 row updated.

 final MuleClient muleClient = MyFactory.muleClient();
 final Date date = new Date();
 final MyObject myObject = new MyObject.Builder().setTestKey("test").build();

 muleClient.dispatch("vm://insert", myObject, null);

However, when I then query the same table using Spring JDBC I get an empty result set.

(String) _jdbcTemplate.queryForObject("SELECT TEST_KEY FROM MYDB.mytable", Class.forName("java.lang.String"));

Internally, Mule (using Apache DbUtils) commits after executing the statement so the insertion should be visible to subsequent queries. I am using the same JdbcTemplate object used to create the schema to then query for the results.

Help appreciated. Thank you.


Just to confirm, are you running Mule and your spring bean querying the table in the same JVM?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜