Topic
  • 5 replies
  • Latest Post - ‏2012-06-13T19:30:21Z by sutter
SystemAdmin
SystemAdmin
45 Posts

Pinned topic Having Two ear using diferrent JPA versions

‏2012-06-05T06:38:18Z |
HI,

I am having two application ear's where one is using JPA version 1.2.2 and another ear is using JPA 2.1.1.
Since one my ear is using open jpa 2 i applied special feature pack to my app server while my ear using open jpa 2 is working fine where as the ear using 1.2 jpa version is throwing exceptions while running queries.
below is the stack trace

Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Parameter named "1" is not declared in query "select nlr from NLR_PRVDR_REGISTRATION nlr where nlr.confirmationNmbr = ? 1 ORDER BY nlr.pymntYear DESC". Declared parameter keys are "[1]".; nested exception is java.lang.IllegalArgumentException: Parameter named "1" is not declared in query "select nlr from NLR_PRVDR_REGISTRATION nlr where nlr.confirmationNmbr = ? 1 ORDER BY nlr.pymntYear DESC". Declared parameter keys are "[1]".
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:286)
at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:120)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:368)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy75.getRegistrationByMaxPymntYear(Unknown Source)
at com.ehr.business.impl.TrackRegistrationByYearImpl.validateRegistrationId(TrackRegistrationByYearImpl.java:193)
at sun.reflect.GeneratedMethodAccessor2203.invoke(Unknown Source)
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$1.doInTransaction(TransactionInterceptor.java:132)
at org.springframework.transaction.jta.WebSphereUowTransactionManager$UOWActionAdapter.run(WebSphereUowTransactionManager.java:337)
at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:1067)
at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:628)
at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:127)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
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 $Proxy138.validateRegistrationId(Unknown Source)
at com.ehr.web.action.ViewRegistrationDetailRequestHandler.createPresentationObjects(ViewRegistrationDetailRequestHandler.java:97)
Updated on 2012-06-13T19:30:21Z at 2012-06-13T19:30:21Z by sutter
  • sutter
    sutter
    94 Posts

    Re: Having Two ear using diferrent JPA versions

    ‏2012-06-05T16:15:33Z  
    Hi,
    I would like to clarify the scenario... You are saying that you have a single application (ear) that is producing different results when running against OpenJPA 1.2.x vs OpenJPA 2.1.x. And, the expected results are coming from the OpenJPA 2.1.x environment. The OpenJPA 1.2.x environment is producing the exception as reported. Is that correct?

    How are you setting the parameter values? It's kind of strange. The exception text indicates a problem with "named" parameters, but your query is using "positional" parameters. So, somewhere the two types of parameter processing are getting mixed up.

    In your case, it looks like you should be using the setParameter(1, <value>) invocation since you are using positional parameters. Any chance you are using setParameter("1", <value>) instead? This would cause us to go down the named parameter path and could produce the exception as reported. But, I don't understand why it would start working in the 2.1.x environment.

    I've looked through the various JIRAs related to parameter processing, but haven't found an exact match. If you could provide these additional details, then maybe we can get to the bottom of the question.

    Thank you,
    Kevin Sutter, JPA Architect, IBM WebSphere
  • SystemAdmin
    SystemAdmin
    45 Posts

    Re: Having Two ear using diferrent JPA versions

    ‏2012-06-06T04:41:33Z  
    • sutter
    • ‏2012-06-05T16:15:33Z
    Hi,
    I would like to clarify the scenario... You are saying that you have a single application (ear) that is producing different results when running against OpenJPA 1.2.x vs OpenJPA 2.1.x. And, the expected results are coming from the OpenJPA 2.1.x environment. The OpenJPA 1.2.x environment is producing the exception as reported. Is that correct?

    How are you setting the parameter values? It's kind of strange. The exception text indicates a problem with "named" parameters, but your query is using "positional" parameters. So, somewhere the two types of parameter processing are getting mixed up.

    In your case, it looks like you should be using the setParameter(1, <value>) invocation since you are using positional parameters. Any chance you are using setParameter("1", <value>) instead? This would cause us to go down the named parameter path and could produce the exception as reported. But, I don't understand why it would start working in the 2.1.x environment.

    I've looked through the various JIRAs related to parameter processing, but haven't found an exact match. If you could provide these additional details, then maybe we can get to the bottom of the question.

    Thank you,
    Kevin Sutter, JPA Architect, IBM WebSphere
    Thanks Kevin for your swift response

    To clarify the scenario my ear was working fine without IBM JPA 2.0 special feature pack,after applying special feature pack am facing this issue.

    here is my code

    Query q = em.createQuery("select nprs from NLR_PRVDR_REG_STATUS nprs where nprs.nlrPrvdrRegistrationSid = ? 1");
    q.setParameter("1", registrationSid);
    return (List<NLRProviderRegStatus>)q.getResultList();
  • sutter
    sutter
    94 Posts

    Re: Having Two ear using diferrent JPA versions

    ‏2012-06-06T14:25:06Z  
    Thanks Kevin for your swift response

    To clarify the scenario my ear was working fine without IBM JPA 2.0 special feature pack,after applying special feature pack am facing this issue.

    here is my code

    Query q = em.createQuery("select nprs from NLR_PRVDR_REG_STATUS nprs where nprs.nlrPrvdrRegistrationSid = ? 1");
    q.setParameter("1", registrationSid);
    return (List<NLRProviderRegStatus>)q.getResultList();
    Thanks for the information. Since you are using positional parameters, you should be using this invocation for setting positional parameters:

    q.setParameter(1, registrationSid);

    If you make this change, does this resolve the issue for both environments?

    Thanks,
    Kevin Sutter, JPA Architect, IBM WebSphere
  • SystemAdmin
    SystemAdmin
    45 Posts

    Re: Having Two ear using diferrent JPA versions

    ‏2012-06-06T15:11:52Z  
    • sutter
    • ‏2012-06-06T14:25:06Z
    Thanks for the information. Since you are using positional parameters, you should be using this invocation for setting positional parameters:

    q.setParameter(1, registrationSid);

    If you make this change, does this resolve the issue for both environments?

    Thanks,
    Kevin Sutter, JPA Architect, IBM WebSphere
    Thanks Kevin,
    Let me try out the provided solution.

    Thanks again
    -Sathish
  • sutter
    sutter
    94 Posts

    Re: Having Two ear using diferrent JPA versions

    ‏2012-06-13T19:30:21Z  
    Since there's been no response for a week, I'm going to assume that this question has been resolved.