5 Replies Latest reply on Oct 21, 2004 2:00 AM by weeclub4

    EJB-Table and DB-Table Mapping Problem

    weeclub4

      Hi,

      I m new to jboss and from documentation and from websites i tried to solve it but nothing is working may be there is problem in my implementation.

      I m trying to Map my entity bean named 'First' to the table 'New_First' which resides on Oracle. Everything works fine for table xyz. I m providing different table name in ejb-jar.xml and jbosscmp-jdbc.xml as well.

      This is the code of jbosscmp-jdbc.xml
      ..
      java:/ERM
      <datasource-mapping>Oracle8</datasource-mapping>


      <enterprise-beans>

      <ejb-name>First</ejb-name>
      <table-name>New_First</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>new_id</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>master_name</field-name>
      <column-name>new_master_name</column-name>

      </cmp-field>

      </enterprise-beans>
      ..


      And Here is the total code of ejb-jar.xml

      <ejb-jar>
      <display-name>ejb1EJB</display-name>
      <enterprise-beans>

      <ejb-name>First</ejb-name>
      <table-name>New_First</table-name>
      firstBean.FirstHome
      firstBean.First
      <ejb-class>firstBean.FirstBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>firstBean.FirstKey</prim-key-class>
      False
      <cmp-field>
      <field-name>id</field-name>
      <column-name>new_id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>master_name</field-name>
      <column-name>new_master_name</column-name>
      </cmp-field>


      <ejb-name>FirstSess</ejb-name>
      firstBean.FirstSessHome
      firstBean.FirstSess
      <ejb-class>firstBean.FirstSessBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      </enterprise-beans>
      </ejb-jar>


      After completion of jboss server starting it looks for table named 'First'.

      PLEASEEEEEEEEEE HELPPPPPP!!!!!!!!!!!!!!

        • 1. Re: EJB-Table and DB-Table Mapping Problem
          robisz

          Your jbosscmp-jdbc.xml should look like this:

          <defaults>
           <datasource>java:/ERM</datasource>
           <datasource-mapping>Oracle8</datasource-mapping>
          </defaults>
          
          <enterprise-beans>
          <entity>
           <ejb-name>First</ejb-name>
           <table-name>New_First</table-name>
           <cmp-field>
           <field-name>id</field-name>
           <column-name>new_id</column-name>
           </cmp-field>
           <cmp-field>
           <field-name>master_name</field-name>
           <column-name>new_master_name</column-name>
           </cmp-field>
          </entity>
          </enterprise-beans>


          • 2. Re: EJB-Table and DB-Table Mapping Problem
            weeclub4

            I copied the given code as it is inside this tag <jbosscmp-jdbc>
            but still the output is same

            [JDBCInitCommand] Table 'First' already exists.

            Is there anything which i can do ot try out.

            • 3. Re: EJB-Table and DB-Table Mapping Problem
              robisz

              Oops, your ejb-jar seems problematic too.
              entity and session elements are missing...
              and you don't need to
              add table-name and column-name elements here.

              • 4. Re: EJB-Table and DB-Table Mapping Problem
                weeclub4

                Sorry about that i think it coz due to interface
                Now i m writing it in this

                
                <ejb-jar>
                 <display-name>ejb1EJB</display-name>
                 <enterprise-beans>
                 <entity>
                 <ejb-name>First</ejb-name>
                 <table-name>New_Table_First</table-name>
                 <home>firstBean.FirstHome</home>
                 <remote>firstBean.First</remote>
                 <ejb-class>firstBean.FirstBean</ejb-class>
                 <persistence-type>Container</persistence-type>
                 <prim-key-class>firstBean.FirstKey</prim-key-class>
                 <reentrant>False</reentrant>
                 <cmp-field>
                 <field-name>id</field-name>
                 <column-name>new_id</column-name>
                 </cmp-field>
                 <cmp-field>
                 <field-name>master_name</field-name>
                 <column-name>new_master_name</column-name>
                 </cmp-field>
                 </entity>
                 <session>
                 <ejb-name>FirstSess</ejb-name>
                 <home>firstBean.FirstSessHome</home>
                 <remote>firstBean.FirstSess</remote>
                 <ejb-class>firstBean.FirstSessBean</ejb-class>
                 <session-type>Stateless</session-type>
                 <transaction-type>Container</transaction-type>
                 </session>
                 </enterprise-beans>
                </ejb-jar>
                
                


                This time it is looking fine (I think).

                • 5. Re: EJB-Table and DB-Table Mapping Problem
                  weeclub4

                  Thank you all who tried to solve the problem but i guess there is some problem with jboss 3.2.5 in this case coz the same thing is working fine in jboss 4.0.0.

                  Thank you once again