Jpa 2.0 eclipselink how to persist(insert) entity class, without auto generated primary key
===

I user JPA 2.0 with  eclipselink with postgres DB.

I want to presist new entity Class. The primary key is an Integer, with not null constraint.


When i one to insert, JPA don't know the value of the new Primary key.

How can i get the new primary key value?

I can't change the DB sheme.

I think about get max id and insert a greater one to the DB, but it kind of messy solution.

This is the definition of the primary key in the entity class, generated with netBeans 7.0.1:
        @Id
        @Basic(optional = false)
        @Column(name = "obj_id")
        private Integer ObjId;

        public void save(){
        TkTopoVerzio test= new TkTest();
        // set all the value
        // ....

        try {
                em.getTransaction().begin();
                em.persist(test);
                em.getTransaction().commit();  
 
         } catch(javax.persistence.NoResultException ex){
            //Todo : manage exception
         } catch (Exception ex){
             // toDO : manage exception 
         }
}