Stephen Oakes wrote:

> Whenever we call one of the "get" methods for our EJB (with CMP), it bombs
> because it is trying to do an "UPDATE" on the database table, and it can't
> insert a value in an identity column

> 
> Why is it trying to do an UPDATE for a get?  

Because the container can't know that the get method has no side 
effects. It has to assume that you've changed something. There are two 
things you can do to alleviate this:
1. Implement a 'boolean isModified()' method in your bean. Set a 
modified flag in all of your setters, making sure you set it to false in 
ejbActivate, ejbPassivate, ejbLoad, and ejbStore. isModified will just 
return this flag. BTW, this goes for BMP as well as CMP.
2. Set 'tuned-updates' to true in jaws.xml for that entity. This will 
check for

> Is there a problem with Identity columns?  

If you're adding rows through the (CMP) entity bean. Read-only access or 
updates with tuned-updates==true should work. The (root) problem is that 
there is no SQL standard way of getting the identity columns new value 
back after the insert, which means that the container can't know the 
primary key of your new bean, which makes much of its job impossible. 
You'll find this with any container (unless they have DB specific hooks).

-danch


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to