Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    JPA Datasource Query

    Hi
    I am trying to adapt the JPADS example to my needs (changed entity "country" to "person" and persistence.xml for MS SQL Server and I get the following error.

    I use smartgwt-pro version 2.3


    04.10.2010 00:35:58 com.isomorphic.jpa.JPADataSource executeFetch
    SCHWERWIEGEND: Failed to fetch results.
    java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1067)
    at com.isomorphic.jpa.JPADataSource.executeFetch(JPADataSource.java:232)
    at com.isomorphic.datasource.DataSource.execute(DataSource.java:782)
    at com.isomorphic.jpa.JPADataSource.execute(JPADataSource.java:94)
    at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
    at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
    at com.isomorphic.application.AppBase.execute(AppBase.java:491)
    at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1382)
    at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:155)
    at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:106)
    at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services - 1.1.1.v20090430-r4097): org.eclipse.persistence.exceptions.JPQLException
    Exception Description: Syntax error parsing the query [select _TPerson from com.smartgwt.sample.server.data.TPerson _TPerson], line 1, column 24: syntax error at [.].
    Internal Exception: MismatchedTokenException(71!=66)
    at org.eclipse.persistence.exceptions.JPQLException.syntaxErrorAt(JPQLException.java:358)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.handleRecognitionException(JPQLParser.java:304)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.addError(JPQLParser.java:245)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.reportError(JPQLParser.java:362)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(Unknown Source)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.mismatch(Unknown Source)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.match(Unknown Source)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.rangeVariableDeclaration(JPQLParser.java:2090)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.identificationVariableDeclaration(JPQLParser.java:1998)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.fromClause(JPQLParser.java:1882)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectStatement(JPQLParser.java:341)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.document(JPQLParser.java:261)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.parse(JPQLParser.java:133)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.buildParseTree(JPQLParser.java:94)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:156)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:134)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:91)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:78)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1065)
    ... 30 more
    Caused by: MismatchedTokenException(71!=66)
    ... 44 more
    === 2010-10-04 00:35:58,083 [l0-2] WARN RequestContext - dsRequest.execute() failed:
    java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1067)
    at com.isomorphic.jpa.JPADataSource.executeFetch(JPADataSource.java:232)
    at com.isomorphic.datasource.DataSource.execute(DataSource.java:782)
    at com.isomorphic.jpa.JPADataSource.execute(JPADataSource.java:94)
    at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
    at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
    at com.isomorphic.application.AppBase.execute(AppBase.java:491)
    at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1382)
    at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:155)
    at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:106)
    at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services - 1.1.1.v20090430-r4097): org.eclipse.persistence.exceptions.JPQLException
    Exception Description: Syntax error parsing the query [select _TPerson from com.smartgwt.sample.server.data.TPerson _TPerson], line 1, column 24: syntax error at [.].
    Internal Exception: MismatchedTokenException(71!=66)
    at org.eclipse.persistence.exceptions.JPQLException.syntaxErrorAt(JPQLException.java:358)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.handleRecognitionException(JPQLParser.java:304)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.addError(JPQLParser.java:245)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.reportError(JPQLParser.java:362)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(Unknown Source)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.mismatch(Unknown Source)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.match(Unknown Source)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.rangeVariableDeclaration(JPQLParser.java:2090)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.identificationVariableDeclaration(JPQLParser.java:1998)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.fromClause(JPQLParser.java:1882)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectStatement(JPQLParser.java:341)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.document(JPQLParser.java:261)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.parse(JPQLParser.java:133)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.buildParseTree(JPQLParser.java:94)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:156)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:134)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:91)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:78)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1065)
    ... 30 more
    Caused by: MismatchedTokenException(71!=66)
    ... 44 more




    my persistence.xml file looks like this



    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="ds" transaction-type="RESOURCE_LOCAL">
    <class>com.smartgwt.sample.server.data.TPerson</class>
    <properties>
    <property name="eclipselink.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/>

    <property name="eclipselink.jdbc.url" value="jdbc:jtds:sqlserver://myserver:1433/testdb;user=admin;password=*****;TDS=8.0"/>
    <property name="eclipselink.jdbc.user" value="admin"/>
    <property name="eclipselink.jdbc.password" value="********"/>
    <property name="eclipselink.jdbc.read-connections.min" value="1" />
    <property name="eclipselink.jdbc.write-connections.min" value="1" />
    <property name="eclipselink.jdbc.batch-writing" value="JDBC" />

    <!-- Logging -->
    <property name="eclipselink.logging.level" value="FINE" />
    <property name="eclipselink.logging.timestamp" value="false" />
    <property name="eclipselink.logging.session" value="false" />
    <property name="eclipselink.logging.thread" value="false" />

    <property name="eclipselink.cache.shared.default" value="false"/>
    </properties>

    </persistence-unit>
    </persistence>



    Thank you for assistance
    Pius

    #2
    Hi Pius,

    JPADataSource creates query using qualified class name.

    JPA specs do not allow using qualified class name.
    Eclipse strictly follows JPA specs while Hibernate and others allows qualified class name usage.
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=243698

    Changes supporting Eclipse will hit nightly build in a few days.

    For now (for test purposes) you can switch to Hibernate.

    Regards,
    Alius

    Comment


      #3
      Hi Pius,

      Thanks for pointing out a problem.

      I've just committed changes for creating query with simple name class (works with EclipseLink).

      You will be able to pick up these changes with next nightly build.

      Regards,
      Alius

      Comment

      Working...
      X