Hi,
I use
Jboss version 3.2.3 and Hypersonic database as the development database. I am trying to create an entry in database QuoteInfo (which only has 2 fields : QuoteID and Desc). quoteid is the primary key column. I want the DB to generate the key for me. The Beans are deployed fine and this is the error from the console when my program calls the create method:
2004-05-11 19:11:01,865 DEBUG [org.apache.struts.action.RequestProcessor] Creating new Action instance
2004-05-11 19:11:01,885 INFO [STDOUT] before calling method create
2004-05-11 19:11:01,885 INFO [STDOUT] inside create method
2004-05-11 19:11:01,885 INFO [STDOUT] inside create method 2
2004-05-11 19:11:01,895 ERROR [org.jboss.ejb.plugins.LogInterceptor] RuntimeException:
java.lang.NullPointerException
at org.jboss.ejb.plugins.cmp.jdbc.JDBCIdentityColumnCreateCommand.executeInsert(JDBCIdentityColumnCreateCommand.java:62)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInsert(JDBCAbstractCreateCommand.java:287)
TIA
-Vili
$$ -- $$
This is the method that calls the create method:
public boolean quoteCreate() {
boolean authenticate= false;
try{
System.out.println("before calling method create");
quoteInfoLocal = quoteInfoLocalHome.create();
System.out.println("after calling method create");
authenticate= true;
return authenticate;
} catch (CreateException e){
System.out.println("Can't create quote");
return authenticate;
}
}
$$ -- $$
public interface EntityQuoteLocalHome extends EJBLocalHome {
public EntityQuoteLocal create() throws CreateException;
public EntityQuoteLocal findByPrimaryKey(Integer quoteID) throws FinderException;
}
$$ -- $$
EntityQuoteBean:
public abstract class EntityQuoteBean implements EntityBean {
private EntityContext context;
public abstract Integer getQuoteID();
public abstract void setQuoteID(Integer quoteID);
public abstract
String getDesc();
public abstract void setDesc(String desc);
public Integer ejbCreate() throws CreateException {
System.out.println("inside create method");
setDesc("Test");
System.out.println("inside create method 2");
return null;
}
public void ejbPostCreate(){
System.out.println("This is where I should get the generated PK???");
}
...
}
$$ -- $$
A portion of jbosscmp-jdbc:
<entity>
<ejb-name>QuoteBean</ejb-name>
<table-name>QuoteInfo</table-name>
<cmp-field>
<field-name>desc</field-name>
</cmp-field>
<cmp-field>
<field-name>quoteID</field-name>
<column-name>quoteID</column-name>
<not-null/>
<auto-increment/>
</cmp-field>
<entity-command name="hsqldb-fetch-key"/>
</entity>
</enterprise-beans>
<entity-commands>
<!-- retrieves generated key of the record inserted into hsql db -->
<entity-command name="hsqldb-fetch-key"
class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCHsqldbCreateCommand">
<attribute name="pk-sql">CALL IDENTITY()</attribute>
</entity-command>
</entity-commands>
$$ -- $$
Hypersonic database script:
create table
quoteinfo(quoteid identity, desc varchar(50));