Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:33:57+00:00 2026-05-23T13:33:57+00:00

I am trying to build a set of domain classes for a legacy database

  • 0

I am trying to build a set of domain classes for a legacy database using Grails 1.3.7 and MySQL 5.1.56. I am specifying the MySQL connector in the BuildConfig.groovy file as ‘mysql:mysql-connector-java:5.1.13’.

The database schema has a field named ‘abstract’ of type TEXT.

I am declaring the corresponding property in my class as follows (only relevant parts shown for clarity):

class Paper {
    String abstractText

    static mapping = {
        table 'papers'
        abstractText column: 'abstract'
    }

    static constraints = {
        abstractText(nullable: false, maxSize: 65535)
    }
}

When I run my integration test, I get the following error:

Wrong column type in citeseerx.papers for column abstract. 
Found: text, expected: longtext

If I change the declaration to be

    static mapping = {
        abstractText column: 'abstract', type: 'text'
    }

I get the same error. If I set the type to ‘longtext’, I get

Could not determine type for: longtext, at table: papers, 
for columns: [org.hibernate.mapping.Column(abstract)]

I saw a discussion of a seemingly-related Hibernate bug, and I am wondering if there is a work-around for it, or some other way of modeling schemas that have TEXT fields.

Thanks,

Gene

EDITED: Here is the relevant DataSource.groovy snippet:

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    url = "jdbc:mysql://mydbhost:3306/mydb"
    username = "u"
    password = "p"
    dbCreate = 'validate'
    //dialect = org.hibernate.dialect.MySQL5Dialect
    dialect = com.fxpal.citeseer.mysql.MyMySQLDialect
    println("Setting dialog = ${dialect}")  
}

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = true
    cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}

EDITED(2): Here is the Custom Dialect class, as suggested by @Stefan’s answer:

import java.sql.Types;

/**
 * An An extension to the SQL dialect for MySQL 5.1 to handle TEXT.
 *
 * @author Gene Golovchinsky
 */
public class MyMySQLDialect extends org.hibernate.dialect.MySQLDialect {

    public MyMySQLDialect() {
        super();
        System.out.println("MyMySQLDialect: created new instance");
    }

    protected void registerVarcharTypes() {
        System.out.println("MyMySQLDialect: RegisteringVarcharTypes");
        registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
        registerColumnType( Types.VARCHAR, 65535, "text" );
        registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
        registerColumnType( Types.LONGVARCHAR, "longtext" );
    }
}
  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:33:57+00:00Added an answer on May 23, 2026 at 1:33 pm

    You could probably derive a custom dialect from https://github.com/hibernate/hibernate-core/blob/master/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java and change the mapping for ‘text’. Then apply the new dialect to Datasource.groovy using the “dialect = ” setting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set up a Build Server using CC.NET and TFS. In
I am trying to set up an automated build system on Windows using Cygwin.
I'm trying to set up Jenkins (v1.47) to build a project using the ClearCase
I'm trying to build an object in javascript using self-invoking functions to set the
I am trying to build set of reusable components for the ASP.Net MVC3 application.
I am trying to build a secure of set of tests with Symfony2, Doctrine
I'm currently trying to build a more or less complete set of unit tests
I am trying to get a build process set up in TeamCity 5, and
I'm trying to automate InstallShield from my build process, and I need to set
I am trying to build a web site in both English and Bulgarian using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.