2 Replies Latest reply on Sep 24, 2002 12:52 PM by Michael

    JBoss 3.0 Changing Datasource in CMP bean using Xdoclet

    Michael Newbie

      Can someone explain, if its possible to change the Default DataSource tags of my CMP bean from Hypersonic Sql to MySql using the xdoclet tags?

      Everytime I build my EJB, the jbosscmp-jdbc.xml file
      looks like the following

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

      <jbosscmp-jdbc>

      java:/DefaultDS
      <datasource-mapping>Hypersonic SQL</datasource-mapping>


      <enterprise-beans>


      <ejb-name>test/TestCMPMySqlEntity</ejb-name>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <table-name>employee</table-name>

      <cmp-field>
      <field-name>empId</field-name>
      <column-name>EmpId</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>title</field-name>
      <column-name>Title</column-name>

      </cmp-field>
      <!--
      To define load groups for this entity, write a file named
      jbosscmp-jdbc-load-TestCMPMySqlEntityBean.xml and put it in
      your mergedir. Write it according to the following DTD slice:
      <!ELEMENT load-groups (load-group+)>
      <!ELEMENT load-group (load-group-name, description?, field-name+)>
      <!ELEMENT load-group-name (#PCDATA)>
      <!ELEMENT description (#PCDATA)>
      <!ELEMENT field-name (#PCDATA)>
      <!ELEMENT eager-load-group (#PCDATA)>
      <!ELEMENT lazy-load-groups (load-group-name+)>
      -->



      </enterprise-beans>

      <dependent-value-classes>

      </dependent-value-classes>

      </jbosscmp-jdbc>

      -- Thanks

        • 1. Re: JBoss 3.0 Changing Datasource in CMP bean using Xdoclet
          koo Newbie

          you have to deploy a mysql-service.xml

          in your xdoclet build target you specify jboss as server target and mysql as a data source
          like this(this is for oracle chage with mysql)


          voila

          • 2. Re: JBoss 3.0 Changing Datasource in CMP bean using Xdoclet
            Michael Newbie

            Thanks for the reply. Actually, what I ended up doing
            is the following.
            1) Using the template project scheme Andreas has put together. By the way it is very useful and easy to follow to build J2EE apps.

            2) Modifying the template build.xml file and specifically modify the .ant.properties file and change 2 entries below.

            # Set the DB type mapping (Hypersonic SQL, PostgreSQL etc., see XDoclet's attribute "typemapping")
            type.mapping=mySQL
            # Set the DataSource name your are going to use (java:/DefaultDS etc., see XDoclet's attribute "datasource")
            datasource.name=java:/MySqlDS

            The ejbdoclet task under the target in the build.xml
            ( <target name="xdoclet-generate" )
            will read in these environment properties and generate the proper deployment descriptor xml files under the META-INF.
            Under the DataSource where I had the default
            HyperSonic DataSource

            <jbosscmp-jdbc>

            java:/DefaultDS
            <datasource-mapping>Hypersonic SQL</datasource-mapping>


            It NOW Changes to the proper ones I want. I just have to make sure the datasource entry is already bound in JBOSS.
            jbosscmp-jdbc>

            java:/MySqlDS
            <datasource-mapping>mySQL</datasource-mapping>