CMP entity bean using auto_increment with mysql?


EJB programming & troubleshooting: CMP entity bean using auto_increment with mysql?

  1. Hello there,

    I am trying to do a simple CMP entity bean for a product table that has about 6 fields created in Mysql. The table has a primary key (pid) that is an integer that set to auto_increments. The other fields are just integer that are foreign keys to other attributes tables.

    I have been going though code from a O'reilly book and have come to a dead end. When a call the create method from a client what attributes do I pass for the primary key. I am not sure how the bean will get the value from the table that is auto_incremented. I am really new to EJB's so please can someone shed some light on the matter?

    I really appriciate the help!!!!!

  2. auto_increment + MySQL[ Go to top ]

    Although I didn't test EJBs with MySQL, I've used MySQL a long time,
    so try putting a zero in your create() method, it will instruct MySQL
    to use the autoincrement value for that field.