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

  • Home
  • SEARCH
  • 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 6728249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:08:51+00:00 2026-05-26T10:08:51+00:00

I have a simple EntityBean with a @Lob annotation. If I delete this annotation

  • 0

I have a simple EntityBean with a @Lob annotation. If I delete this annotation I get no errors on JBossAS 6.0.0.Final and MySQL5. But if I annotate it with @Lob (because mt contains about 100 to 5000 characters in my case) I get errors in my testing environment if I persist the entity.

  • without @Lob: mt is mapped to VARCHAR
  • with @Lob: mt is mapped to LONGTEXT (this is what I want, but I get errors)

This my entity:

@Entity
@Table(name = "Description")
public class Description implements Serializable
{ 
  public static final long serialVersionUID=1;

  @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
  private long id;  

  @Lob
  private String mt;
}  // ... getter/setter

The error are here:

...
Caused by: org.hibernate.exception.GenericJDBCException: could not insert
   [my.Description]
...
Caused by: java.sql.SQLException: Connection is not associated with a managed
     connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6@3e4dd
...

I really don’t know why I get this (reproduceable) error. The environment seems to be ok, many other tests are passed and it even works without the @Lob annotation.

This question is related to JPA: how do I persist a String into a database field, type MYSQL Text, where the usage of @Lob for JPA/MySQL is the accepted answer.

Update 1 The error above is OS specific. On a W7 machine I have no problems with @Lob, with OSX Lion always the error. I will try to update MySQL and the driver.

Update 2 The proposed workaround by Kimi with @Column(columnDefinition = "longtext") works fine, even on OSX. In both cases MySQL creates the same column: LONGTEXT.

Update 3 I updated MySQL to mysql-5.5.17-osx10.6-x86_64 and the connector to mysql-connector-java-5.1.18. Still the same error.

  • 1 1 Answer
  • 0 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-26T10:08:52+00:00Added an answer on May 26, 2026 at 10:08 am

    There is no need to annotate a String property with @Lob. Just set the column length with @Column(length = 10000).

    EDIT:

    Moreover, you can always set the length to your database specific maximum value, as well as define the column type with the columndefinition setting to whichever suits your needs.

    For example, if you’re using MySQL 5.0.3 or later, the maximum amount of data that can be stored in each data type is as follows:

    • VARCHAR: 65,535 bytes (~64Kb, 21,844 UTF-8 encoded characters)
    • TEXT: 65,535 bytes (~64Kb, 21,844 UTF-8 encoded characters)
    • MEDIUMTEXT: 16,777,215 bytes (~16Mb, ~5.5 million UTF-8 encoded characters)
    • LONGTEXT: 4,294,967,295 bytes (~4GB, ~1.4 billion UTF-8 encoded characters).

    As i understand it, @Lob just sets the column type and length depending on the underlying database.

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

Sidebar

Related Questions

I have simple WebView code like this: WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl(http://en.wikipedia.org/wiki/Book); But
I have simple query, but when I'm trying to execute this query I'm getting
I have simple from written on C/gtk+ and i have function in this appliction.
i have simple side menu with this html code : <div id=menu> <div> Menu
I have simple user model: var user = Backbone.Model.extend({ initialize: function(){ this.bind(change:auth, function (){
I have simple front controller plugin which contains this code: http://pastebin.com/m155c59b0 When session expire
I have simple JSF application. Everything works fine, but not navigation. It behaves like
I have simple WCF Service Application (based on this tutorial : Getting Started ).
I have simple web application based on JSP. Root of application looks like this:
I have simple models with generic relations from this example at the Django Project

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.