Announcement Announcement Module
Collapse
No announcement yet.
"Wrong column type " after using DBRE? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • "Wrong column type " after using DBRE?

    I'm trying to build a SpringRoo web app from a pre-existing MySQL database. (I've been having some problems with foreign keys but this is separate from that).

    I just tried it all from scratch and when I ran tomcat with the new webapp it reports:

    Caused by: org.hibernate.HibernateException: Wrong column type in isfdb.authors for column author_canonical. Found: mediumtext, expected: varchar(255)
    at org.hibernate.mapping.Table.validateColumns(Table. java:284)
    at org.hibernate.cfg.Configuration.validateSchema(Con figuration.java:1174)
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validat e(SchemaValidator.java:139)
    at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi onFactoryImpl.java:389)
    at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1385)
    at org.hibernate.cfg.AnnotationConfiguration.buildSes sionFactory(AnnotationConfiguration.java:954)


    Now that column *is* "mediumtext


    CREATE TABLE `authors` (
    `author_id` int(11) NOT NULL auto_increment,
    `author_canonical` mediumtext,
    `author_legalname` mediumtext,
    `author_birthplace` varchar(64) default NULL,
    `author_birthdate` date default NULL,
    `author_deathdate` date default NULL,
    `note_id` int(11) default NULL,
    `author_wikipedia` mediumtext,
    `author_views` int(11) default '0',
    `author_imdb` mediumtext,
    `author_marque` int(11) NOT NULL default '0',
    `author_image` mediumtext,
    `author_annualviews` int(11) NOT NULL default '0',
    `author_lastname` mediumtext,
    PRIMARY KEY (`author_id`),
    KEY `canonical` (`author_canonical`(50))
    ) ENGINE=MyISAM AUTO_INCREMENT=112930 DEFAULT CHARSET=latin1;



    I could have sworn this worked a few hours ago....

    Anything to suggest for how to investigate this? Does it sound like a bug, or a misconfiguration on my part?

    PS I don't really understand what "database introspect --schema myschema" is doing apart from displaying the schema to the screen.

    Oh, here are my Springroo commands from the log

    project --topLevelPackage mysite.isfdb.isfdbreader
    persistence setup --provider HIBERNATE --database MYSQL --databaseName isfdb --userName isfdb
    quit
    // Spring Roo 1.1.0.RELEASE [rev 793f2b0] log closed at 2010-11-19 10:39:54
    // Spring Roo 1.1.0.RELEASE [rev 793f2b0] log opened at 2010-11-19 10:40:30
    database introspect --schema isfdb
    database reverse engineer --schema isfdb --package ~.domain
    controller all --package ~.web
    logging setup --level DEBUG
    perform tests
    perform package
    perform eclipse
    quit



    This is what the introspect reports (but I don't know where it saves this data)

    <!--WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.-->

    <database name="isfdb" schema="isfdb">

    <table name="authors">

    <column index="1" name="author_id" primaryKey="true" required="true" size="10" type="INTEGER"/>

    <column index="2" name="author_canonical" primaryKey="false" required="false" size="16777215" type="LONGVARCHAR"/>

    <column index="3" name="author_legalname" primaryKey="false" required="false" size="16777215" type="LONGVARCHAR"/>

    <column index="4" name="author_birthplace" primaryKey="false" required="false" size="64" type="VARCHAR"/>

    <column index="5" name="author_birthdate" primaryKey="false" required="false" size="10" type="DATE"/>

    <column index="6" name="author_deathdate" primaryKey="false" required="false" size="10" type="DATE"/>

    <column index="7" name="note_id" primaryKey="false" required="false" size="10" type="INTEGER"/>

    <column index="8" name="author_wikipedia" primaryKey="false" required="false" size="16777215" type="LONGVARCHAR"/>

    <column index="9" name="author_views" primaryKey="false" required="false" size="10" type="INTEGER"/>

    <column index="10" name="author_imdb" primaryKey="false" required="false" size="16777215" type="LONGVARCHAR"/>

    <column index="11" name="author_marque" primaryKey="false" required="true" size="10" type="INTEGER"/>

    <column index="12" name="author_image" primaryKey="false" required="false" size="16777215" type="LONGVARCHAR"/>

    <column index="13" name="author_annualviews" primaryKey="false" required="true" size="10" type="INTEGER"/>

    <column index="14" name="author_lastname" primaryKey="false" required="false" size="16777215" type="LONGVARCHAR"/>

    <unique name="PRIMARY">

    <unique-column name="author_id" sequenceNumber="1"/>

    </unique>

    <index name="canonical">

    <index-column name="author_canonical" sequenceNumber="1"/>

    </index>

    </table>



    So? My mistake, or roo's?

  • #2
    There are a number of column types in MySQL that cause a mismatch between the database metadata returned from the JDBC driver and when Hibernate tries to persist the data later. The metadata from the MySQL JDBC driver will return java.sql.Types values that map to Strings for columns with TEXT, MEDIUMTEXT etc, however on the forward direction, Hibernate will give the error as you report. There's nothing I can do here, except to suggest to change your columns to VARCHAR.

    Comment

    Working...
    X