JPA中字符串的大小有限

时间:2011-11-13 11:40:39

标签: mysql jpa persistence

我在MySQL中有一个表“message”,其中包含VARCHAR(3000)类型的“content”列。我正在尝试使用JPA执行以下查询:

@PersistenceContext(unitName="Course7-ejbPU")
protected EntityManager manager;
(...)
manager.createQuery("SELECT m.content FROM Message m WHERE m.id=10").getResultList();

在某些情况下,我收到以下例外情况:

>Exception occurred in target VM: com/mysql/jdbc/OperationNotSupportedException 

实验上,我发现,在列“内容”中设置不同的值时,当此列中的文本长度超过1126时抛出该异常。当我在列中留下1126个符号时,它工作正常,还有一个符号 - 抛出异常。 与列映射的entity bean的属性如下

@Basic(optional = false)
@NotNull
@Size(min = 1, max = 3000)
@Column(name = "content")
private String content;

MySQL Workbench可以正常使用此列。 持久性提供程序是EclipseLink 2.2.0。 有谁知道问题的原因?提前谢谢。

UPD。 所描述的问题有时会发生。在我写完这篇文章后,我忘记了几天。似乎EJB只是希望休息一段时间,然后它们才能正常工作。然而,问题再次发生。詹姆斯,抛出异常的简要说明:

WARNING: LDR5207: ASURLClassLoader EarLibClassLoader : 
doneCalled = true
doneSnapshot = ASURLClassLoader.done() called ON EarLibClassLoader : 
urlSet = [URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/commons-codec-1.5.jar, URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/eclipselink-2.2.0.jar, URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/eclipselink-javax.persistence-2.0.jar, URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/gson-1.7.1.jar, URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/jdom-1.1.jar, URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/jstl-api-1.2.jar, URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/log4j-1.2.16.jar, URLEntry : file:/C:/Course7/dist/gfdeploy/Course7/lib/mysql-connector-java-5.1.18-bin.jar]
doneCalled = false 
Parent -> org.glassfish.internal.api.DelegatingClassLoader@1fb5694
AT Sat Nov 19 14:33:48 EET 2011 
BY :java.lang.Throwable: printStackTraceToString
(...)
Parent -> org.glassfish.internal.api.DelegatingClassLoader@1fb5694
was requested to find class com.mysql.jdbc.OperationNotSupportedException after done was invoked from the following stack trace
(...)
WARNING: A system exception occurred during an invocation on EJB MessageDAO method public java.util.List dao.MessageDAO.getTaskMessageList(int)
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean:
java.lang.NoClassDefFoundError: com/mysql/jdbc/OperationNotSupportedException

0 个答案:

没有答案