I have an entity bean with the following three methods.
| public abstract Integer getProductid(); | public abstract void setProductid(Integer productid); | public abstract String getProduct_desc(); | public abstract void setProduct_desc(String desc); | public abstract String getProduct_info(); | public abstract void setProduct_info(String info); | Let's look at method update: | public void update(ProductDetails productDetails) { | logger.info("update"); | try { | BeanUtils.copyProperties(this, productDetails); | }catch (java.lang.reflect.InvocationTargetException e) { | logger.warn("InvocationTargetException", e); | }catch (IllegalAccessException e) { | logger.warn("Illegal Access exception", e); | } | } | Let's look at ProductDetails | private int productid; | private int product_desc; | private int product_info; | .... getter and setters for all the three variables declared above. | As you noticed I am using BeanUtils.copyProperties(this, productDetails); code to copy all the values from productDetails to update the entity bean. I get an error when I execute update. anonymous wrote : java.lang.IllegalStateException: A CMP field that is a member of the primary key can only be set in ejbCreate This is a valide error. What's fix: I thought of having two value objects for each entity bean. One class will have all the fields except the primary key field. So my productDetails class will drop productid from the above mentioned code. Next I'll extend produceDetails class to produceDetailsID which will just have productid field along with getter and setter. Next my update code will use productDetailsID instead of productDetails to update the bean. Is there a better way to handle this case. This is my first ejb project. How do most of developers update the entity bean fields. Some of my beans have lots of fields. BeanUtils class is available at org.apache.commons.beanutils.BeanUtils. Thanks. - Roger View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3833766#3833766 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3833766 ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user