如果系统中存在多数据源,spring启动默认加载时,datasouce、session、transaction的id值不能设置为相同,必须对其使用不同的名称命名,否则将会出现数据调用问题。
如从mysql读取数据,则会始终提示no persistent classes found for query class问题,或者提示如下错误:
Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1}: org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:301) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:15) [spring-aspects-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at com.tmm.enterprise.socialcv.security.dao.AccountDAO.loadAccountByUserName(AccountDAO.java:28) [classes:]
at com.tmm.enterprise.socialcv.service.AccountService.loadAccountByUserName(AccountService.java:48) [classes:]
at com.tmm.enterprise.socialcv.service.AccountService.setCredentials(AccountService.java:241) [classes:]
at com.tmm.enterprise.socialcv.controller.HomeController.signup(HomeController.java:59) [classes:]
...
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:446) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:67) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
... 80 more
Caused by: org.hibernate.QueryParameterException: ***Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1***
at org.hibernate.engine.query.spi.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:80) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.query.spi.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:86) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.AbstractQueryImpl.determineType(AbstractQueryImpl.java:444) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:416) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:440) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
... 81 more
时间: 2024-10-11 13:40:34