Hi, I have resource local datasource (Oracle9i) deployed at JBoss 5.1.0:
<datasources>
<local-tx-datasource>
<jndi-name>OracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@IP_ADDRESS:1521:inv9i</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>***</user-name>
<password>***</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
persistence unit:
<persistence version="1.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_1_0.xsd">
<persistence-unit name="myEJB" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:OracleDS</non-jta-data-source>
<class>hr.bel.model.Instrument</class>
<class>hr.bel.model.Order</class>
<class>hr.bel.model.OrderAdditionalData</class>
<class>hr.bel.model.OrderCondition</class>
<class>hr.bel.model.Trade</class>
<class>hr.bel.model.TradeAdditionalData</class>
<class>hr.bel.model.Tradeticker</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/>
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
Within an MDB, when onMessage method is invoked I'm trying to persist an bean and fetch latest 5 beans of that type via an namedQuery:
@PersistenceContext
EntityManager em = null;
public void onMessage(MyMessage msg) {
Map message = msg.getMessageTree(false);
Instrument instrument = em.find(Instrument.class, 55);
Tradeticker tt = createTradeticker(message);
tt.setInstrument(instrument);
log.info("Persisting tradeticker: " + tt.getTradeType());
em.persist(tt);
log.info("Tradeticker persisted...");
List<Tradeticker> last5 = em.createNamedQuery("getLast5").setParameter(1,instrument.getInstrumentId()).setMaxResults(5).getResultList();
log.info("Persisted tradetickers size: " + last5.size());
}
My problem is that there is no any trace of an error but still there is no any persisted objects in my Oracle database. After great number of messages call last5.size()
returns 0. Log is perfectly clean.
Only restrictions for MDBs I found are I have to use REQUIRED or NOT_SUPPORTED transaction attribute on methods. My onMessage is not annotated so it uses REQUIRED as default. Also I have no any annotations on MDB class so bean should use container managed transaction.
What I'm doing wrong?