Hello I am having problem with auto generated primary key of entity in JPA. I am persisting the entity and trying to get the id value out of it, but it returns null even though I am doing flush. I am using latest glassfish, JPA, netbeans, EJB 3
public class CatchesEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
(...)
@PersistenceContext(unitName = "DBF")
private EntityManager em;
(...)
public void randomMethod()
{
CatchesEntity catchEntity = new CatchesEntity();
em.persist(catchEntity);
em.flush();
System.out.println("CATCH ID: "+catchEntity.getId());
I get NULL