Announcement Announcement Module
No announcement yet.
Foreign Key constraint fails Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Foreign Key constraint fails

    I am attempting to set up a relationship that resembles the example under the 'hint relationships' command. Instead of an Order with lineItems, I have a GolfCourse with scorecards relationship.

    I am getting the following exception:

    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityCons traintViolationException: Cannot add or update a child row: a foreign key constraint fails (`handicaptracker`.`scorecard`, CONSTRAINT `FK7EEC20A258736E` FOREIGN KEY (`id`) REFERENCES `scorecard` (`id`))

    I can see that a foreign key is created on the (id) field on the scorecard table. When I remove that foreign key, I can manually add records.

    Is there something I need to do to modify the way I'm setting up the relationship?


    field set --fieldName scorecards --class GolfCourse --element Scorecard --mappedBy golfCourse

    field reference --fieldName golfCourse --class Scorecard --type GolfCourse --notNull

    Software Versions Used:
    MySQL Server 5.1
    persistence setup --provider HIBERNATE --database MYSQL

    Thank you in advance!


  • #2
    This appears to be the same issue as reported in ROO-873.It only happens with MySql and there is no solution as yet. You can re-open the problem and we will have a look again. Also, please test using PostgreSQL and see if it works.