2 Replies Latest reply on Sep 18, 2006 7:23 AM by abuayyub

    Insert Triggers and Hibernate

    tlien

      I have an ejb3 entity has an IDENTITY field and a before insert trigger. The problem is that hibernate sets the IDENTITY value of my entity to 0 every time causing NonUniqueObjectExceptions when I create more than one of them in a session. I verified that it is the trigger that is causing it because it does not happen when I remove it.

      I need the triggers due to legacy applications that insert into to table. Are there any ways to workaround this?

      Thanks

        • 1. Re: Insert Triggers and Hibernate
          tlien

          I did some more digging and realized that hibernate was using scope_identity. Since the table has a trigger scope_identity returns null. I still don't know what to do about it though since I can't change the database due to legacy applications though :(

          • 2. Re: Insert Triggers and Hibernate
            abuayyub

            Hi

            would it be possible to use the sequence generator for that field. so it generates a new value every time it sets it? defined like.

            <property name="identity" column="IDENTITY" generated="insert"/>


            regards tod