There is a problem about generating id while persisting into database. I added the following code to my jpa entity file, however I'm getting 0 for personid.
@Id
@Column(unique=true, nullable=false, precision=10, name="PERSONID")
@SequenceGenerator(name="appUsersSeq", sequenceName="SEQ_PERSON", allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "appUsersSeq")
private long personid;
EjbService:
@Stateless
public class EjbService implements EjbServiceRemote {
@PersistenceContext(name = "Project1245")
private EntityManager em;
@Override
public void addTperson(Tperson tp) {
em.persist(tp);
}
}
0 is default value for
longtype. The id will be set after invoking select query for the related sequence, which commonly is executed when you persist the entity. Are you persisting the entity? In case yes, post the database sequence definition to check it.