1 2 Previous Next 27 Replies Latest reply on Apr 4, 2012 11:27 AM by Noa Drach

    AS7 has wrong behavior for @GeneratedValue(AUTO)

    Ove Ranheim Novice

      I'm a bit surprised by how AS7.0.0.Final and AS7.1.0-SNAPSHOT (build #1477) generates IDs for @GeneratedValue(strategy = GenerationType.AUTO) on persistent entities. It actually increments IDs accross tables/entities.

       

      Example using ExampleDS and standard standalone configuration:

       

       

      @MappedSuperclass
      @Veto
      public abstract class AbstractEntity implements Serializable {
      
           protected Long id;     
      
           @Id
           @GeneratedValue(strategy = GenerationType.AUTO)
           @Column(name="ID")
           public Long getId() {
                return id;
           }
           
           public void setId(Long id) {
                this.id = id;
           }
      }
      
      

       

       

       

      @Entity
      @Veto
      public class Part extends AbstractEntity {
      }
      

       

       

       

      @Entity
      @Veto
      public class Piece extends AbstractEntity {
      }
      

       

       

      When I persist one instance of Part and then an instance of Piece.

       

      Part will be given ID=1

      Piece will be given ID=2

       

      This must be wrong as both entities should have an ID of 1 for each initial instance.

       

      I could not find any bug report on this, so I start suspect I'm doing something wrong here.

        1 2 Previous Next