Hello folks!

JBossCMP now provides some new ways to setup and create entity beans.
It is based on so called entity commands.
First some working examples (snippet from jbosscmp-jdbc.xml):
<entity>
   <ejb-name>MyCMPBean</ejb-name>
   <table-name>mycmp_table</table-name>

   <!-- auto-incremented primary key (jdk1.3/1.4) for now supported only for MySQL. -->
   <cmp-field>
      <field-name>id</field-name>
      <column-name>knownid</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER(11)</sql-type>
      <auto-increment/>
   </cmp-field>
   <!-- entity command to create the entity -->
   <entity-command name="mysql-get-generated-keys"/>

   <!-- unknown primary key generated with SQL statement -->
   <unknown-pk>
      <unknown-pk-class>java.lang.Integer</unknown-pk-class>
      <column-name>genid</column-name>
      <jdbc-type>TIMESTAMP</jdbc-type>
      <sql-type>DATETIME</sql-type>
   </unknown-pk>
   <entity-command name="pk-sql"/>
    -->
   <!-- pk-sql generated unknown-pk; overriding default sql
   <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>
   -->
   <!-- mysql generated unknown-pk
   <unknown-pk>
      <unknown-pk-class>java.lang.Integer</unknown-pk-class>
      <column-name>genid</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER(11)</sql-type>
      <auto-increment/>
   </unknown-pk>
   <entity-command name="mysql-get-generated-keys"
                   
class="org.jboss.ejb.plugins.cmp.jdbc.mysql.MySQLCreateEntityCommand"/>
    -->
    <!-- the use of key generator for unknown-pk
    <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>
    -->
</entity>

The general syntax of entity-command is:
<entity-command name="CommandName"
                class="ComandClass">
   <attribute name="attr1">value1</attribute>
   <attribute name="attr2">value2</attribute>
</entity-command>

Only the 'name' is required.
You can check the list of available commands in
standardjbosscmp-jdbc.xml in entity-commands element.
The default entity command is specified in 'defaults' element and can
be overriden in each entity element as above.
If entity-command in the entity provides 'class' or 'attribute' it
overrides the corresponding element of in the known command.

For now the feature is available in HEAD version.

-- 
Best regards,
 Alex Loubyansky




-------------------------------------------------------
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