0

After a few weeks, my application now has a strange behaviour. When I try to do an insert, the sequence value is always zero, but the database gives me the correct value. The sequence is as follows:

CREATE SEQUENCE SEQ_ID_PERSONA_AUTOMATICKEY
INCREMENT BY 1
START WITH 1
MAXVALUE 999
MINVALUE 1
NOCYCLE;

The entity has the necessary annotations and as I said it worked perfect.

@Id
@SequenceGenerator(name = "MY_SEQUENCE", sequenceName = "SEQ_ID_PERSONA_AUTOMATICKEY", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MY_SEQUENCE")
@Column(name = "ID_PERSONA")
private Long idPersona;

The insert method has nothing special, just em.persist(persona);

I don't know what to do. I tried to recompile the project and redeploy it but it always gives me zero. Any suggestions? Thanks.

Using Oracle Database 11g Express, Oracle Weblogic 12c, Java EE 6

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Sergi
  • 579
  • 3
  • 14

1 Answers1

0

Your sequence definition says MAXVALUE is 999, and there is this NOCYCLE which would mean it will not reset when reaching the max value. Maybe you just reached this max value? You can check this using help from this answer I guess https://stackoverflow.com/a/10210308/1937263

Community
  • 1
  • 1
makasprzak
  • 5,082
  • 3
  • 30
  • 49