Spring Roo
  1. Spring Roo
  2. ROO-129

JPA's @ManyToOne mapping fails when using Hibernate in conjunction with MySQL

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0.M2
    • Fix Version/s: 1.0.0.RC1
    • Component/s: PERSISTENCE
    • Labels:
      None

      Description

      This was reported by Ronald Vermeire in the Roo forums. Thanks Ronald!

      The following script will fail on 'mvn test' with the following exception:


      Unsuccessful: create table product_group (id bigint not null auto_increment, version integer, index varchar(255), postfix bigint, prefix bigint, primary key (id))
      You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar(255), postfix bigint, prefix bigint, primary key (id))' at line 1


      This might be a problem in Hibernate (generating an invalid SQL query or the MySQL driver itself.

      The following script reproduces the issue:

      create project -topLevelPackage com.foo
      install jpa -database MYSQL -provider HIBERNATE
      new persistent class jpa -name ~.Prefix -testAutomatically
      add field string -fieldName name
      new persistent class jpa -name ~.ProductGroup -testAutomatically
      add field string -fieldName name
      add field reference jpa -type com.foo.Prefix -fieldName prefix

      However, changing the @ManyToOne mapping annotation in ProductGroup to have an explicit 'targetEntity' attribute fixes the issue:

      @ManyToOne(targetEntity=Prefix.class)
      @JoinColumn
      private Prefix prefix;

      So as a workaround we should include the targetEntity attribute by default.

        Activity

        Hide
        Stefan Schmidt added a comment -

        Change available since revision 151.

        Show
        Stefan Schmidt added a comment - Change available since revision 151.

          People

          • Assignee:
            Stefan Schmidt
            Reporter:
            Stefan Schmidt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: