Hi!
I have the following problem.
I create the following table (with PostgreSQL) :
CREATE TABLE "project" (
"idproject" SERIAL,
"projectName" varchar(64),
"budget" int4,
"start" date,
"end" date,
CONSTRAINT "project_pkey" PRIMARY KEY ("idproject")
);
In this way the primary key idproject is auto incrementing.
I'm using an BMP entity bean: as you know, the ejbCreate method must return
the primary key.
My ejbCreate method calls insertRow, a function which insert the newly
created bean into the database.
In insertRow i don't need to specify the value of idproject 'cause it's
generated by the DB during the insertion.
The code is:
private Integer insertRow (String projectName,int budget,java.sql.Date
start,java.sql.Date end) throws SQLException {
System.out.println(" insertRow() called ");
String insertStatement =
"insert into project
(\"projectName\",\"budget\",\"start\",\"end\") values ( ? , ? , ? , ? )";
..............................
prepStmt.executeUpdate();
prepStmt.close();
...............................................
How may i obtain the value of the primary key generated by PostgreSQL ( i
need to obtain this value because i have to return the primary key value) ?
I thougth I migth obtain it with a simple select query, but in this way i'm
not sure the value I obtain is exactly the one needed (by definition, only
the primary key identifies univokely a record).
Any suggestion? How can i manage this situation? Do you think I have do
change my program?
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user