Results 1 to 2 of 2
  1. #1
    kriskras is offline Member
    Join Date
    May 2008
    Posts
    1
    Rep Power
    0

    Default Bean data not mapped to database

    Hi all,

    I am building a web application that calls entity beans through a session bean. For example:

    Java Code:
    	try {
    		  	a1 = home.create(new Date().getTime(), 1, leverancierID, productID, hoeveelheid);
    	 	} catch (Exception e) {
    			System.err.println("Kan order niet aanmaken: " + e);
    			System.exit(2);
    		}
    I actually never get an error, everything compiles fine but nonetheless the data never gets inserted into the HSQL database tables. So, I thought something might be wrong with the descriptors. I checked and re-checked everything but the data does not get mapped to the database. It simply doesn't get inserted. It's a mystery.

    Here are my descriptors (I actually have three beans but none insert data. Hereby I give an example for the bean called OrderBean)

    XML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
    		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    		 http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
    		 version="2.1">
    
      <description>Deployment descriptor for the bestellingsadministratie JOnAS example</description>
      <display-name>bestellingsadministratie example</display-name>
      <enterprise-beans>
    
        <entity>
          <description>Deployment descriptor for the Order bean with CMP2</description>
          <ejb-name>OrderBean</ejb-name>
          <home>org.colruyt.bestellingsadministratie.beans.order.OrderHome</home>
          <remote>org.colruyt.bestellingsadministratie.beans.order.Order</remote>
    	  <local-home>org.colruyt.bestellingsadministratie.beans.order.OrderLocalHome</local-home>
          <local>org.colruyt.bestellingsadministratie.beans.order.OrderLocal</local>
          <ejb-class>org.colruyt.bestellingsadministratie.beans.order.OrderBean</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>java.lang.Integer</prim-key-class>
          <reentrant>false</reentrant>
          <cmp-version>2.x</cmp-version>
          <abstract-schema-name>order</abstract-schema-name>
          <cmp-field>
            <field-name>orderid</field-name>
          </cmp-field>
          <cmp-field>
            <field-name>orderdatum</field-name>
          </cmp-field>
          <cmp-field>
            <field-name>orderstatusid</field-name>
          </cmp-field>
          <cmp-field>
            <field-name>leverancierid</field-name>
          </cmp-field>
          <cmp-field>
            <field-name>productid</field-name>
          </cmp-field>
          <cmp-field>
            <field-name>besteldehoeveelheid</field-name>
          </cmp-field>
          <primkey-field>orderid</primkey-field>
          <query>
            <query-method>
              <method-name>findByNumber</method-name>
              <method-params>
                  <method-param>int</method-param>
              </method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM order o WHERE o.orderid = ?1</ejb-ql>
          </query>
          <query>
            <query-method>
              <method-name>findAllOrders</method-name>
              <method-params/>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM order o</ejb-ql>
          </query>
        </entity>
    	<session>
          <ejb-name>BestellingsadministratieSession</ejb-name>
          <home>org.colruyt.bestellingsadministratie.beans.session.BestellingsadministratieSessionHome</home>
          <remote>org.colruyt.bestellingsadministratie.beans.session.BestellingsadministratieSession</remote>
          <ejb-class>org.colruyt.bestellingsadministratie.beans.session.BestellingsadministratieSessionBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
        </session>
    	
      </enterprise-beans>
      <assembly-descriptor>
     
    	
        <container-transaction>
          <method>
            <ejb-name>OrderBean</ejb-name>
            <method-name>*</method-name>
          </method>
         <method>
            <ejb-name>LeverancierBean</ejb-name>
            <method-name>*</method-name>
          </method>
    	  <method>
            <ejb-name>ProductBean</ejb-name>
            <method-name>*</method-name>
          </method>
    	  <method>
    		<ejb-name>BestellingsadministratieSession</ejb-name>
    		<method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>
        </container-transaction>
    
      </assembly-descriptor>
    </ejb-jar>
    And my web application server specific (I use JOnAS) descriptor

    XML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    
    <jonas-ejb-jar xmlns="http://www.objectweb.org/jonas/ns"
    	      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	      xsi:schemaLocation="http://www.objectweb.org/jonas/ns
    		  http://www.objectweb.org/jonas/ns/jonas-ejb-jar_4_0.xsd" >
      
      
      <jonas-entity>
        <ejb-name>OrderBean</ejb-name>
        <jndi-name>OrderBean</jndi-name>
        <jdbc-mapping>
          <jndi-name>jdbc_1</jndi-name>
        </jdbc-mapping>
      </jonas-entity> 
      <jonas-session>
        <ejb-name>BestellingsadministratieSession</ejb-name>
        <jndi-name>BestellingsadministratieSessionHome</jndi-name>
      </jonas-session>
      
    </jonas-ejb-jar>
    One last thing I'd like to mention: I based my code upon an example and all my fields in the DB table end with "_". If this is really a problem, why are there no errors then?

    I really don't know what I should do. Could you guys please help me?
    Thank you so much!

  2. #2
    linuxswan is offline Member
    Join Date
    Mar 2008
    Posts
    28
    Rep Power
    0

    Default

    What about the connection pool i.e for the database have you created the Datasource. i.e which you mentioned in the jonas-ejb-jar.xml

    <jdbc-mapping>
    <jndi-name>jdbc_1</jndi-name>
    </jdbc-mapping>


    what is the status of this --- jdbc_1

    have you created the connection pool or this is from the odbc settings.

    if you are creating the connection pool you can try one more rdbms xml file.

Similar Threads

  1. Database Bean Generator 2.1.4
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 04-15-2008, 07:55 PM
  2. Replies: 0
    Last Post: 04-07-2008, 08:54 PM
  3. [SOLVED] Getting Data from a database
    By AJG in forum New To Java
    Replies: 8
    Last Post: 04-04-2008, 01:52 PM
  4. How to query data from database using SSL
    By mano in forum New To Java
    Replies: 0
    Last Post: 08-02-2007, 06:30 PM
  5. Database Bean Generator 2.1.2
    By JavaBean in forum Java Software
    Replies: 1
    Last Post: 07-17-2007, 01:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •