2 Replies Latest reply: Mar 30, 2012 3:47 AM by 926897 RSS

    DBRE on Oracle table

    926897
      Hi all!

      The database table I try to generate a model and a (Vaadin) UI for is very simple:

      Column: id Type: Integer
      Column: text Type: Varchar2(32)

      For the column “id” I have created a sequence and a trigger setting “nextVal” before insert into the column ID.
      Everything is fine within my database client (DbVisualizer).

      The persistence is setup with “eclipselink” as JPA provider, because I have learned, that “eclispelink” is mandatory for Vaadin at the moment. For the same reason I am still using Roo 1.1.5.

      In the RooShell (within STS) I do

      [ database reverse engineer --schema MY_SCHEMA --includeTables "MY_TABLE" ]
      and

      [ vaadin generate all --package ~.web.ui --visuallyComposable true ]

      My generated UI works fine, displays all the items, I am able to select, edit and update an item, but in case of “insert” (Button “New”) I get an exception:

      [ Error Code: 942
      Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
           bind => [2 parameters bound]
      Query: DataModifyQuery(name="SEQUENCE" sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?") ]

      I assume I am doing something basically wrong here. For I found no tutorial and I think this is a basic problem all Oracle Roo projects may have it would be nice to have a tutorial for this….

      Regards,
      Philipp
        • 1. Re: DBRE on Oracle table
          cdelahun
          The problem seems to be your sequence definition on the entity is not defined, and so using the provider default - in EclipseLink this is to use a SEQUENCE table to hold onto sequence values.

          Sequencing options are described here:
          http://wiki.eclipse.org/EclipseLink/Examples/JPA/PrimaryKey

          What you are doing though is setting the sequence using a trigger instead of allowing the JPA provider to get the sequence value from the Sequence object directly. This is somewhat described here:
          http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Primary_Keys_through_Triggers
          And from it I would recommend you instead use the sequence object directly instead of the trigger to set the ID on the row.

          I've never used it, but specifying a @ReturnInsert might work using your trigger on the ID:
          http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Use_the_.40ReturnInsert_Annotation

          Best Regards,
          Chris
          • 2. Re: DBRE on Oracle table
            926897
            Thanks!