Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-3251

Composite key with Oracle - Gives error on rendering after creation, and on listing

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2.RELEASE
    • Fix Version/s: None
    • Component/s: PERSISTENCE
    • Environment:
      Oracle, Windows 7, SpringSource STS

      Description

      Hello,
      I'm new to spring/spring roo and hibernate. I'm trying it out with my existing oracle database schema. This issue may be more related to JPA or hibernate, so please let me know if i'm reporting to wrong place, or doing something wrong, etc. I've seen the following issues regarding an entity mapped to a table with a composite key:

      1) when doing a listing... It appears to try to do a count() SQL with all three fields of key as arguments to the count()... Oracle doesn't allow this, and thus it throws an error.

      2) After saving a record... the record will be saved correctly, but an error is thrown... I believe regarding the rendering of the record.

      The issues occur only when the table has a composite key - on a legacy table with a single-field PK, it doesn't have this problem.

      I attached an example project with schema-creation script. It includes an example of the entity with the composite key and an entity with a single-field legacy key.

      Notes about the included example:
      1) run the "01" script as system or sys user, to create the sample user "roo" with password "roo".
      2) run the "02" sql script to create the two tables with primary keys.
      3) I altered the pom file... how it does the ojdbc jar, by doing this... Notice where I placed the ojdbc6.jar file:
      <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc6</artifactId>
      <version>11.2.0</version>
      <scope>system</scope>
      <systemPath>C:\Java\Oracle_JDBC\ojdbc6.jar</systemPath>
      </dependency>
      4) I also copied the ojdbc6.jar into this folder, so it's available once the app is deployed and running:
      \TraxDefects\src\main\webapp\WEB-INF\lib\ojdbc6.jar
      5) I added this to each of the entities @RooJpaActiveRecord annotation, because my tables don't have a version field: versionField = ""
      6) The table that works okay (single field key) is: ac_master
      7) the table that doesn't work okay (composite key) is: defect_report

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            darthluch LB
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: