7 Replies Latest reply on Mar 8, 2002 2:37 AM by koval

    Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping

    koval

      Hi all,

      I'm new to JBoss and trying to get my customerEjb jar working (containing 5 entity beans, CMP Local EJBs) with JBoss3.0. I've managed to get rid of some exceptions when deploying it, but I'm still experiencing some problems. Following exception is thrown during deployment:
      ---------------------
      java.lang.NullPointerException
      at org.jboss.ejb.plugins.cmp.jdbc.SQLUtil.getCreateTableColumnsClause(SQ
      LUtil.java:29)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.getRelationCreateTabl
      eSQL(JDBCStartCommand.java:134)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.execute(JDBCStartComm
      and.java:50)
      at org.jboss.ejb.plugins.cmp.CMPStoreManager.start(CMPStoreManager.java:...
      ----------

      I guess I should add O-R mappings into 'jbosscmp-jdbc.xml' but I'm not sure if this is necessary. Does anyone has experienced similar problems and what is the answer?

      Thanks

        • 1. Re: Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping
          dsundstrom

          The goal is for the mapping to not be required, but there are some places where it is currently necessary.

          What verion are you using? Do you currently have a jbosscmp-jdbc.xml file? What the ejb-jar.xml file spec for this relationship?

          • 2. Re: Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping
            koval

            I'm using jboss-3.0.0alpha and there is 'jbosscmp-jdbc.xml' (as well as 'jboss.xml') that contains following text:

            - <jbosscmp-jdbc>
            -
            java:/testbeanDS
            <type-mapping>mySQL</type-mapping>
            true
            <create-table>true</create-table>
            <remove-table>false</remove-table>
            <read-only>false</read-only>
            <time-out>300</time-out>
            <select-for-update>false</select-for-update>
            <preferred-relation-mapping>foreign-key</preferred-relation-mapping>

            </jbosscmp-jdbc>



            There are "one-to-many" and "one-to-one" relationships between EJBs. ejb-jar.xml file was created by using "deploytool" from j2sdkee1.3.1, and the only thing I was missing initially was "ejb-link" parameter, after that I got this null exception. probably when trying to create db tables.
            if this could help:
            I had same exception when was trying to deploy "customerEjb" from petStoreDemo 1.3 (using only 'one-to-one' relationship), and noticed that some tables where created some not.

            • 3. Re: Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping
              dsundstrom

              I would recommend switching to the beta.

              I think this doesn't work because the Pet Store demo uses "unknown" primary keys which are not currently supported.

              • 4. Re: Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping
                koval

                Hi Dain,

                I just figured out (when looking for the answers) that You are the author of "JBossCMP Workbook".

                First tell me if there are enough explanations to my problems in this book, so I would spend less time (is money too) looking for the answers.

                Second why are you suggesting BETA version?

                And third, I'm not postitive about'"unknown" primary keys ' but I guess it's the thing I liked in whole thing, and was wandering how it works. That was approach I've choosed to play with JBoss persistence engine.

                Nevermind, what is the solution and is there any possibility or work around.
                How this thing will work, e.g.
                I already defined relationship between entities 'address' and 'customer' (address is a field inside the customer). So are You telling me that I got to add 'customerId' inside the address (for one-to-many) because current version is not able of doing so. And if I do this how will I tell the persistence engine that field is a foreign key that points to the customer table ID.

                If all this things are well explained inside "JBossCMP Workbook", just tell me, but also I would appriciated a short answer.

                Thanks.

                • 5. Re: Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping
                  koval

                  Oh I almost forgot,
                  are you also suggesting that I had to define PRIMARY KEY inside EJBs (and descriptor) since not defined PK (Object key) won't work.

                  like following:
                  public AddressLocal findByPrimaryKey(Object key) throws FinderException;

                  • 6. Re: Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping
                    dsundstrom

                    &gt; First tell me if there are enough explanations to my
                    &gt; problems in this book, so I would spend less time (is
                    &gt; money too) looking for the answers.

                    The docs walk you through the process of creating entities, cmp fields, relationship and queries. They are quite detailed and come with a full source example.

                    The current docs only cover the alpha, but I am currently in the middle of updating them for the beta.

                    &gt; Second why are you suggesting BETA version?

                    The beta is less buggy, and cvs beta is even less buggy.

                    &gt; And third, I'm not postitive about'"unknown" primary
                    &gt; keys ' but I guess it's the thing I liked in whole
                    &gt; thing, and was wandering how it works. That was
                    &gt; approach I've choosed to play with JBoss persistence
                    &gt; engine.

                    What?

                    &gt; Nevermind, what is the solution and is there any
                    &gt; possibility or work around.
                    &gt; How this thing will work, e.g.
                    &gt; I already defined relationship between entities
                    &gt; 'address' and 'customer' (address is a field inside
                    &gt; the customer). So are You telling me that I got to
                    &gt; add 'customerId' inside the address (for one-to-many)
                    &gt; because current version is not able of doing so. And
                    &gt; if I do this how will I tell the persistence engine
                    &gt; that field is a foreign key that points to the
                    &gt; customer table ID.

                    No, the relationship code works fine; it is unknown primary keys that don't work. When you use an unknown primary key you leave the definition and implementation of the primary key up to the container. Generally this is implemented using an sequence table. I just haven't implemented it yet.

                    &gt; If all this things are well explained inside
                    &gt; "JBossCMP Workbook", just tell me, but also I would
                    &gt; appriciated a short answer.

                    It is all explained in the workbook.

                    • 7. Re: Do we have to use 'jbosscmp-jdbc.xml' for O-R mapping
                      koval

                      Thanks Dain,

                      for your help (and patience). I already downloaded the workbook.


                      It's amazing that you guys find the way to answer most of the questions having such a huge number of downloads, great service.