jboss 3.0.5 tries to insert null when create is called
rlopez Mar 3, 2004 8:43 PMI have an entity bean built with xdoclet, when I use the create() method to insert a row it throws the following exception
20:42:44,877 ERROR [ReportStore] Could not create entity
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=322, COLNO=0" is not allowed. SQLSTATE=23502
This is the definition of my bean
/*
* Copyright (c) 2002 Aquitec Inc.
* All rights reserved.
*/
package com.aquitecintl.ewms.warehouse.beans;
import javax.ejb.EntityBean;
import javax.ejb.EJBException;
import javax.ejb.EntityContext;
import com.aquitecintl.ewms.warehouse.common.DomainVO;
import com.aquitecintl.ewms.warehouse.common.MaintainableDomainVO;
import com.aquitecintl.ewms.warehouse.interfaces.ReportStoreLocal;
import com.aquitecintl.ewms.warehouse.interfaces.ReportStoreVO;
import com.aquitecintl.ewms.warehouse.interfaces.ReportStorePK;
/**
*
* @ejb:bean name="ReportStore"
* type="CMP"
* jndi-name="ewms/warehouse/ReportStore"
* local-jndi-name="ewms/warehouse/ReportStoreLocal"
* use-soft-locking="false"
* view-type="both"
*
* @ejb:home local-extends="org.x.engine.search.Searchable"
* @ejb:transaction type="Required"
* @ejb:pk package="com.aquitecintl.ewms.warehouse.interfaces"
*
* @ejb:finder signature="java.util.Collection findAll()"
* @ejb:data-object package="com.aquitecintl.ewms.warehouse.interfaces"
* extends="com.aquitecintl.ewms.warehouse.common.DomainVO"
* equals="true"
*
* @ejb:util generate="physical"
*
* @ejb:home local-extends="org.x.engine.search.Searchable"
*
* @jboss:table-name "SCWT_RPT_STORE"
* @jboss:create-table "true"
* @jboss:remove-table "false"
* @jboss:tuned-updates "true"
* @jboss:read-only "false"
*/
public abstract class ReportStoreBean extends DomainEntity
implements EntityBean
{
private EntityContext ctx;
public void setEntityContext(EntityContext val) {
this.ctx = val;
}
public void unsetEntityContext() {
ctx = null;
}
/**
*
* @ejb:interface-method
*/
public abstract ReportStoreVO getData();
/**
* @ejb:home-method view-type="local"
*/
public Object ejbHomeResolveObject(Class type, Object obj) {
return ((ReportStoreLocal) obj).getData();
}
/**
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name CPY_CD
* @ejb:pk-field
*/
public abstract String getCompanyCode();
public abstract void setCompanyCode(String val);
/**
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name FACL
* @ewms:char
* @ejb:pk-field
*/
public abstract String getFacility();
public abstract void setFacility(String val);
/**
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name WHSE
* @ejb:pk-field
*/
public abstract String getWarehouse();
public abstract void setWarehouse(String val);
/**
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name REPORT_PROGRAM
*/
public abstract String getReportId();
public abstract void setReportId(String val);
/**
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name REPORT_USER
*/
public abstract String getRecipient();
public abstract void setRecipient(String val);
/**
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name REPORT_FILENAME
* @ejb:pk-field
*/
public abstract String getFileName();
public abstract void setFileName(String val);
/**
*
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name REPORT_BODY
*/
public abstract Object getBody();
public abstract void setBody(Object val);
/**
* @ejb:persistent-field
* @ejb:interface-method
* @jboss:column-name TYPE
*/
public abstract String getType();
public abstract void setType(String val);
}
The code Im using to insert a row is
/** @todo Add code to store bytes into EJB */
try
{
System.out.println("Storing ejb");
ReportStoreVO reportStore = new ReportStoreVO();
System.out.println("assigning cpy-cd=["+rpt_cpy_cd+"]");
reportStore.setCompanyCode(rpt_cpy_cd);
System.out.println("assigning facl=["+rpt_facl+"]");
reportStore.setFacility(rpt_facl);
System.out.println("assigning whse=["+rpt_whse+"]");
reportStore.setWarehouse(rpt_whse);
System.out.println("assigning report-user=["+rpt_user+"]");
reportStore.setRecipient(rpt_user);
System.out.println("assigning report-name=["+rpt_reportName+"]");
reportStore.setReportId(rpt_reportName);
System.out.println("assigning report-filename=["+rpt_fileName+"]");
reportStore.setFileName(rpt_fileName);
System.out.println("assigning type=["+rpt_type+"]");
reportStore.setType(rpt_type);
System.out.println("assigning update-serial=[1]");
reportStore.setUpdateSerial(1l);
reportStore.setBody(report);
System.out.println(reportStore.toString());
ReportStoreLocalHome rslh = ReportStoreUtil.getLocalHome();
rslh.create(reportStore);
}
catch(Exception e)
{
System.out.println("EJB threw exception");
e.printStackTrace();
throw (JRException)(new JRException(e.getMessage())).fillInStackTrace();
}
The output of the server.log is
20:42:44,855 INFO [STDOUT] Storing ejb
20:42:44,857 INFO [STDOUT] assigning cpy-cd=[DARYL]
20:42:44,857 INFO [STDOUT] assigning facl=[3]
20:42:44,857 INFO [STDOUT] assigning whse=[01]
20:42:44,857 INFO [STDOUT] assigning report-user=[D]
20:42:44,857 INFO [STDOUT] assigning report-name=[PS14S_EN]
20:42:44,858 INFO [STDOUT] assigning report-filename=[D.PS14S_EN.20040303.20424064]
20:42:44,858 INFO [STDOUT] assigning type=[PDF]
20:42:44,858 INFO [STDOUT] assigning update-serial=[1]
20:42:44,858 INFO [STDOUT] com.aquitecintl.ewms.warehouse.interfaces.ReportStoreVO {
companyCode=[DARYL]
facility=[3]
warehouse=[01]
reportId=[PS14S_EN]
recipient=[D]
fileName=[D.PS14S_EN.20040303.20424064]
body=[[B@6aa50f]
type=[PDF]
updateSerial=[1]
}
20:42:44,877 ERROR [ReportStore] Could not create entity
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=322, COLNO=0" is not allowed. SQLSTATE=23502
at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.check_return_code(Unknown Source)
...
The column reference in the DB2 exception is CPY_CD, which is mapped to companyCode
The only mod I had to do to DB2 was to change the stanadardjboss-cmp.xml mapping of DB2's BLOB to be VARBINARY rather than JAVA_OBJECT
Any help is greatly appreciated, Ive been spinning my whells on this for 3 days.
Thanks you.