2 Replies Latest reply on Jun 21, 2002 3:55 PM by nqin

    Please, a simple example with jbosscmp-jdbc.xml

    Rafael Muñoz Newbie

      I'm introducing with CMP in JBoss, and developing with JBuilder 6 as IDE, using the JBossDocsOpenTool.jar.

      I have problems with the jbosscmp-jbdc.xml automatically created.

      Please, can anybody give me a simple good-working example of a CMP example that connect to a database?.

      Thanx

        • 1. Re: Please, a simple example with jbosscmp-jdbc.xml
          Pete Luellen Newbie

          I have some sample code posted on my web site (http://www.westsidewidgets.com), then click on the 'sample code' menu item.

          The jbosscmp-jdbc.xml file is for Rick Hightower's tutorials (there's a link to the tutorials on my site).

          Good luck. Let me know if you have any questions.

          • 2. Re: Please, a simple example with jbosscmp-jdbc.xml
            nqin Newbie

            here is a class, course beans and their relationship. I wish this can help you.



            <?xml version="1.0" encoding="UTF-8"?>
            <jbosscmp-jdbc>

            java:/MySQLDS
            <type-mapping>mySQL</type-mapping>
            true
            <remove-table>false</remove-table>
            <create-table>true</create-table>
            <read-only>false</read-only>
            <time-out>300</time-out>
            <select-for-update>false</select-for-update>
            <pk-constraint>false</pk-constraint>
            <read-ahead>
            on-load
            <page-size>500</page-size>
            <eager-load-group>userEager</eager-load-group>
            </read-ahead>

            <enterprise-beans>

            <ejb-name>classBean</ejb-name>
            <table-name>Class</table-name>
            <cmp-field>
            <field-name>classID</field-name>
            <column-name>classID</column-name>
            <sql-type>INT</sql-type>
            <not-null>true</not-null>
            </cmp-field>
            <cmp-field>
            <field-name>semester</field-name>
            <column-name>semester</column-name>
            <sql-type>VARCHAR(15)</sql-type>
            <jdbc-type>VARCHAR</jdbc-type>
            <not-null>true</not-null>
            </cmp-field>
            <cmp-field>
            <field-name>classDescription</field-name>
            <column-name>classDescription</column-name>
            <sql-type>TEXT</sql-type>
            <jdbc-type>LONGVARCHAR</jdbc-type>
            </cmp-field>
            <cmp-field>
            <field-name>isEnabled</field-name>
            <column-name>isEnabled</column-name>
            <sql-type>INT</sql-type>
            <not-null>true</not-null>
            </cmp-field>
            <cmp-field>
            <field-name>isEverEnabled</field-name>
            <column-name>isEverEnabled</column-name>
            <sql-type>INT</sql-type>
            <not-null>true</not-null>
            </cmp-field>

            <load-groups>
            <load-group>
            <load-group-name>classEager</load-group-name>

            <field-name>semester</field-name>
            <field-name>classDescription</field-name>
            <field-name>isEnabled</field-name>
            <field-name>isEverEnabled</field-name>
            </load-group>
            </load-groups>
            <eager-load-group>classEager</eager-load-group>
            <lazy-load-groups/>



            <ejb-name>courseBean</ejb-name>
            <table-name>Course</table-name>
            <cmp-field>
            <field-name>courseName</field-name>
            <column-name>courseName</column-name>
            <sql-type>VARCHAR(50)</sql-type>
            <jdbc-type>VARCHAR</jdbc-type>
            </cmp-field>
            <cmp-field>
            <field-name>courseDescription</field-name>
            <column-name>courseDescription</column-name>
            <sql-type>TEXT</sql-type>
            <jdbc-type>LONGVARCHAR</jdbc-type>
            </cmp-field>

            <load-groups>
            <load-group>
            <load-group-name>courseEager</load-group-name>
            <field-name>courseDescription</field-name>
            </load-group>
            </load-groups>
            <eager-load-group>courseEager</eager-load-group>
            <lazy-load-groups/>

            </enterprise-beans>


            <ejb-relation>
            <ejb-relation-name>course-class</ejb-relation-name>
            <foreign-key-mapping>
            <ejb-relationship-role>
            <ejb-relationship-role-name>class-relates-to-a-course</ejb-relationship-role-name>
            <foreign-key-fields>
            <foreign-key-field>
            <field-name>courseName</field-name>
            <column-name>courseName</column-name>
            </foreign-key-field>
            </foreign-key-fields>
            </ejb-relationship-role>
            <ejb-relationship-role>
            <ejb-relationship-role-name>course-has-many-class-instance</ejb-relationship-role-name>
            <foreign-key-fields/>
            </ejb-relationship-role>
            </foreign-key-mapping>
            </ejb-relation>

            </jbosscmp-jdbc>