码迷,mamicode.com
首页 > 编程语言 > 详细

spring配置多数据源问题

时间:2016-06-03 21:23:27      阅读:464      评论:0      收藏:0      [点我收藏+]

标签:

   如果系统中存在多数据源,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

spring配置多数据源问题

标签:

原文地址:http://www.cnblogs.com/hutton/p/5557540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!