7 Replies Latest reply on Mar 5, 2002 10:45 AM by mfortin

    CMP bean not inserting into oracle db

    mfortin

      I've had no trouble creating a database connection and accessing existing beans in the database but when I try to call a create method on the bean below, I do not get any errors but my bean is never inserted into the database. Subsequent calls to create give me an "CreationException that id already exists" but if I restart jboss they're lost. The class seems to be in memory but the bean is never commited. Is there some commit flag I need to set that I don't know about? I've spent entirely to much time on this and would greatly appreciate any help.

      jaws.xml
      --------------

      java:/OracleDS
      <type-mapping>Oracle8</type-mapping>
      true

      <enterprise-beans>

      <ejb-name>fullAccessMedical/Employee</ejb-name>

      <cmp-field>
      <field-name>email</field-name>
      <column-name>email</column-name>
      <sql-type>VARCHAR2(48)</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>first_name</column-name>
      <sql-type>VARCHAR2(30)</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>keyval</field-name>
      <column-name>keyval</column-name>
      <sql-type>NUMBER(16)</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>last_name</column-name>
      <sql-type>VARCHAR2(30)</sql-type>

      </cmp-field>
      etc....
      <table-name>employee</table-name>
      <create-table>false</create-table>
      <remove-table>false</remove-table>



      ejb-jar.xml
      ----------------



      <ejb-name>fullAccessMedical/Employee</ejb-name>

      com.fullAccessMedical.user.interfaces.EmployeeHome
      com.fullAccessMedical.user.interfaces.Employee

      <ejb-class>com.fullAccessMedical.user.ejb.EmployeeCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>1.x</cmp-version>
      <abstract-schema-name>fullAccessMedical/Employee</abstract-schema-name>
      <cmp-field>
      <![CDATA[the primary key in the database]]>
      <field-name>keyval</field-name>
      </cmp-field>
      <cmp-field>
      <![CDATA[employees first name]]>
      <field-name>firstName</field-name>
      </cmp-field>
      <cmp-field>
      <![CDATA[employees last Nme]]>
      <field-name>lastName</field-name>
      </cmp-field>
      ...etc...
      <primkey-field>keyval</primkey-field>



      jboss.jcml
      --------------------
      <!-- oracle data source for our database -->

      OracleDS
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
      jdbc:oracle:thin:@172.22.1.1:1521:ddb
      user
      pwd
      true




      thanks Michael Fortin

        • 1. Re: CMP bean not inserting into oracle db
          dsundstrom

          change

          <type-mapping>Oracle8</type-mapping>

          to

          <datasource-mapping>Oracle8</datasource-mapping>

          • 2. Re: CMP bean not inserting into oracle db
            mfortin

            Thanks for the quick reply, but that didn't make any difference. What else could I be missing?

            • 3. Re: CMP bean not inserting into oracle db
              mfortin

              I should mention that I'm using jboss 2.4.4 and oracle 8.1.7

              • 4. Re: CMP bean not inserting into oracle db
                dsundstrom

                oops, that change was for JBossCMP in JBoss3.0.

                I don't relly know 2.4 that well.

                • 5. Re: CMP bean not inserting into oracle db
                  mfortin

                  I still haven't figured it out. Could some one explain to me what "no transaction right now" in the log output could mean. It seems to be the heart of my problem. I get that line every time I try to create a new bean. thanks...

                  [INFO,JdbcProvider] Starting
                  [INFO,JdbcProvider] Started
                  [INFO,FamDS] Starting
                  [INFO,FamDS] XA Connection pool FamDS bound to java:/FamDS
                  [INFO,FamDS] org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl created new Connection (oracle.jdbc.driver.OracleConnection
                  ) with XAResource org.jboss.pool.jdbc.xa.wrapper.XAResourceImpl and XAConnection org.jboss.pool.jdbc.xa.wrapper.XAConnec
                  tionImpl.
                  [INFO,FamDS] No transaction right now.
                  [INFO,FamDS] Started

                  • 6. Re: CMP bean not inserting into oracle db
                    earlgrey

                    Does the inserting method run within a tx? Obviously, the entity creation is not committed. I always use a session facade in order to create new entity instances. The method call to the session bean would be marked as tx-required.

                    (You can also mark the entity-create method as tx-required - although, I read somewhere that this is not spec compliant(anyone?)).

                    I recommend using xdoclet for ejb generation - this is very convenient (in terms of ejb declarations).

                    Lars

                    • 7. Re: CMP bean not inserting into oracle db
                      mfortin

                      thanks earlgrey and dsundstrom,

                      I am using xdoclet and changing the transaction to required did the trick. I was under the impression that supports was suffient. I'll chalk it off to a beginners learning experience.

                      once again thanks thanks thanks.