[JBoss-user] [Persistence CMP/JBoss] - Re: Updating entity bean fields using BeanUtils

2004-05-07 Thread roger_cmu
Thanks. I'll try that.

- Roger

View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3834090#3834090

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3834090


---
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson  Lucent use to 
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence CMP/JBoss] - Updating entity bean fields using BeanUtils

2004-05-05 Thread roger_cmu
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=bbop=viewtopicp=3833766#3833766

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=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=3149alloc_id=8166op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence CMP/JBoss] - Re: Auto Increment Primary Keys and MySQL

2004-04-23 Thread roger_cmu
I am getting some errors. For completeness could you please post the sql to create 
tables. I just want to sure that I am not doing anything wrong on the database side.

- Roger

View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3832108#3832108

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3832108


---
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence CMP/JBoss] - Re: Auto Increment Primary Keys and MySQL

2004-04-23 Thread roger_cmu
I am using MySQL database with mysql-connector-java-3.0.11-stable-bin.jar as the 
connector.

- Roger

View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3832117#3832117

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3832117


---
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence CMP/JBoss] - Re: Auto Increment Primary Keys and MySQL

2004-04-23 Thread roger_cmu
The data is getting inserted but I get following exception:

javax.ejb.EJBException: getGeneratedKeys returned an empty ResultSet
at 
org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand.executeInsert(JDBCMySQLCreateCommand.java:77)
at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInsert(JDBCAbstractCreateCommand.java:287)
at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:138)
at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:554)
at 
org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:208)


ejb-jar.xml


display-nameEmployeeEJB/display-name
ejb-nameEmployeeEJB/ejb-name
local-homeemployee.ejb.com.sbm.cts.EmployeeHome/local-home
employee.ejb.com.sbm.cts.Employee
ejb-classemployee.ejb.com.sbm.cts.EmployeeBean/ejb-class
persistence-typeContainer/persistence-type
prim-key-classjava.lang.Integer/prim-key-class 
 
False
cmp-version2.x/cmp-version
abstract-schema-nameEmployeeSchema/abstract-schema-name
cmp-fieldfield-namefirstname/field-name/cmp-field   
 
cmp-fieldfield-namelastname/field-name/cmp-field   
 
cmp-fieldfield-nametelephone/field-name/cmp-field  
 
cmp-fieldfield-nameemployeeid/field-name/cmp-field 
 

primkey-fieldemployeeid/primkey-field

resource-ref
res-ref-namejdbc/ctsDB/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
res-sharing-scopeShareable/res-sharing-scope
/resource-ref


jbosscmp-jdbc.xml:

ejb-nameEmployeeEJB/ejb-name
table-nameemployee/table-name

cmp-field
field-namefirstname/field-name
column-namefirstname/column-name
/cmp-field
cmp-field
field-namelastname/field-name
column-namelastname/column-name
/cmp-field
cmp-field
field-nametelephone/field-name
column-nametelephone/column-name
/cmp-field
cmp-field
field-nameemployeeid/field-name
column-nameemployeeid/column-name
auto-increment/
not-null/
/cmp-field
entity-command name=mysql-get-generated-keys
 
class=org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand/ 


code:

public Integer ejbCreate(EmployeeDetails employeeDetails) throws CreateException {

logger.debug(ejbCreate);

try {
BeanUtils.copyProperties(this, employeeDetails);
} catch (java.lang.reflect.InvocationTargetException e) {
logger.error(e.getMessage());
} catch (Exception e) {
logger.error(e.getMessage());
}

return null;
}


public void ejbPostCreate(EmployeeDetails employeeDetails) {
logger.debug(ejbPostCreate);
}

//  CMP field accessors

public abstract String getFirstname();
public abstract void setFirstname(String firstname);

public abstract String getLastname();
public abstract void setLastname(String lastname);

public abstract String getTelephone();
public abstract void setTelephone(String telephone);

public abstract Integer getEmployeeid();
public abstract void setEmployeeid(Integer employeeid);




View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3832116#3832116

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3832116


---
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!

[JBoss-user] [Persistence CMP/JBoss] - Re: Auto Increment Primary Keys and MySQL

2004-04-23 Thread roger_cmu
Thanks. Problem solved on my side too.  I didn't realise that in jbosscmp-jdbc.xml 
when I wrote
auto-increment/ for the key field, it's meant for the mysql table too. My key field 
on mysql was not auto-increment and hence the cause of problem.

View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3832130#3832130

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3832130


---
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user