4 Replies Latest reply on Nov 26, 2003 12:30 PM by abuayyub

    ignoring jbosscmp-jdbc.xml problem

    greigm Newbie

      Hi there,

      I am new to JBOSS but feel I have progressed well. I now have a problem in that I am trying to use jbosscmp-jdbc.xml to specify the table name to cmp bean mapping, but can't seem to get it to work, when deployed jboss tries to read the table name as the bean name. If I explain what I have done, can someone have a look and help me out:

      I have created a CMP entity bean called dispatch_areasEJB and created the relevant ejb-jar.xml entries.

      I also created a jbosscmp-jdbc.xml file and packaged this inside the meta-inf directory alongside the ejb-jar.xml file inside the ejb.jar. Inside this file I specify the table-name attribute as "dispatch_areas".

      The problem is when deployed the bean still wants to map to the dispatch_areasEJB table, which does not exist, therefore if I do not use the create tables option in the standardjbosscmp-jdbc.xml file then I get a SQL error stating the table does not exist, otherwise it creates the incorrect table.

      It looks like my jbosscmp-jdbc.xml file is being ignored. Is there anything else I need to do to make sure this is picked up. This is a very simple bean with a couple of fields and no CMR. The datasource obviously works fine as it can create and work with the incorrect table name.

      I am using Oracle 9i, although I don't think the database connection is a problem as it can create the wrong table.

      Extract from my ejb-jar.xml:

      <ejb-name>dispatch_areasEJB</ejb-name>
      com.threefourteen.geographic.dispatch_areasHome
      com.threefourteen.geographic.dispatch_areas
      <local-home>com.threefourteen.geographic.Localdispatch_areasHome</local-home>
      com.threefourteen.geographic.Localdispatch_areas
      <ejb-class>com.threefourteen.geographic.dispatch_areasBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>dispatch_areasEJB</abstract-schema-name>
      <cmp-field>
      Dispatch Area ID
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      Short descriptor
      <field-name>short_name</field-name>
      </cmp-field>
      <cmp-field>
      Full name of dispatch area
      <field-name>full_name</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>


      <query-method>
      <method-name>findAll</method-name>
      <method-params></method-params>
      </query-method>
      <ejb-ql>select distinct object(o) from dispatch_areasEJB o</ejb-ql>



      <query-method>
      <method-name>findByFullName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>select distinct object(o) from dispatch_areasEJB o
      where o.full_name = ?1</ejb-ql>



      <query-method>
      <method-name>findByShortName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>select distinct object(o) from dispatch_areasEJB o
      where o.short_name = ?1</ejb-ql>



      My entire jbosscmp-jdbc.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC
      "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN"
      "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">

      <jbosscmp-jdbc>
      <enterprise-beans>

      <ejb-name>dispatch_areasEJB</ejb-name>
      <table-name>dispatch_areas</table-name>

      </enterprise-beans>
      </jbosscmp-jdbc>


      Do I have enough in this file? I only want to use it to map the table name, everything else is a 'vanilla' bean.

      Thanks for any help.

      Greig...