0 Replies Latest reply on Nov 28, 2003 4:42 AM by sandros

    Referential Integrity Violation in cmr

    sandros


      Hi all,

      I have two entities 'SystemUser' (primary key 'login') and 'Author', where author's primary-key is composed by an foreign-key to systemuser's primary-key and a string field fullName.
      I create in author a field that is both cmp-field and cmr-field and did all relationship configurations.
      All table were successfully created with primary-key and foreign-key constraints (PostgreSQL):

      Table "public.systemuser"
      Column | Type | Modifiers
      ----------+------+-----------
      login | text | not null
      fullname | text | not null
      password | text | not null
      Indexes: pk_systemuser primary key btree (login)

      Table "public.author"
      Column | Type | Modifiers
      ----------+------+-----------
      login | text | not null
      fullname | text | not null
      name | text | not null
      address | text | not null
      Indexes: pk_author primary key btree (login, fullname)
      Foreign Key constraints: fk_author_login FOREIGN KEY (login) REFERENCES systemuser(login) ON UPDATE NO ACTION ON DELETE NO ACTION

      But, the accessor setLogin(x), where x is the LocalInterface for systemuser with primary-key = 'sandro', in entity Author throws the following error:
      "Could not create entity:java.sql.SQLException: ERROR: fk_author_login referential integrity violation - key referenced from author not found in systemuser", but record 'sandros' exists in systemuser table.

      If I delete the constraint fk_author_login in table author, the record inserted is:

      login | fullname | name | address
      --------------------------+-----------------------+----------------+---------
      local/SystemUser:sandros | Sandro Santos Andrade | Andrade, S. S. | UFBa

      That is, the systemuser's primary key (login) is being 'local/SystemUser:sandros' rather than just 'sandros'

      If the cmr-field login is not part of primary key the insert occurs all right.

      Any solution ? I'm using jboss 3.2.2rc2.

      Thanks in advance,

      Sandro