Am using MySQL database with 3.0.8 of the JDBC drivers. Now I want to create a simple test...
I have a session bean witch create an instance of a CMP Entity Bean, then I want to purposly throw an exception and see if the data is rolled back from the DB. Do CMP Beans even use XADatasource for transcation processing?
CMP beans are transactional. Whether the transaction will be rolled back depends on the kind of exception you use. According to the EJB specification, any System exception (defined as a Runtime exception) will automatically cause rollback.
Any application exception (defined as a non-Runtime exception) will not automatically rollback the transaction. This allows for the possibility of error recovery. If you use application exceptions, you must call the SessionContext.setRollBackOnly() method to rollback the transaction.
You could also use a 'normal' DataSource instead of the XADataSource. The big difference between Datasource and XADatasource is that the XADataSource can handle transactions over multiple resources (Databases).
Hope this helps
So this means I can still use the CMP transaction features with MySQL?
It should work, so long as you configure your DataSource correctly.