2 Replies Latest reply on Nov 1, 2005 8:15 AM by dominique boeckli

    Relationship (post-table-create)

    dominique boeckli Newbie

      Hi,

      i have exactly the same problem described here:
      http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3837631#3837631

      with the difference that i am using JBoss 4.02

      the post create in the <relation-table-mapping> tag is ignored and replaced with the one defined in the bean itself which result in a SQL error: "Duplicate entry".

      Listing of my
      jbosscmp-jdbc.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
      <jbosscmp-jdbc>
       <defaults>
       <datasource>java:/TPFuserDS</datasource>
       <datasource-mapping>mySQL</datasource-mapping>
       <create-table>true</create-table>
       <alter-table>false</alter-table>
       <remove-table>false</remove-table>
       <read-only>false</read-only>
       <row-locking>false</row-locking>
       <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
       <read-ahead>
       <strategy>on-load</strategy>
       <page-size>5</page-size>
       <eager-load-group>*</eager-load-group>
       </read-ahead>
       <list-cache-max>5</list-cache-max>
       <clean-read-ahead-on-load>true</clean-read-ahead-on-load>
       <fetch-size>5</fetch-size>
       </defaults>
       <enterprise-beans>
       <entity>
       <ejb-name>TPFuser</ejb-name>
       <post-table-create>
       <sql-statement>INSERT INTO tpfuser (userid, password, firstname, lastname, contact) VALUES ('admin', 'admin', 'admin', 'admin', 'anybody@any.net')</sql-statement>
       </post-table-create>
       <table-name>tpfuser</table-name>
       <cmp-field>
       <field-name>userID</field-name>
       <column-name>userid</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>password</field-name>
       <column-name>password</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>firstname</field-name>
       <column-name>firstname</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>lastname</field-name>
       <column-name>lastname</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>contact</field-name>
       <column-name>contact</column-name>
       </cmp-field>
       </entity>
       <entity>
       <ejb-name>Role</ejb-name>
       <post-table-create>
       <sql-statement>INSERT INTO role (role, comment) VALUES ('admin', 'Administrator')</sql-statement>
       </post-table-create>
       <table-name>role</table-name>
       <cmp-field>
       <field-name>role</field-name>
       <column-name>role</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>comment</field-name>
       <column-name>comment</column-name>
       </cmp-field>
       </entity>
       </enterprise-beans>
       <relationships>
       <ejb-relation>
       <ejb-relation-name>TPFusers-roles</ejb-relation-name>
       <read-only>false</read-only>
       <relation-table-mapping>
       <table-name>users_roles</table-name>
       <create-table>true</create-table>
       <remove-table>false</remove-table>
       <post-table-create>
       <sql-statement>INSERT INTO users_roles (Role, TPFuser) VALUES ('admin', 'admin')</sql-statement>
       </post-table-create>
       <pk-constraint>true</pk-constraint>
       </relation-table-mapping>
       </ejb-relation>
       </relationships>
      </jbosscmp-jdbc>
      
      


      many thanks for your help