[jboss-user] [EJB 3.0] - Re: Use oracle to generate the id with the orcle seqence tab

penguine do-not-reply at jboss.com
Tue Sep 18 10:32:23 EDT 2007


Thank you for your help.

But it doesn´t work. I need the returning pk after commit. In your way oracle is setting a new pk in my table
Because we use a trigger which creates a new pk by oracle when I do table.persist(). I can´t change the mechnism because it is an old infrastructur. In ejb2.x we have our own oraclecreatecommand

  | public class OracleCreateCommand  extends JDBCIdentityColumnCreateCommand
  | {
  |   protected void initInsertSQL()
  |   {
  |      pkIndex = 1 + insertFields.length;
  |      jdbcType = pkField.getJDBCType().getJDBCTypes()[0];
  | 
  |      StringBuffer sql = new StringBuffer();
  |      sql.append("{call INSERT INTO ").append(entity.getTableName());
  |      sql.append(" (");
  |      SQLUtil.getColumnNamesClause(insertFields, sql);
  |      sql.append(")");
  |      sql.append(" VALUES (");
  |      SQLUtil.getValuesClause(insertFields, sql);
  |      sql.append(")");
  |      sql.append(" RETURNING ");
  |      SQLUtil.getColumnNamesClause(pkField, sql)
  |         .append(" INTO ? }");
  |      insertSQL = sql.toString();
  |      if (debug) {
  |         log.debug("Insert Entity SQL: " + insertSQL);
  |      }
  |   }
  | 
  | 

This is returning the created pk form oracle after persist().
And know in JPA a need a similar mechanism.
I think the 

  |  @GenericGenerator(name="select", strategy="select",
  |     		parameters = 
  |     		{
  |     		  @Parameter(name = "key", value = "idstoerung")
  |             })
  | 
Is the right way. but is seems there is a bug in jboss, isn´t it?
Is there no one who is using a oracle trigger for generating the pk?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085543#4085543

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085543




More information about the jboss-user mailing list