There are several approaches to generate primary keys:
- vendor-specific. such as auto-increment. here, vendor-specific api
is used to fetch generated primary keys. For now, only MySQL create
command is implemented.

- using key generator. This approach is vendor independent. For now
only UUIDKeyGenerator is implemented.
<unknown-pk>
   <unknown-pk-class>java.lang.String</unknown-pk-class>
   <column-name>genid</column-name>
   <jdbc-type>VARCHAR</jdbc-type>
   <sql-type>VARCHAR(32)</sql-type>
</unknown-pk>
<entity-command name="key-generator"
                class="org.jboss.ejb.plugins.cmp.jdbc.JDBCKeyGeneratorCreateCommand">
   <attribute name="key-generator-factory">UUIDKeyGeneratorFactory</attribute>
</entity-command>

- using SQL statement to fetch a new pk value. This is for databases
that support sequences.
<unknown-pk>
   <unknown-pk-class>java.lang.Integer</unknown-pk-class>
   <column-name>genid</column-name>
   <jdbc-type>INTEGER</jdbc-type>
   <sql-type>INTEGER</sql-type>
</unknown-pk>
<entity-command name="pk-sql">
   <attribute name="pk-sql">SELECT SEQ_2279_1.nextval FROM DUAL</attribute>
</entity-command>

Required elements are:
- for unknown-pk: unknown-pk-class
- for entity-command: attribute 'name', but for pk-sql you'll probably
want to set your own SQL statement.

alex

Tuesday, September 24, 2002, 11:02:10 PM, you wrote:

DW> And what about Hypersonic (for testing)?

DW> --

DW> Emerson Cargnin - SICREDI Servi�os wrote:
>> those features are just for mysql?? may I use Oracle instead?
>> 
>> Alex Loubyansky wrote:
>> 
>>> Support for unknown primary keys, custom entity create commands and
>>> auto-increment are ported from HEAD to Branch_3_2.
>>>
>>> For more details on how to use it refer to
>>> http://www.jboss.org/forums/thread.jsp?forum=46&thread=21623
>>>
>>> One remark: MySQLCreateEntityCommand is renamed to
>>> JDBCMySQLCreateCommand.
>>>
>>> alex




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to