Hi all,
I am building a web application that calls entity beans through a session bean. For example:
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 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 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!