• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

jpa persist increment id twice

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks for reply. .
I'm a newbie, but I expect to help other people soon.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic