Does VAJ4.0 WTE even support transactions?


EJB programming & troubleshooting: Does VAJ4.0 WTE even support transactions?

  1. Does VAJ4.0 WTE even support transactions? (2 messages)

    I'm using Visual Age for Java 4.0 and i'm working on a few entity beans using their websphere test environment. The situation is that I have a entity-entity bean relationship, (Employee to Skill) such that in order to associate a skill with an employee, i use the secondaryAddRatedSkills() method (autogengerated, of course, I love their naming conventions, NOT).

    The problem is, I have set up a test case where I call a SLSB that will take a list of skill ratings and add it to the employee. Basically, the SLSB gets the reference to the employee bean, and calls secondaryAddRatedSkills() on it in a loop for each skill. The test was to check that if one of the skills was already assigned, it should raise an exception. So, in my loop, i'm trying and catching anything, and when I catch the exception i throw an appliaction level exception with a friendlier message. But the transaction doesn't roll back! so if i send it a list of 5 skills, and the 3rd in the list is already assigned, the first two get assigned and the exception causes the entire operation to stop, but the database shows the first 2 skills assigned! Why doesn't the transaction rollback?!?!? This is killing me. These tools are supposed to make development of transactional systems easier, but this behavior defies logic.

    Any help would be appreciated.

    btw: all components are set to TX_REQUIRED so that they must be used in a transaction.


    Threaded Messages (2)

  2. Gagh, ok, here's the story,

    I was reading through the Mastering EJB book (good book, btw) and apparantly, throwing an exception may or may not cause a transaction to rollback (actually, throwing a custom exception will not) therefore, you need to setRollbackOnly() on the ejb context to indicate that the exception was bad enough to cause a there it is.

  3. looking[ Go to top ] this the same Christopher that lived in Michigan?