"demmahom" wrote:
Hallo evryone , I have a probelm with my J2EE Application and JBOSS
the problem is i use xdochlet to generate the id for my EJB ,
wenn i try to create an EJB JbOSS throw an Exception:
23:44:35,132 ERROR [ProjectManagerBean] Could not create entity:java.sql.SQLExce
ption: Try to insert null into a non-nullable column: column: ID table: PROJECT
in statement [INSERT INTO PROJECT (name, url) VALUES (?, ?)]
here is my EJB:
/*
* Created on 31.12.2004
*
*/
package de.tuberlin.ivs.vspj.pvt.entity.ejb;
import java.rmi.RemoteException;
import java.util.Collection;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
import de.tuberlin.ivs.vspj.pvt.entity.Project;
/**
* A ProjectBean is an CMP-implementation of the <code>Project</code>-interface.
*
* @author Mohamed Osman
* @version $Revision: 1.1.1.1 $
*
* @ejb.bean name = "Project"
* display-name = "TopicProject EJB"
* description = "Represents a Project"
* type = "CMP"
* cmp-version = "2.x"
* view-type = "local"
* local-jndi-name = "ejb/ProjectLocal"
* local-business-interface = "de.tuberlin.ivs.vspj.pvt.entity.Project"
* primkey-field = "id"
*
*
* @ejb.finder signature="java.util.Collection findAll()"
* unchecked="true"
* @ejb.value-object
* implements = "de.tuberlin.ivs.vspj.pvt.entity.Project"
*
*/
public abstract class ProjectBean implements EntityBean, Project {
/**
* Get the id of the project.
*
* @ejb.pk-field
* @ejb.persistence
* @ejb.interface-method
* @jboss.persistence auto-increment = "true"
* @return the id of the project
*/
public abstract Integer getId();
/**
* Set the id of the project.
*
* @param id the id of the project
*/
public abstract void setId(Integer id);
/**
* Get the name of this project.
*
* @ejb.persistence
* @ejb.interface-method
* @return the name of the project
*/
public abstract String getName();
/**
* Set the name of the project.
*
* @ejb.interface-method
* @param name the name of the project
*/
public abstract void setName(String name);
/**
* Get the url of the project.
*
* @ejb.persistence
* @ejb.interface-method
* @return the url of this project
*/
public abstract String getUrl();
/**
* Set the url of the project.
*
* @ejb.interface-method
* @param url The url of the project.
*/
public abstract void setUrl(String url);
/* *//**
*
* Get the publications of the project with the given id.
* @ejb.interface-method
* @ejb.relation name = "ProjPubs"
* cascade-delete = "no"
* role-name = "Project-has-Publications"
* target-ejb = "Publication"
* @jboss.relation-table create-table = "true"
* table-name = "ProjPubs"
* @jboss.relation fk-column = "id"
* related-pk-field = "id"
*
* @param id the id of the project.
* @return the publications of the project with the given id.
*//*
public abstract Collection getPublications() ;*/
/**
* Creates an instance of a new Project.
* Returns the primary key of the new entity or null if cmp is used.
*
* @ejb.create-method
* @param name the name of the project.
* @param url the url of the project.
* @return The local Interface of the ejb.
* @throws CreateException If server failed to create entity.
*/
public Integer ejbCreate(String name, String url) throws CreateException {
setName(name);
setUrl(url);
return null;
}
/**
* Does nothing.
* @param name The name of the project.
* @param url The url of the project.
* @throws CreateException If server failed to create the entity.
*/
public void ejbPostCreate(String name, String url)
throws CreateException {
}
/**
* Sets the EntityContext.
* @param ctx The EntityContext set by the server.
* @throws EJBException If a general error occurs.
* @throws RemoteException If an Error occurs during remote method invocation.
*/
public void setEntityContext(EntityContext ctx) throws EJBException,RemoteException {}
/**
* Unsets the EntityContext.
* @throws EJBException If a general error occurs.
* @throws RemoteException If an Error occurs during remote method invocation.
*/
public void unsetEntityContext() throws EJBException, RemoteException {}
/**
* Removes the project from persistent storage.
* @throws RemoveException If an error occurs during removal of the project.
* @throws EJBException If a general error occurs.
* @throws RemoteException If an Error occurs during remote method invocation.
*/
public void ejbRemove() throws RemoveException, EJBException,RemoteException {}
/**
* @see javax.ejb.EntityBean#ejbActivate()
*/
public void ejbActivate() throws EJBException, RemoteException { }
/**
* @see javax.ejb.EntityBean#ejbPassivate()
*/
public void ejbPassivate() throws EJBException, RemoteException { }
/**
* @see javax.ejb.EntityBean#ejbLoad()
*/
public void ejbLoad() throws EJBException, RemoteException { }
/**
* @see javax.ejb.EntityBean#ejbStore()
*/
public void ejbStore() throws EJBException, RemoteException { }
}
and here is the standardjbosscmp-jdbc.xml :
<jbosscmp-jdbc>
<defaults>
<datasource>java:/DefaultDS</datasource>
<!-- optional since 4.0 <datasource-mapping>Hypersonic SQL</datasource-mapping> -->
<create-table>true</create-table>
<remove-table>false</remove-table>
<read-only>false</read-only>
<read-time-out>300000</read-time-out>
<row-locking>false</row-locking>
<pk-constraint>true</pk-constraint>
<fk-constraint>false</fk-constraint>
<preferred-relation-mapping>foreign-key</preferred-relation-mapping>
<read-ahead>
<strategy>on-load</strategy>
<page-size>1000</page-size>
<eager-load-group>*</eager-load-group>
</read-ahead>
<list-cache-max>1000</list-cache-max>
<clean-read-ahead-on-load>false</clean-read-ahead-on-load>
<unknown-pk>
<key-generator-factory>UUIDKeyGeneratorFactory</key-generator-factory>
<unknown-pk-class>java.lang.String</unknown-pk-class>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(32)</sql-type>
</unknown-pk>
<entity-command name="hsqldb-fetch-key"/>
<ql-compiler>org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLCompiler</ql-compiler>
</defaults>
...
please i need your help.