5 Replies Latest reply on Mar 29, 2008 12:06 AM by manuelgchacon

    seam generate-entities problem NO @OneToMany or @ManyToMany

    manuelgchacon

      I may be doing something wrong, but I don't know what it could be because 95% of seam-gen is working fine for me.  The only problem is that it is not generating the @OneToMany or @ManyToMany annotations in my entity beans.  I have set up a typical ManyToMany situation with 2 parent tables and an intersection table with 2 foreign keys between them.



      Any tips are greatly appreciated.


      Using..
      MySQL 5.0.x on Mac OSX 10.4 and SEAM 2.0.1 GA


      seam-gen properties for the setup task are ....


      All the typical stuff for MySQL.  The only thing I can think that may be confusing it it the JDBC URL I am using.


      The MySQL database name is DBOne


      The JDBC URL I use is jdbc:mysql://localhost:3306/DBOne


      Another weird thing is that the @Entity annotations have the   catalog option set to the database name in the @Table entity.








        • 1. Re: seam generate-entities problem NO @OneToMany or @ManyToMany
          max.max.andersen.jboss.com

          Sounds like you are either using an too old jdbc driver or you underlying mysql is using ISAM instead of innodb and thus no foreign keys are reported to us via jdbc.

          • 2. Re: seam generate-entities problem NO @OneToMany or @ManyToMany
            manuelgchacon

            Thanks for the well intended tips Max.  However my problem turned out to be something a little more devious than that.  It turns out that seam-gen uses Middlegen under the hood.  Middlegen has issues with table names that are either in uppercase or mixed case. 


            Due to this feature in Middlegen and thus seam-gen, if you want to use MySQL the table names must be all in lower case.


            You are right regarding the ISAM vs INNODB tables though.  The engine behind the tables must be INNODB.


            Check out Middlgen's site for more info.

            • 3. Re: seam generate-entities problem NO @OneToMany or @ManyToMany
              pmuir

              Manuel Chacon wrote on Mar 26, 2008 03:37 PM:


              Thanks for the well intended tips Max.  However my problem turned out to be something a little more devious than that.  It turns out that seam-gen uses Middlegen under the hood.  Middlegen has issues with table names that are either in uppercase or mixed case.


              It never does. I was so surprised by this assertion that I double checked with Max ;-) 


              Seam-gen uses Hibernate Tools for all the real work (it's really just a set of templates).

              • 4. Re: seam generate-entities problem NO @OneToMany or @ManyToMany
                pmuir

                Oops, my quote was a bit long.


                What I meant was:


                Seam-gen doesn't use middlegen in anyway at all.

                • 5. Re: seam generate-entities problem NO @OneToMany or @ManyToMany
                  manuelgchacon

                  I could have sworn I read on a Hibernate site page somewhere that Hibernate Tools used Middlegen.  I will take your word for it.


                  I will say this however, switching the table names to all lower case fixed the problem I was experiencing.  With upper or mixed-case table names the relationships were not recognized by seam-gen.


                  Does the Eclipse Dali project also uses the same code base as seam-gen? I assume so because JBoss is a sponsor of that project. I ask because I saw the exact same behavior with the Dali Data Source Explorer.  It was not showing the foreign key constraints with mixed case or uppercase table names.


                  All I can say is that the behavior I was experiencing is eerily similar to the problem that Middlegen describes on this page.


                  http://boss.bekk.no/boss/middlegen/platforms/database.html


                  BTW -- I think you guys have done a great job with SEAM so far.  I think its going to be the Next Big Thing