Announcement Announcement Module
Collapse
No announcement yet.
Reverse engineer MySql table with text field Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reverse engineer MySql table with text field

    Hello,

    I did a reverse enineering of my MySql schema.

    I typed in a:

    database reverse engineer --package ~.domain --schema PUBLIC

    The command went fine.

    But then when running the integration tests I got:

    Caused by: org.hibernate.HibernateException: Wrong column type in db_integration.admin for column profile. Found: text, expected: varchar(255)

    How come Roo doesn't accept the text field ?

    Here is the table structure:

    mysql> desc admin;
    +------------------+------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +------------------+------------------+------+-----+---------+----------------+
    | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
    | version | int(10) unsigned | NO | | NULL | |
    | firstname | varchar(255) | NO | | NULL | |
    | lastname | varchar(255) | NO | | NULL | |
    | login | varchar(50) | NO | UNI | NULL | |
    | password | varchar(100) | NO | | NULL | |
    | password_salt | varchar(50) | YES | | NULL | |
    | super_admin | tinyint(1) | NO | | NULL | |
    | preference_admin | tinyint(1) | NO | | NULL | |
    | address | varchar(255) | YES | | NULL | |
    | zip_code | varchar(10) | YES | | NULL | |
    | city | varchar(255) | YES | | NULL | |
    | country | varchar(255) | YES | | NULL | |
    | email | varchar(255) | YES | | NULL | |
    | profile | text | YES | | NULL | |
    +------------------+------------------+------+-----+---------+----------------+
    15 rows in set (0.00 sec)

    Kind Regards,

    Stephane

  • #2
    I'm using Roo 1.2.1.RELEASE [rev 6eae723]

    Comment


    • #3
      I can see in the dbre.xml file the following:

      <column name="profile" primaryKey="false" required="false" scale="0" size="65535" type="-1,TEXT"/>

      It seems the reverse ingineering was fine, as the field was not seen as a VARCHAR, like for example:

      <column name="email" primaryKey="false" required="false" scale="0" size="255" type="12,VARCHAR"/>

      So, how come the integration test desn't see it that way too ?

      Comment


      • #4
        The generated Admin domain class:

        @RooJavaBean
        @RooToString
        @RooJpaActiveRecord(table = "admin")
        @RooDbManaged(automaticallyDelete = true)
        public class Admin {
        }

        Comment


        • #5
          The file Admin_Roo_DbManaged.aj contains:

          @Column(name = "profile")
          private String Admin.profile;

          So I manually edited this annotation to have it like:

          @Column(name = "profile", columnDefinition="TEXT")

          And the issue was solved.

          So now I have to fo the same thing for all the text fields :-)
          Last edited by stephaneeybert; Apr 6th, 2012, 11:10 PM.

          Comment


          • #6
            It is possible to add "--includeNonPortableAttributes" to reverse engineering command, so it will create all your classes correctly. (BLOB type has the same problem.)

            Comment


            • #7
              The issue is with Hibernate and not DBRE. You have reverse engineered but are now experiencing a problem going "forward" to the DB with the ORM. louisnerys suggestion of using --includeNonPortableAttributes should help.

              Comment


              • #8
                Okay, will try that, thanks.

                Comment


                • #9
                  The --includeNonPortableAttributes attribute produced the desired result of having the columnDefinition = "TEXT" for the column annotation.

                  Comment

                  Working...
                  X