Mapping CMP field and PK (DB sequence) column
morenito9000 Jan 22, 2007 1:29 PMHi all,
when I try to create a CMP Entity Bean I get an error:
null value in column xmoid .... could not create entity bean.
xmoid is the PK of the table info_allegato.
Values assigned to xmoid are retrieved from a db sequence (info_allegato_xmoid_seq).
I'm using JBoss 3.2.3, Postgresql 7.4 according to EJB 2.1 specs
(I'm not up-to-date :-)).
I tried different combinations of xdoclet tags inside InfoAllegatoEntityBean.java class with the same bad result :-(
I report java code (and xdoclet tags) related to CMP field
that maps PK of DB table.
* @ejb.bean name = "InfoAllegatoEntity" * local-jndi-name = "ejb/InfoAllegatoEntity" * type = "CMP" * display-name = "InfoAllegato Entity Bean" * description = "Entity CMP..." * view-type = "local" * cmp-version = "2.x" * primkey-field = "xmoid" * * @ejb.persistence table-name = "info_allegato" * * @jboss.persistence table-name = "info_allegato" * * @ejb.pk class="java.lang.Integer" * generate="false" * * @jboss.unknown-pk class = "java.lang.Integer" * column-name = "xmoid" * jdbc-type = "INTEGER" * sql-type = "INTEGER" * auto-increment = "true" * * @jboss.entity-command name = "postgresql-fetch-seq" * class = "org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCPostgreSQLCreateCommand" * /** * @ejb.create-method * @exception = "javax.ejb.CreateException" */ public Integer ejbCreate(String prodotto, Integer idMalf) throws javax.ejb.CreateException { /* I don't set pk field xmoid */ setProdotto(prodotto); setIdMalf(idMalf); return null; } /** * * @exception = "javax.ejb.CreateException" */ public void ejbPostCreate(String prodotto, Integer idMalf) throws javax.ejb.CreateException { } /** * @ejb.persistence column-name = "xmoid" * @ejb.pk-field * * * @jboss.column-name = "xmoid" * @jboss.persistence not-null = "true" * @jboss.persistence auto-increment = "true" * * @return */ public abstract Integer getXmoid(); /** * @param xmoid */ public abstract void setXmoid(Integer xmoid);
Could anyone tell me if something is wrong in this code ?
Deploy of Entity Bean is ok but when I call create() method
of Entity Bean InfoAllegato I get the error.
Any help is very very appreciated.
Thanks in advance.
Moreno