• 1348675996-402_QuoteImages4[1]

  • 1348675978-402_QuoteImages3[1]

  • 1348675962-402_QuoteImages2[1]

  • The minute you think of giving up, think of the reason why you held on so long
  • Problems are not stop signs, they are guidelines
  • Motivation is what gets you started. Habit is what keeps you going.

JPA implementation with Hibernate & Oracle Primary Key Sequences/Triggers

Written by Dwi Ardi Irawan. Posted in Uncategorized

TABLE: TR_TITLE
Column Name Data Type
title_id(PK) NUMBER
title VARCHAR2
code $VARCHAR2
NOTE: Title_id column by default is auto increment by trigger. By using this method, you will get:
  1. Two records will be inserted in TR_TITLE table(duplicate with different title_id, one is generated by triggers and other is generated by hibernate)
  2. You can’t get return value of the object because of this duplication.
What I want are:
  1. User can insert data from the back door or directly to the table
  2. Trigger is ignored when new record is inserted from the application. It means the title_id is generated by our JPA Configuration.
SOLUTION: NOTE: add condition when the inserted title_id null, get the auto increment sequence from database’s sequence and when the inserted title id is not null, auto increment sequence is generated from our JPA configuration. Disadvantage:
  1. User input directly to the table and insert title_id which is not generated by triggers.
  2. Portability, changing DBMS means create new triggers and sequence.

Hello World!

Written by Dwi Ardi Irawan. Posted in Uncategorized

Good Day! Finally I can share my personal website to the world wide web. This website is a representation of my ideas, my opinions, my ego and my idealism as a person and as a software engineer. I really hope what is written on this website will be useful for others. Last but not least, thank you for reading and feel free to comment.