Re: Native SQL Query
For our application we want to support both native queries and JPQL. Does open JPA not support native query under a distributed environment yet? -- View this message in context: http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6446011.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Native SQL Query
I've created a JIRA issue for this bug: https://issues.apache.org/jira/browse/OPENJPA-2008 -- View this message in context: http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6447446.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Native SQL Query
Thanks for the reply. Yes you are right, we are using a distributed environment (Slice) and we did find out that this only happens when we are using slice. Below is the method that is returning null for ExpressionParser. At this point in execution, language is openJpa.SQL. There doesn't seem to be an ExpressionParser mapped to this language. public StoreQuery newQuery(String language) { ExpressionParser parser = QueryLanguages.parserForLanguage(language); DistributedStoreQuery ret = new DistributedStoreQuery(this, parser); for (SliceStoreManager slice : _slices) { ret.add(slice.newQuery(language)); } return ret; } Is this a bug or is native queries not going to be supported in a sliced environment? -- View this message in context: http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6436172.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Native SQL Query
Below is our persistence.xml. When we are using the persistence-unit platform (no sharding), then createNativeQuery works. But if we use the persistence-unit platform-slice, then createNativeQuery fails with the stacktrace in the previous post. ?xml version=1.0 encoding=UTF-8? persistence version=2.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_2_0.xsd; persistence-unit name=platformTest_AWS transaction-type=RESOURCE_LOCAL provider org.apache.openjpa.persistence.PersistenceProviderImpl /provider properties property name=javax.persistence.jdbc.driver value=com.mysql.jdbc.Driver/ property name=javax.persistence.jdbc.url value=jdbc:mysql://platformtest.co7yazhl6rhc.us-east-1.rds.amazonaws.com:3306/platform/ property name=javax.persistence.jdbc.user value=**/ property name=javax.persistence.jdbc.password value=**/ property name=openjpa.Log value=DefaultLevel=WARN, Tool=INFO/ property name=openjpa.QueryCache value=ehcache/ property name=openjpa.DataCacheManager value=ehcache/ /properties /persistence-unit persistence-unit name=platform transaction-type=RESOURCE_LOCAL provider org.apache.openjpa.persistence.PersistenceProviderImpl /provider properties property name=openjpa.ConnectionDriverName value=com.mysql.jdbc.Driver/ property name=openjpa.ConnectionUserName value=**/ property name=openjpa.ConnectionPassword value=**/ property name=openjpa.ConnectionURL value=jdbc:mysql://127.0.0.1:3306/platform/ property name=openjpa.jdbc.SchemaFactory value=native(ForeignKeys=true)/ property name=openjpa.Log value=Runtime=TRACE, SQL=TRACE, DefaultLevel=WARN, Tool=INFO/ property name=openjpa.QueryCache value=ehcache/ property name=openjpa.DataCacheManager value=ehcache/ /properties /persistence-unit persistence-unit name=platform_slice provider org.apache.openjpa.persistence.PersistenceProviderImpl /provider properties property name=openjpa.Log value=Runtime=TRACE, SQL=TRACE, DefaultLevel=TRACE, Tool=TRACE/ property name=openjpa.BrokerFactory value=slice/ property name=openjpa.slice.Names value=platform,platform1,platform2/ property name=openjpa.slice.Master value=platform/ property name=openjpa.slice.Lenient value=true/ property name=openjpa.ConnectionDriverName value=com.mysql.jdbc.Driver/ property name=openjpa.ConnectionUserName value=root/ property name=openjpa.ConnectionPassword value=99nfirst/ property name=openjpa.slice.platform.ConnectionURL value=jdbc:mysql://127.0.0.1:3306/platform/ property name=openjpa.slice.platform1.ConnectionURL value=jdbc:mysql://127.0.0.1:3306/platform1/ property name=openjpa.slice.platform2.ConnectionURL value=jdbc:mysql://127.0.0.1:3306/platform2/ property name=openjpa.slice.DistributionPolicy value=com.edelements.platform.service.openjpa.DistributeByInstitutionPolicy/ property name=openjpa.slice.FinderTargetPolicy value=com.edelements.platform.service.openjpa.ShardFinderTargetPolicy/ property name=openjpa.slice.ReplicationPolicy value=com.edelements.platform.service.openjpa.ShardReplicationPolicy/ property name=openjpa.slice.ReplicatedTypes value=/ property name=openjpa.QueryCache value=false/ property name=openjpa.DataCache value=false/ property name=openjpa.QueryCompilationCache value=false/
Native SQL Query
Hi, I am trying to run a native select sql query on openJPA 2.1, MySQL 5.5. When I tried to run the following code, it throws the exception below. From what I can tell, the error is being thrown because there is no ExpressionParser for the SQL Language, but I have no idea why the parser is null or how to make sure it's not null. If anyone has any idea how to fix this, it would be most appreciated. Code being ran: Query query = entityManager.createNativeQuery(sqlquery); Listlt;Object[]gt; results = query.getResultList(); Stack trace: openjpa-2.1.0-r422266:1071316 nonfatal general error org.apache.openjpa.persistence.PersistenceException: null at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:625) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:852) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:305) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:319) at com.edelements.platform.dao.impl.CustomReportsDAOImpl.runQuery(CustomReportsDAOImpl.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy71.runQuery(Unknown Source) at com.edelements.platform.service.impl.CustomReportsServiceImpl.generateReport(CustomReportsServiceImpl.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy72.generateReport(Unknown Source) at com.edelements.platform.servlets.CustomReportsServlet.doPost(CustomReportsServlet.java:47) at com.edelements.platform.servlets.CustomReportsServlet.doGet(CustomReportsServlet.java:32) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.edelements.platform.web.filter.RestMethodFilter.doFilter(RestMethodFilter.java:79) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at