Hi,

after reading a lot of stuff about the item. I don't know what is the
right way.
Here is my problem.
I'm using Jboss 4.0.3 with a MySQL 4.1 with tables which use
the serial type as primary key.
I want to use entity beans which make use of the auto-increment feature.
I'm using xdoclet. Before I start I want to know which is the right way.
These are the things I found.
1. Solution
In the head of the bean

  |  * @jboss.entity-command name="mysql-get-generated-keys"
  |  * 
  |  * @jboss.unknown-pk class="java.lang.Integer"
  |  *          auto-increment="true"
  | 
Do I have do declare the column of the table with the primary key
as field in the bean?

The create method looks like

  | /**
  |   * @ejb.create-method
  |   * @return Primary Key
  |   * @throws CreateException
  |   */ 
  |   public Integer ejbCreate() throws CreateException {
  |    return null;
  |   }
  | 
  |   public void ejbPostCreate() {
  | 
  |   }
  | 

2. Solution
I only declare in the head of the bean the following

  |  * @jboss.entity-command name="mysql-get-generated-keys"
  |  * 
  | 

And the method declaration for the primary key is

  |     /**
  |      * Getter for CMP Field id
  |      *
  |      * @ejb.pk-field
  |      * @ejb.persistent-field
  |      * @ejb.interface-method   view-type="both"
  |      * 
  |      * @jboss.persistence auto-increment="true"
  |      * 
  |      */
  |     public abstract java.lan.Integer getId();
  | 
The create method looks the same as in solution 1.

What is the right way?

Another problem is how can I access the bean when the key is
autogenerated? The create method delivers a null.
How can I access the generated key?

Thanks in advance,

Marcel.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3930892#3930892

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3930892


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to