I have a number of EJB2 CMP beans with logic such as the follows:
In other words, create a widget with a specified ID then set additional attributes like name and description. Now, let me add additional information that widgetName is a required field in the database (cannot be null). In Geronimo, this wasn't a problem as the CMP flush/write was delayed until the end of the transaction. Now that I'm trying to run the same code in JBoss, I'm running into the problem that writes are sent to the database during the home.create() call and any missing fields (like Name) are throwing SQL Exceptions.
One solution would be to add name as part of the create method as follows:
The problem? I have hundreds of EJBs each with up to a dozen required fields. The fix would take a lot of time to implement. My question: is there a way I can get the same behavior as in geronimo, such that writes were delayed until after the create is run such as at the end of the transaction?
I have some other solutions such as remove the database constraint -or- modify the ejbCreate methods to insert blank data (like "" for strings or -1 for integers) but those seem like bad ideas to me. On the plus side they would save me from having to rewrite all the signatures. [ August 15, 2008: Message edited by: Scott Selikoff ]
The more I think about it the more I think Geronimo/OpenEJB was incorrect in allowing the INSERT's to occur after ejbCreate()/ejbPostCreate() is executed. In that regard there's no way to tell exactly when the objects are created in the database and its a time bomb waiting to go off for errors.
Just wish the original developers had foreseen this...
Convert it to EJB3 where delayed commit is required, since you can tag fields explicitly as not NULL.
You do need to expand the scope of the transaction, since if there are mandatory fields, it would be perilous in the extreme to have an eager commit kick in, regardless of the platform, and the default transaction scope for an EJB is per-method. Normally one would do this by setting up the entity bean from a session EJB.
Customer surveys are for companies who didn't pay proper attention to begin with.
Originally posted by Tim Holloway: Convert it to EJB3
One giant conversion at a time. I figure moving from Geronimo to JBoss even with changing the ejbCreate methods is a 2-3 week project. Moving to EJB3 is well beyond that.
In the current situation, all the entity beans are set up by session beans, but in Geronimo/OpenEJB there was a notion that database writes wouldn't happen immediately, whereas JBoss has a different approach.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com