Hello!
        I am using JBoss 3.2.3 with Postgres 7.3.4. I am trying to generate primary
keys automatically. When I use the following entity-command, with the
sequence previously created, everything works fine:

* @jboss.entity-command
*        name="pk-sql"
* @jboss.entity-command-attribute
*        name="pk-sql"
*        value="SELECT nextval('TEST_SEQ')"


CMP declaration:

* @ejb:persistent-field
* @ejb:pk-field
*
* @jboss:column-name name="TEST_ID"
* @jboss:persistence auto-increment="true"



When I tried with the following entity-command:
* @jboss:entity-command
 *          name="postgresql-fetch-seq"
 *
class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCPostgreSQLCreateCommand"
 * @jboss:entity-command-attribute
 *          name="sequence"
 *          value="TEST_SEQ"


I got the following exception:

2004-02-05 17:48:20,132 ERROR
[org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCPostgreSQLCreateCommand.Test]
Could not create entity
java.sql.SQLException: ERROR:  ExecInsert: Fail to add null value in not
null attribute test_id

        at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection
.java:505)


Why is this happening?

Is there any way to have incremental primary keys without the explicit usage
of sequences? If yes, how?
What can I win with a unknown-pk declaration?
Is there any way to automatically create the sequences if they don't still
exist (something like: @jboss:create-table create="true")?


Thanks in advance,
        Victor Batista





-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to