Spring configures multiple data source issues

Source: Internet
Author: User

If there is a multiple data source in the system, spring starts the default load, the ID value of the Datasouce, session, transaction cannot be set to the same, it must be named with a different name, or a data invocation problem will occur.

If you read data from MySQL, you will always be prompted no persistent classes found for query class problem, or the following error is indicated:

Position beyond number of declared ordinal parameters. Remember that ordinal parameters is 1-based! Position:1; Nested exception is java.lang.IllegalArgumentException:org.hibernate.QueryParameterException:Position beyond number of declared ordinal parameters. Remember that ordinal parameters is 1-based! Position:1}:Org.springframework.dao.InvalidDataAccessApiUsageException:org.hibernate.QueryParameterException:Position Beyond  Number  of declared ordinal parameters. Remember  that ordinalParameters is 1-based!Position: 1; Nested exception is java.lang.IllegalArgumentException:org.hibernate.QueryParameterException:Position Beyond  Number  of declared ordinal parameters. Remember  that ordinalParameters is 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 ordinalParameters is 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] ... morecaused by:org.hibernate.QueryParameterException: * * *Position Beyond  Number  of declared ordinal parameters. Remember  that ordinalParameters is 1-based!Position: 1*** at Org.hibernate.engine.query.spi.ParameterMetadata.getOrdinalParameterDescriptor (Parametermetadata.java : +) [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] ... Bayi more

Spring configures multiple data source issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.