I have a fairly straight forward product catalog data model that includes categories, products, items. Categories can have zero or more products, products can have zero or more items.
I have a single (integer) primary key on all beans and have basic CMR mapping between the beans. The primary keys are auto_increment fields in the DB. All beans also include a character 'ID' field. The ID field is not unique at each level in the hierarchy (e.g., product P0 can have item I0 associated with it as well as product P1 can have an Item I0 associated with it). I'm using MySQL 4.0.21, JBoss 3.2.3 on Linux RedHat 9. The issue I'm having is how to have the system (JBoss, MySQL, etc.) handle more of the 'uniqueness' issue here. I've implemented an 'addChild()' business method on the category and product beans to add children to their nest. This method determines if the new child already exists (based on the ID field) in their nest. If so, then toss an exception. This is, however, a bit heavy on the processing side........ I would like the system to handle more of this processing. I tried composite keys on all of the beans but that pretty much failed. I could create composite keys at the item level, but specifying a composite key as a foreign key in the CMR relationship I just couldn't get to work. Bummer..... Soooo, I tried setting a UNIQUE INDEX (itemID, parentKey) on the database and having the 'addChild()' method just call, for example, ItemLocalHome.create() with the new Item child. The 'create()' succeeded but when the new Item bean was persisted, the DB server threw a nasty exception back to JBoss (TransactionRolledbackLocalException). Unfortunately, I couldn't trap this in any of the beans' methods and return a nice error back to the client. I understand that with CMP-based beans, I write less code but I also lose significant processing control, especially in situations like this. Is there any way of specifying something in the system to allow me to (not have composite keys defined in the beans but) force JBoss or something else to provide me better control in this situation (e.g., synchronize create() and persistence processing) so I can handle error conditions better? Thanks. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3854642#3854642 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3854642 ------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
