Note that there are some explanatory texts on larger screens.

plurals
  1. POLimited size of string in JPA
    text
    copied!<p>I have a table "message" in MySQL which contains the column "content" of type VARCHAR(3000). I'm trying to execute the following query using JPA:</p> <pre><code>@PersistenceContext(unitName="Course7-ejbPU") protected EntityManager manager; (...) manager.createQuery("SELECT m.content FROM Message m WHERE m.id=10").getResultList(); </code></pre> <p>In some cases, I receive the following exception:</p> <pre><code>&gt;Exception occurred in target VM: com/mysql/jdbc/OperationNotSupportedException </code></pre> <p>Experimentally, setting different values to the column "content", i found out, that exception is thrown when the length of text in this column is more than 1126. When i leave 1126 symbols in the column it works fine, one more symbol - exception is thrown. The property of entity bean, which is mapped with the column, is the following</p> <pre><code>@Basic(optional = false) @NotNull @Size(min = 1, max = 3000) @Column(name = "content") private String content; </code></pre> <p>MySQL Workbench works with this column fine. Persistence provider is EclipseLink 2.2.0. Does anyone know the cause of the problem? Thanks in advance.</p> <p><strong>Upd.</strong> The described problem occurs from time to time. After I had wrote this post, I forgot about it for some days. It seems like EJB just want to have a rest for some time, and then they become to work normally. Nevertheless, the problem happened again. James, brief description of throwed exception:</p> <pre><code>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 -&gt; org.glassfish.internal.api.DelegatingClassLoader@1fb5694 AT Sat Nov 19 14:33:48 EET 2011 BY :java.lang.Throwable: printStackTraceToString (...) Parent -&gt; 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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload