1 Reply Latest reply on Apr 2, 2007 6:12 PM by fhh

    Question about sequences and entity ejbs 3.0

    balteo

      Hello,

      I have simplified my problem as follows: I have a three-field table as follows:

      pk key name
      1 1 johm (this is an insert)
      2 1 john (this is an update)
      3 2 Pat (this is an insert)
      

      The requirement for one table cannot be changed.

      I have a auto generated identity or a sequence for pk.

      My question relates to key. As you have noticed key is not unique.

      How can I retrieve the value used for the pk for use by key field when I do an insert bearing in mind I currently use an auto generated identity (with DB2). Do I need a sequence? Please advise me on the best strategy.

      Please tell me what code I need on the entity bean side (the one that is persisted) and on the session bean side (the one that persists the entity).

      Please help!!!

      Thanks in advance,

      Julien Martin.

        • 1. Re: Question about sequences and entity ejbs 3.0

          Well on my database primary keys are usually not changed by an update. So your example would look like this:


          pk key name
          1 1 johm (this is an insert)
          1 1 john (this is an update)
          2 2 Pat (this is an insert)


          If you want a column that increments on updates look at the @version annotation or use a trigger.

          Regards

          Felix