Announcement Announcement Module
Collapse
No announcement yet.
Primary key type mismatch error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Primary key type mismatch error

    I have Postgres database and Hibernate provider.

    I have reverse engineered five interconnected tables both in 1.1.5 and now in 1.2.0.M1, and I get the same problem.

    Here are the roo commands I ran through 1.2.0
    database reverse engineer --schema public --package com.xxx.database --includeTables "main appt location regioni_catalogo zone_catalogo"
    web mvc setup
    web mvc all --package com.xxx.database.controllers

    When I try the web app - calling for example the following page:
    http://localhost/DatabaseTables/mains?form

    I get:
    org.hibernate.TypeMismatchException: Provided id of the wrong type for class com.villeinitalia.database.Main. Expected: class com.villeinitalia.database.MainPK, got class com.villeinitalia.database.LocationPK;

    the database structure is as follows (some fields removed for reasons of space):
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.-->
    <database name="deprecated" package="com.villeinitalia.database">
        <option key="activeRecord" value="true"/>
        <option key="includeNonPortableAttributes" value="false"/>
        <option key="testAutomatically" value="false"/>
        <table alias="public" name="appt">
            <column name="nomecasa" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="codice" primaryKey="false" required="true" scale="0" size="2147483647" type="12,text"/>
            <column name="appartm" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="pax" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="mq" primaryKey="false" required="false" scale="0" size="5" type="5,int2"/>
            <column name="dal" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="al" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="cauzione" primaryKey="false" required="false" scale="0" size="10" type="4,int4"/>
            <column name="appt_no" primaryKey="true" required="true" scale="0" size="5" type="5,int2"/>
            <column name="dal_long" primaryKey="false" required="false" scale="0" size="19" type="-5,int8"/>
            <column name="al_long" primaryKey="false" required="false" scale="0" size="19" type="-5,int8"/>
            <column name="appt_srl" primaryKey="false" required="true" scale="0" size="10" type="4,serial"/>
             <foreign-key foreignTable="main" name="main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="false"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <unique name="appt_primary_key">
                <unique-column name="serial_link"/>
                <unique-column name="appt_no"/>
                <unique-column name="stagione"/>
            </unique>
            <index name="appt_al_long_index">
                <index-column name="al_long"/>
            </index>
            <index name="appt_codice_index">
                <index-column name="codice"/>
            </index>
            <index name="appt_dal_long_index">
                <index-column name="dal_long"/>
            </index>
            <index name="appt_nomecasa_index">
                <index-column name="nomecasa"/>
            </index>
            <index name="appt_nomecasa_stagione_index">
                <index-column name="nomecasa"/>
                <index-column name="stagione"/>
            </index>
        </table>
        <table alias="public" name="location">
            <column name="serial_link" primaryKey="true" required="true" scale="0" size="10" type="4,int4"/>
            <column name="regione" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="provincia" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="comune" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="localita" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="latitude" primaryKey="false" required="false" scale="5" size="7" type="2,numeric"/>
            <column name="longitude" primaryKey="false" required="false" scale="5" size="7" type="2,numeric"/>
            <column name="nomecasa" primaryKey="false" required="false" scale="0" size="2147483647" type="12,varchar"/>
            <column name="stagione" primaryKey="true" required="true" scale="0" size="5" type="5,int2"/>
            <foreign-key foreignTable="main" name="location_to_main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="false"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <unique name="location_primary_key">
                <unique-column name="serial_link"/>
                <unique-column name="stagione"/>
            </unique>
        </table>
        <table alias="public" name="main">
            <column name="nomecasa" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="valutazione" primaryKey="false" required="false" scale="0" size="5" type="12,varchar"/>
            <column name="indcp" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="stagione" primaryKey="true" required="true" scale="0" size="5" type="5,int2"/>
            <column name="serial_link" primaryKey="true" required="true" scale="0" size="10" type="4,int4"/>
     	   <foreign-key foreignTable="appt" name="main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="true"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <foreign-key foreignTable="location" name="location_to_main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="true"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <foreign-key foreignTable="regioni_catalogo" name="regioni_to_main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="true"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <foreign-key foreignTable="zone_catalogo" name="zone_to_main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="true"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <unique name="main_primary_key">
                <unique-column name="serial_link"/>
                <unique-column name="stagione"/>
            </unique>
            <index name="main_nomecasa_index">
                <index-column name="nomecasa"/>
            </index>
        </table>
        <table alias="public" name="regioni_catalogo">
            <column name="nomecasa" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="serial_link" primaryKey="true" required="true" scale="0" size="10" type="4,int4"/>
            <column name="regione" primaryKey="true" required="true" scale="0" size="2147483647" type="12,text"/>
            <column name="stagione" primaryKey="true" required="true" scale="0" size="10" type="4,int4"/>
            <foreign-key foreignTable="main" name="regioni_to_main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="false"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <unique name="regioni_catalogo_primary_key">
                <unique-column name="serial_link"/>
                <unique-column name="regione"/>
                <unique-column name="stagione"/>
            </unique>
        </table>
        <table alias="public" name="zone_catalogo">
            <column name="nomecasa" primaryKey="false" required="false" scale="0" size="2147483647" type="12,text"/>
            <column name="serial_link" primaryKey="true" required="true" scale="0" size="10" type="4,int4"/>
            <column name="zona" primaryKey="true" required="true" scale="0" size="2147483647" type="12,text"/>
            <column name="stagione" primaryKey="true" required="true" scale="0" size="10" type="4,int4"/>
            <foreign-key foreignTable="main" name="zone_to_main_foreign_key" onDelete="cascade" onUpdate="none">
                <option key="foreignSchemaName" value="public"/>
                <option key="exported" value="false"/>
                <reference foreign="serial_link" local="serial_link"/>
                <reference foreign="stagione" local="stagione"/>
            </foreign-key>
            <unique name="zone_catalogo_primary_key">
                <unique-column name="serial_link"/>
                <unique-column name="zona"/>
                <unique-column name="stagione"/>
            </unique>
        </table>
    </database>

    Any help with this gratefully received.

  • #2
    the database structure is as follows (some fields removed for reasons of space):
    Can you please zip up your entire dbre.xml and attach here as the one above is giving me erros due to missing foreign keys
    Thanks
    Alan

    Comment


    • #3
      dbre.xml attached

      Here's dbre.xml .zipped up

      Comment


      • #4
        P.s.

        Just wondering if there was any further news about this.

        The message was strange for another reason. Not only was there a primary key mismatch, but the other point was that error came when I clicked on 'create record'.
        Which was strange, because it appears that a list() method was being called, when all the controller should have been doing, I think, was to fill an empty entity for the form.

        Comment


        • #5
          Any progress?

          Dear Alan,

          I'd be very grateful for any possible news about this.

          Roo looks so promising, and we'd love to go down this road, it will save so much time.
          But after spending time getting into it we've got stuck here, and we can't solve it on our own.

          At least some indication that something is happening, or that the problem is due to something we've done wrong: something to keep us on track, please.


          Thanks for your time.

          Comment


          • #6
            Your dbre.xml file and generated JPA look OK, so it would appear to be a web controller issue. However, we only offer limited support for composite primary keys in Roo and this may be one of those corner cases that we haven't covered.

            The Roo team is focussed on multi-module Maven project support an JSF at the moment and I will try to find the time to see what can be done.

            Alan

            Comment

            Working...
            X