1 2 3 Previous Next 32 Replies Latest reply on Jan 27, 2003 6:30 AM by milasx Go to original post
      • 30. Re: NEW FEATURE: new ways to create entity beans
        h2o_polo

        I was trying to get Informix serial field to work, so I took your class (org.jboss.ejb.plugins.cmp.jdbc.mysql.JDBCMySQLCreateCommand) and modified it a bit to get the serial (sequence/auto-generated) number out of it after the insert is done.

        if you are interested in seeing how it's done in Informix
        here is the code.

        the code is pretty much the same except for the code where you retrieve the sequece number for MySQL:

        // cast to the wrapped statement
        org.jboss.ejb.plugins.cmp.jdbc.WrappedStatement ws =
        (org.jboss.ejb.plugins.cmp.jdbc.WrappedStatement) ps;
        // fetch underlying statement and cast it to Informix native
        com.informix.jdbc.IfxStatement ifxStmt =
        (com.informix.jdbc.IfxStatement) ws.getUnderlyingStatement();

        int serialValue = ifxStmt.getSerial ();
        Object pk = null;
        if (serialValue != 0) {
        pk = new Integer (serialValue);
        }

        if( pk == null ) {
        throw new Exception( "Primary key isn't generated." );
        }

        log.debug ("Generated serial PK value is: " + pk);


        if you need to see it in full just send me e-mail and I will reply with the file.

        Alex.

        • 31. Re: NEW FEATURE: new ways to create entity beans
          milasx

          Is all this stuff supported by XDoclet?

          Many thanks!

          Simone

          • 32. Re: NEW FEATURE: new ways to create entity beans
            milasx

            Do you have one for Sybase Identity columns?

            Many thanks!

            Simone

            1 2 3 Previous Next