Results 1 to 9 of 9

Thread: Reverse engineer MySql table with text field

  1. #1
    Join Date
    Mar 2008
    Posts
    257

    Default 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
    Stephane

  2. #2
    Join Date
    Mar 2008
    Posts
    257

    Default

    I'm using Roo 1.2.1.RELEASE [rev 6eae723]
    Stephane

  3. #3
    Join Date
    Mar 2008
    Posts
    257

    Default

    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 ?
    Stephane

  4. #4
    Join Date
    Mar 2008
    Posts
    257

    Default

    The generated Admin domain class:

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

  5. #5
    Join Date
    Mar 2008
    Posts
    257

    Default

    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 at 10:10 PM.
    Stephane

  6. #6
    Join Date
    Apr 2012
    Posts
    11

    Default

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

  7. #7
    Join Date
    Dec 2005
    Posts
    930

    Default

    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.
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  8. #8
    Join Date
    Mar 2008
    Posts
    257

    Default

    Okay, will try that, thanks.
    Stephane

  9. #9
    Join Date
    Mar 2008
    Posts
    257

    Default

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •