• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jpa persist increment id twice

 
Juan Porras Antonio
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to forum.

I have a problem with JPA and persist.
I'm working with oracle database and I have created a Trigger, which increments id by 1.

This is the trigger:

CREATE OR REPLACE TRIGGER MDITADMIN."BI_MITD_ENTIDADES"
before insert on "MITD_ENTIDADES"
for each row
begin
select "MITD_SEQ_ENTIDADES".nextval into :NEW.ID_ENTIDADES from dual;
end;


My problem is, when I tried to insert an object, JPA call oracle's sequence and increment id by one, but then, Oracle calls trigger an increment id too. Result: Id is incremente Twice.

My problem is not AllocationSize (it's set 1). My patch is disable trigger, but it's the correct solution?

Thanks for reply.
 
Craig Taylor
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes - The jpa implementation is responsible for assigning the id (assuming it's marked appropriately). The trigger is not needed.
 
Juan Porras Antonio
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks for reply. .
I'm a newbie, but I expect to help other people soon.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic