精华内容
下载资源
问答
  • JRA4 <Software Package> Software Verification and Validation Plan Template Author1 (Author@institute.com ) Institute1 Author2 Institute2 Author3 Institue3 Author: AUTHOR vmmodel Institute : Signature
  • 在使用Validation时,我们有时候不希望验证成功后直接跳转页面(比如判断登录密码用户名正确与否),而希望自己使用Ajax提交,并且验证回调的结果。 $('.login-form').validate({ //验证规则, rules: { ...

    在使用Validation时,我们有时候不希望验证成功后直接跳转页面(比如判断登录密码用户名正确与否),而希望自己使用Ajax提交,并且验证回调的结果。

    
                    $('.login-form').validate({
                    //验证规则,  
                    rules: {
                        username: {
                            required: true
                        },
                        password: {
                            required: true
                        },
                        remember: {
                            required: false
                        }
                    },
    
                    messages: {
                        username: {
                            required: "必须输入用户名"
                        },
                        password: {
                            required: "必须输入密码"
                        }
                    },
                    submitHandler: function (form) {                    
                        $.ajax({  
                            type: 'post',  
                            url: "/plan/preplan/preplan_person_login.action", 
                            data:{
                                username:$('#username').val(),
                                password:$('#password').val()
                            },
                            success:function(data){
                                //console.log(data=="\"ok\"");
                                if(data=="\"ok\""){
                                    location.href ="/plan/preplan/plan_index.action";  //成功执行 
                                }else{
                                    alert('出错');//出错执行
                                }
                            }   
                        }); 
                        return false; // 阻止表单自动提交事件
                    }
                });
    
    展开全文
  • Validation failed for query for method

    千次阅读 2019-03-14 17:08:00
    nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.crab.bookol.repository.UserRepository.findBySex(java.lang.Character)!...

    问题原因

    sql语法,使用@Query("select id, username, usersex, userphone from User where User.usersex = ?1")会报错

    问题解决

    @Query("select id, username, usersex, userphone from User u where u.usersex = ?1")

    Bug重现

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.crab.bookol.repository.UserRepository.findBySex(java.lang.Character)!
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
        at com.crab.bookol.BookolApplication.main(BookolApplication.java:10) [classes/:na]
    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.crab.bookol.repository.UserRepository.findBySex(java.lang.Character)!
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        ... 19 common frames omitted
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.crab.bookol.repository.UserRepository.findBySex(java.lang.Character)!
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1762) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        ... 32 common frames omitted
    Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.crab.bookol.repository.UserRepository.findBySex(java.lang.Character)!
        at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:93) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:63) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:76) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromQueryAnnotation(JpaQueryFactory.java:56) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:139) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:206) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:79) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lookupQuery(RepositoryFactorySupport.java:566) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(RepositoryFactorySupport.java:559) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_202]
        at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[na:1.8.0_202]
        at java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1049) ~[na:1.8.0_202]
        at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:1.8.0_202]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_202]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_202]
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_202]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_202]
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_202]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.mapMethodsToQuery(RepositoryFactorySupport.java:561) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$new$0(RepositoryFactorySupport.java:551) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at java.util.Optional.map(Optional.java:215) ~[na:1.8.0_202]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:551) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:324) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.util.Lazy.getNullable(Lazy.java:211) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.util.Lazy.get(Lazy.java:94) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:300) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:119) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1821) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        ... 42 common frames omitted
    Caused by: java.lang.NullPointerException: null
        at java.lang.String$CaseInsensitiveComparator.compare(String.java:1192) ~[na:1.8.0_202]
        at java.lang.String$CaseInsensitiveComparator.compare(String.java:1186) ~[na:1.8.0_202]
        at java.util.TreeMap.getEntryUsingComparator(TreeMap.java:376) ~[na:1.8.0_202]
        at java.util.TreeMap.getEntry(TreeMap.java:345) ~[na:1.8.0_202]
        at java.util.TreeMap.get(TreeMap.java:278) ~[na:1.8.0_202]
        at org.hibernate.dialect.function.SQLFunctionRegistry.findSQLFunction(SQLFunctionRegistry.java:45) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.findSQLFunction(SessionFactoryHelper.java:385) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.ast.tree.IdentNode.getDataType(IdentNode.java:366) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:659) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:5002) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1286) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4706) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4174) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2138) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:815) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:609) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:271) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:191) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:595) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:704) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_202]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202]
        at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350) ~[spring-orm-5.1.5.RELEASE.jar:5.1.5.RELEASE]
        at com.sun.proxy.$Proxy82.createQuery(Unknown Source) ~[na:na]
        at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:87) ~[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]
        ... 71 common frames omitted

    转载于:https://www.cnblogs.com/pycrab/p/10531513.html

    展开全文
  • Bean Validation是目前用的最多的验证工具,因为是运行时数据验证框架,在验证之后验证的错误信息会被马上返回。但有时候验证的错误信息,每次都要进行判断,是否有错,然后组合成项目中对应的数据模型,返回前端。...

    微信公众号:吉姆餐厅ak
    学习更多源码知识,欢迎关注。
    在这里插入图片描述


    Bean Validation是目前用的最多的验证工具,因为是运行时数据验证框架,在验证之后验证的错误信息会被马上返回。但有时候验证的错误信息,每次都要进行判断,是否有错,然后组合成项目中对应的数据模型,返回前端。这样比较麻烦。这也是本文要解决的问题。

     @RequestMapping(value = "/plan", method = RequestMethod.POST)
        public Result<List> getAttePlanTimeSlot(@Valid @RequestBody PageSearchVo pageSearchVo, BindingResult bindingResult) {
        //这里每个有验证的接口都要进行判断,比较麻烦
            if (bindingResult.hasErrors()) {
                return Result.ofParamsError(bindingResult.getFieldError().getDefaultMessage());
            }
            return Result.ofSuccess(new ArrayList<>());
        }
    

    解决的办法就是重写 继承ResponseEntityExceptionHandler,重写 handleMethodArgumentNotValid 方法,该方法主要是数据校验出错时调用,重写该方法,统一组装返回。

    /**
     * Created by zhangshukang on 2017/12/26.
     *
     * 参数校验,报错信息处理类
     *
     */
    
    @ControllerAdvice
    @Slf4j
    public class BadRequestExceptionHandler extends ResponseEntityExceptionHandler {
    
        @Override
        protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
            IybBaseResponse response = new IybBaseResponse();
            response.setCode(ErrorCodeEnum.CMN_ILLEGAL_ARG.getCode ());
            String message = "";
            BindingResult result = ex.getBindingResult();
            //组装校验错误信息
            if(result.hasErrors()){
                List<ObjectError> list = result.getAllErrors();
                StringBuffer errorMsgBuffer = new StringBuffer();
                for(ObjectError error:list){
                    if (error instanceof FieldError) {
                        FieldError errorMessage = (FieldError) error;
                        errorMsgBuffer = errorMsgBuffer.append(errorMessage.getDefaultMessage()+",");
                    }
                }
                //返回信息格式处理
                message = errorMsgBuffer.toString().substring(0,errorMsgBuffer.length()-1);
            }
            response.setMessage(message);
            return new ResponseEntity<>(response, headers, status);
        }
    }
    

    这种方式比较灵活,handleMethodArgumentNotValid起到了拦截的作用,前提是数据校验抛异常之后才会执行到这里
    适合全局的校验处理。如果想单独处理错误信息,还是上面接口中用bindingResult处理。

    展开全文
  • 最近将一个比较大的历史表改造为分区表,中间用到了分区交换,为了搞清楚分区交换时WITHOUT VALIDATION与WITH VALIDATION以及是否禁用主键约束的区别, 用10046对各种情况进行了跟踪对比: 1....
    最近将一个比较大的历史表改造为分区表,中间用到了分区交换,为了搞清楚分区交换时WITHOUT VALIDATION与WITH VALIDATION以及是否禁用主键约束的区别,
    用10046对各种情况进行了跟踪对比:

    1.禁用主键约束+without validation
    ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 DISABLE CONSTRAINT PK_LOG_TRANSFER_EB_HIS KEEP INDEX;

    alter session set events '10046 trace name context forever,level 12';
    ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITHOUT VALIDATION;
    alter session set events '10046 trace name context off';

    ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 ENABLE CONSTRAINT PK_LOG_TRANSFER_EB_HIS;
    ***********************************************************************************************
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse       59      0.02       0.02          0          0          0           0
    Execute     76      0.06       0.12          5         59         39          16
    Fetch       69      0.02       0.26         26        138          0          69
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total      204      0.11       0.41         31        197         39          85

    Misses in library cache during parse: 9
    Misses in library cache during execute: 6

    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      Disk file operations I/O                        6        0.00          0.00
      db file sequential read                        31        0.03          0.30

    2.不禁用主键约束+without validation
    alter session set events '10046 trace name context forever,level 12';
    ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITHOUT VALIDATION;
    alter session set events '10046 trace name context off';
    ******************************************************************************
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse       56      0.02       0.02          0          0          0           0
    Execute     67      0.04       0.16          6         59         39          16
    Fetch       47      2.28       2.92       2408      26711          1          31
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total      170      2.36       3.11       2414      26770         40          47

    Misses in library cache during parse: 4

    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      Disk file operations I/O                        7        0.04          0.04
      db file scattered read                          1        0.01          0.01
      db file sequential read                      2407        0.07          0.98

    select /*+ first_rows(1) ordered */ 1
    from
     "SYS"."BC_LOG_TRANSFER_EB_HIS0" A ,"SYS"."BC_LOG_TRANSFER_EB_HIS1" B where
      "A"."CREDIT_ID" = "B"."CREDIT_ID" and "A"."TRAN_DATE" = "B"."TRAN_DATE" and
      "A"."CHANNEL" = "B"."CHANNEL" and (
      tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,B .rowid )  <  4
      or  tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,B .rowid )
      >  4 ) and tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,A
      .TRAN_DATE )  <>  4 and rownum < 2

    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.01       0.01          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      2.27       2.84       2399      26652          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        3      2.28       2.85       2399      26652          0           0

    Misses in library cache during parse: 1
    Optimizer mode: FIRST_ROWS
    Parsing user id: SYS   (recursive depth: 1)
    Number of plan statistics captured: 1

    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
    ---------- ---------- ----------  ---------------------------------------------------
             0          0          0  COUNT STOPKEY (cr=26652 pr=2399 pw=0 time=2842034 us)
             0          0          0   NESTED LOOPS  (cr=26652 pr=2399 pw=0 time=2842009 us cost=0 size=128 card=2)
             0          0          0    INDEX FULL SCAN PK_LOG_TRANSFER_EB_HIS0 (cr=26652 pr=2399 pw=0 time=2842003 us cost=0 size=78 card=3)(object id 80228)
             0          0          0    PARTITION RANGE ITERATOR PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=0 size=38 card=1)
             0          0          0     INDEX UNIQUE SCAN PK_LOG_TRANSFER_EB_HIS PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=0 size=38 card=1)(object id 80177)

    3.不禁用主键约束+with validation
    alter session set events '10046 trace name context forever,level 12';
    ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITH VALIDATION;
    alter session set events '10046 trace name context off';

    ************************************************************************************
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse       56      0.01       0.02          0          0          0           0
    Execute     83      0.08       0.15          5         59         39          16
    Fetch       63      1.76      24.95      12224      13159          1         207
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total      202      1.87      25.12      12229      13218         40         223

    Misses in library cache during parse: 9
    Misses in library cache during execute: 7

    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      Disk file operations I/O                        7        1.27          1.27
      db file sequential read                        11        1.88          5.88
      db file scattered read                        113        2.12         15.05

    select 1
    from
     "BC_LOG_TRANSFER_EB_HIS0" where
      TBL$OR$IDX$PART$NUM("BC_LOG_TRANSFER_EB_HIS1", 0, 3,1048576,"TRAN_DATE") !=
      :1

    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      1.74      17.38      12218      13055          1           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        3      1.75      17.38      12218      13055          1           0

    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Number of plan statistics captured: 1

    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
    ---------- ---------- ----------  ---------------------------------------------------
             0          0          0  TABLE ACCESS FULL BC_LOG_TRANSFER_EB_HIS0 (cr=13055 pr=12218 pw=0 time=17383845 us)
    结论:
    1.当禁用主键约束,不进行validation时,分区交换仅是数据字典级的操作,不会对表或索引进行扫描
    2.当不禁用主键约束,进行validation时,分区交换需要对表进行全表扫描,来做validation。
    3.当不禁用主键约束,不进行validation时,分区交换需要对主键索引进行扫描来完成主键约束的校验。

    因此,只有在禁用主键约束并不进行validation时,分区交换才是效率最快的。
      

    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-1069992/,如需转载,请注明出处,否则将追究法律责任。

    转载于:http://blog.itpub.net/10972173/viewspace-1069992/

    展开全文
  • 1.复制resources/lang/en 文件夹改为zh 2.validation.php文件的代码替换为: &lt;?... return [ /* |--------------------------------------------------------------------... | Validation Language Lines |...
  • Validation and verification are two important terms in project management; they seem very similar, and it’s easy to get them confused. 验收和核实是项目管理中的两个重要术语;它们看起来很相似,很容易...
  • 当然我们用正则表达式可以达到同样的效果,但是android Validation框架给我们提供了敏捷开发的途径,它支持的验证主要包括: 必填项 非空数据 仅数字 电子邮件 二选一必填验证 重复密码验证 H...
  • 模型评价的目的:通过模型评价,我们知道当前训练模型的好坏,泛化能力...https://cloud.tencent.com/developer/support-plan?invite_code=2l6rvdr2fmcko 转载于:https://www.cnblogs.com/ysugyl/p/8707887.html
  • 出现下列异常信息,异常关键报错:java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List org.aodous.mall.order.dao.OrderRepository....
  • "urn:acme:error:unauthorized","detail":"Error creating new authz :: Validations for new domains are disabled in the V1 API (https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430)",...
  • PLAN_TABLE_OUTPUT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -...
  • 看了 全面学习分区表及分区索引(10)--交换分区 这篇,最后是关于使用了without validation子句后,不会再验证数据的有效性。究竟使用不当会有什么结果,试下。 (所用的表是 全面学习分区表及分区索...
  • <div><p>Hi, is there a plan to provide translatable validation messages (using gettext like toolchain) ? <p>I know I could use custom fields (subclassing standard marshmallow Fields) that provide my ...
  • at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302) at org....
  • planning solution industrializing by problem file generation from templates 计划验证 plan validation 当扩展在 .pddl 文件(通常包含域或问题定义)或选定的PDDL命令被激活时,即可配置解释器(parser)或规划...
  • <p>Run <code>terraform plan</code> with an AWS provider configured to skip credential validation. <h3>Additional Context <p>Terraform output at the time of credential validation: <pre><code> ...
  • <p>The validation of the app service ARM template (Microsoft.Web/sites) suddenly started failing about 3 weeks ago on the basis of requiring an app service plan to exist. No other resource validation ...
  • : One common problem with internationalization and validation is where the validation rules may be different between locales. For example an alphanumeric test may vary. How is this handled? (please...
  • 3. Elements of a Test Plan

    2019-03-15 16:26:00
    This section describes the different parts of a test plan. A minimal test will consist of the Test Plan, a Thread Group and one or more Samplers. ...
  • 前面我们知道无法查出数据原因了,详情请参考http://blog.itpub.net/29487349/viewspace-1764438/【SQL】Oracle交换分区中参数without validation引发的症...
  • explain plan SET STATEMENT_NAME = 'select_emp' FOR select ename,sal,hiredate from emp where hiredate > '1980-12-17' and hiredate ; 方法二: 在SAP HANA Studio中打开SQL EDIT 选中要执行的SQL 语句,右键...
  • optimizer_capture_sql_plan_baselines optimizer_use_sql_plan_baselines create_stored_outline use_stored_outlines 2. 与profile和outline相比,更加灵活的控制手段 (1)可以有很多的计划被保存下来,只有...
  • Responsibilities include setting up test environment, designing and developing test plan, cases and test scripts for automated testing, participating in test execution, analyzing test run results, ...
  • Error: Error running plan: 1 error occurred: * module.swarm.module.certs.aws_route53_record.cert-record: 5 errors occurred: * module.swarm.module.certs.aws_route53_record.cert-record[0]: Resource &#...
  • JMeter Test Plan的组成部分之Assertions Assertions allow you to include some validation test on the response of your request made using a Sampler. They are inserted as a child component of a ...
  • Validation with Java and XML Schema

    千次阅读 2006-11-22 22:28:00
    Part 1Learn the value of data validation and why pure Java isnt the complete solution for handling itBy Brett Mclaughlin, JavaWorld.com, 09/08/00As technologies have matured and APIs for Java and o
  • In-App Purchases in iOS 6 Tutorial: Consumables and Receipt Validation  By Ray Wenderlich on December 13, 2012 Tweet Learn how to implement consumable In-App Purchas
  • webservice trainning plan

    2012-07-12 12:21:50
    ================================= ...webservice training plan ================================= 1. Write a HelloWorld with JAX-WS knowledge. 2. XSD, For the request, it should be contain below elemen

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 4,204
精华内容 1,681
关键字:

planvalidation