0 Replies Latest reply on Sep 19, 2006 3:35 PM by stephan opitz

    JPA persistence primary key loose

    stephan opitz Newbie

      i make a customer object persistent

      // create a new customer
      customer = new Customers();

      // fill with data

      // make persistent

      after persists i know the new id is in db 11, but if i log its 0
      why it won*t set automattically
      log.info("customer ID: " + customer.getCustomersId());

      entity has this:

      @Table(name = "customers")
      public class Customers implements Serializable {

      // ------------------------------------------------------ Manifest Constants

      private static final long serialVersionUID = 5L;

      // ------------------------------------------------------- Public Properties

      private long customersId;

      private String firstName;

      private String lastName;

      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "customers_id")
      public long getCustomersId() {
      return customersId;


      should work or how it works?