EntityManager.persist() function is trying to update a existing record, but I always need to insert a new one. How to achieve this?
Part of Entity bean:
@Entity
@Table(name="SYNC_TRIGGER", schema="ETL")
public class SyncTrigger implements Serializable {
@Id
@Column(name="ID")
@SequenceGenerator(name = "TRIGGER_SEQ", sequenceName = "ETL.TRIGGER_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TRIGGER_SEQ")
private Long triggerId;
......
Part of Stateless bean, which persists the record:
@Stateless
public class TriggerPersister {
@PersistenceContext(unitName="syncTriggerDS")
protected EntityManager entityManager;
public <T extends GenericTrigger> void persistTrigger(SyncTrigger
st, T concreteTrigger){
entityManager.persist(st);
.........
UPD: Before entityManager.persist(st) is executed st.triggerId value is null, but after - id of previously added record is assigned to this field.