1 Reply Latest reply on Sep 26, 2006 3:29 PM by lafr

    can i use oracle sequence for primary key in cmp ejb?help me

    wxjpxp

      Oracle's sequence is very useful,we oftenly use it for most of my tables' primary key field,don't you ?

      in my cmp ejb,the bean class name is "beana",and it's mapping table's name within oracle is "beana",thire primary field is "id". I also want use sequence's value for their primary key.in fact ,if i do not use sequence ,it will be very unconvient to operate my data in sqlplus or plsql.

      how can i tell ejb container to use oracle's sequence when it creat every bean instance(mapping into new oracle record).

        • 1. Re: can i use oracle sequence for primary key in cmp ejb?hel
          lafr

          Using XDoclet you have to put
          * @jboss.entity-command name="oracle-sequence"
          * @jboss.entity-command-attribute name="sequence" value="Name of the Sequence to use"
          at class level.

          This leads to

          <entity-command name="oracle-sequence">
           <attribute name="sequence">Name of the Sequence to use</attribute>
          </entity-command>
          

          in jbosscmp-jdbc.xml as child of the matching entity element.