问:
How to solve java.lang.IllegalArgumentException: Could not locate named parameter [enteredValue], expecting one of [] in Hibernate 5.4.15 Final?
This is my StudentDaoImpl class.

```<code>package com.gavs.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;

import com.gavs.beans.Result;
import com.gavs.beans.Student;
import com.gavs.hibernate.until.HibernateUtil;

public class StudentDaoImpl implements StudentDao {

    @Override
    public List<Result> showRecords(Student s) {

        System.out.println("student name is:"+s.getName());

        SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

        Session session = sessionFactory.openSession();

                session.beginTransaction();

String hql="select s from com.gavs.beans.Student s where s.name = :nameparam";

      System.out.println(hql);

        Query q = session.createQuery(hql);
        q.setParameter("nameparam",s.getName());

        List<Student> r1= q.list();

        session.getTransaction().commit();
        session.close();
        return rl;
    }

}

</code>```

This is error message displayed :

```<code>Type Exception Report

Message Request processing failed; nested exception is java.lang.IllegalArgumentException: Could not locate named parameter [nameparam], expecting one of []

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Could not locate named parameter [nameparam], expecting one of []
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause

java.lang.IllegalArgumentException: Could not locate named parameter [nameparam], expecting one of []
    org.hibernate.query.internal.ParameterMetadataImpl.getNamedParameterDescriptor(ParameterMetadataImpl.java:229)
    org.hibernate.query.internal.ParameterMetadataImpl.getQueryParameter(ParameterMetadataImpl.java:198)
    org.hibernate.query.internal.QueryParameterBindingsImpl.getBinding(QueryParameterBindingsImpl.java:188)
    org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:490)
    org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:111)
    com.gavs.dao.StudentDaoImpl.showRecords(StudentDaoImpl.java:41)
    com.gavs.controllers.StudentControl.getStudentDetail(StudentControl.java:37)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:483)
    org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.

</code>```

Here is the error that occurred when I  debug the code,

```<code>Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name:   Apache Tomcat/9.0.31
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Feb 5 2020 19:32:12 UTC
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 9.0.31.0
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 8.1
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            6.3
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jdk1.8.0_31\jre
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_31-b13
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         F:\VCM\JpaSpring\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         D:\BACKUP 19.03.2020\Downloads\apache-tomcat-9.0.31
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:65187
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -javaagent:E:\eclipse1\eclipse\configuration\org.eclipse.osgi\418\0\.cp\lib\javaagent-shaded.jar
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=F:\VCM\JpaSpring\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=D:\BACKUP 19.03.2020\Downloads\apache-tomcat-9.0.31
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=F:\VCM\JpaSpring\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=D:\BACKUP 19.03.2020\Downloads\apache-tomcat-9.0.31\endorsed
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0].
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized [OpenSSL 1.1.1c  28 May 2019]
Jun 03, 2020 12:18:57 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jun 03, 2020 12:18:57 PM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [1,800] milliseconds
Jun 03, 2020 12:18:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
WARNING: Name = CRUDCode Property maxActive is not used in DBCP2, use maxTotal instead. maxTotal default value is 8. You have set value of "100" for "maxActive" property, which is being ignored.
Jun 03, 2020 12:18:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
WARNING: Name = CRUDCode Property maxWait is not used in DBCP2 , use maxWaitMillis instead. maxWaitMillis default value is -1. You have set value of "10000" for "maxWait" property, which is being ignored.
Jun 03, 2020 12:18:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
INFO: Name = CRUDCode Ignoring unknown property: value of "CRUDCode" for "global" property
Jun 03, 2020 12:18:57 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Jun 03, 2020 12:18:57 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.31]
Jun 03, 2020 12:19:02 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 03, 2020 12:19:02 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [338] milliseconds.
Jun 03, 2020 12:19:20 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 03, 2020 12:19:20 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jun 03, 2020 12:19:20 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring DispatcherServlet 'studentDetails'
Jun 03, 2020 12:19:20 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Initializing Servlet 'studentDetails'
Jun 03, 2020 12:19:23 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Completed initialization in 2866 ms
Jun 03, 2020 12:19:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Jun 03, 2020 12:19:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in [25,979] milliseconds
Student name is  Vishnu
Jun 03, 2020 12:28:17 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 5.4.17.Final
Jun 03, 2020 12:30:51 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
Jun 03, 2020 12:31:09 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/initialdb]
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=root, password=****}
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
Jun 03, 2020 12:32:24 PM org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator initiateService
WARN: HHH000342: Could not obtain connection to query metadata : null
Jun 03, 2020 12:32:26 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
Jun 03, 2020 12:32:29 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 08S01
Jun 03, 2020 12:32:30 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Jun 03, 2020 12:35:21 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [studentDetails] in context with path [/HibernateWithQuery] threw exception [Request processing failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]] with root cause
java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
    at sun.security.ssl.InputRecord.read(InputRecord.java:503)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:961)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375)
    at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:336)
    at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188)
    at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99)
    at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:325)
    at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:164)
    at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1342)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:157)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.addConnections(DriverManagerConnectionProviderImpl.java:331)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:250)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:228)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:369)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:98)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:73)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:107)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:473)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:84)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:689)
    at com.gavs.hibernateutil.HibernateUtil.getSessionFactory(HibernateUtil.java:23)
    at com.gavs.dao.StudentDaoImpl.showRecords(StudentDaoImpl.java:23)
    at com.gavs.controllers.StudentControl.getStudentDetail(StudentControl.java:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

</code>```

Also I want to mention that this is a dynamic web application where I have put the hibernate.cfg.xml file in the WEB-INF/classes folder within the WebContent folder. This is  A Spring MVC and hibernate project.
Thank You

答:
```<code>String hql="select new com.gavs.beans.Result(s.name as s_name,s.age as s_age,d.dept_name as d_name,c.college_name as c_name)"+
        " from com.gavs.beans.College c" +
        "join com.gavs.beans.Department d on d.institutes.college_id = c.college_id" +
        "join com.gavs.beans.Student s on s.departments.dept_id = d.dept_id" +
        "where s.name = :enteredValue";
</code>```

You have a missing space between dept_id and where s.name and a few other places (almost all lines are missing a blank character at the end). This probably plays a role in your issue. Consider storing your queries as resources (files) and read them from your code. Building SQL strings in another language is not very elegant (can be alright for simple queries).

The same query with corrected spaces:

String hql=
        "select new com.gavs.beans.Result(s.name as s_name,s.age as s_age,d.dept_name as d_name,c.college_name as c_name)"+
        " from com.gavs.beans.College c" +
        " join com.gavs.beans.Department d on d.institutes.college_id = c.college_id" +
        " join com.gavs.beans.Student s on s.departments.dept_id = d.dept_id " +
        " where s.name = :enteredValue";
```

Body:
This is my StudentDaoImpl class.

package com.gavs.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;

import com.gavs.beans.Result;
import com.gavs.beans.Student;
import com.gavs.hibernate.until.HibernateUtil;

public class StudentDaoImpl implements StudentDao {

    @Override
    public List<Result> showRecords(Student s) {

        System.out.println("student name is:"+s.getName());

        SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

        Session session = sessionFactory.openSession();

                session.beginTransaction();

String hql="select s from com.gavs.beans.Student s where s.name = :nameparam";

      System.out.println(hql);

        Query q = session.createQuery(hql);
        q.setParameter("nameparam",s.getName());

        List<Student> r1= q.list();

        session.getTransaction().commit();
        session.close();
        return rl;
    }

}

This is error message displayed :

Type Exception Report

Message Request processing failed; nested exception is java.lang.IllegalArgumentException: Could not locate named parameter [nameparam], expecting one of []

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Could not locate named parameter [nameparam], expecting one of []
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause

java.lang.IllegalArgumentException: Could not locate named parameter [nameparam], expecting one of []
    org.hibernate.query.internal.ParameterMetadataImpl.getNamedParameterDescriptor(ParameterMetadataImpl.java:229)
    org.hibernate.query.internal.ParameterMetadataImpl.getQueryParameter(ParameterMetadataImpl.java:198)
    org.hibernate.query.internal.QueryParameterBindingsImpl.getBinding(QueryParameterBindingsImpl.java:188)
    org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:490)
    org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:111)
    com.gavs.dao.StudentDaoImpl.showRecords(StudentDaoImpl.java:41)
    com.gavs.controllers.StudentControl.getStudentDetail(StudentControl.java:37)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:483)
    org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.

Here is the error that occurred when I  debug the code,

Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name:   Apache Tomcat/9.0.31
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Feb 5 2020 19:32:12 UTC
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 9.0.31.0
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 8.1
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            6.3
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jdk1.8.0_31\jre
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_31-b13
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         F:\VCM\JpaSpring\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         D:\BACKUP 19.03.2020\Downloads\apache-tomcat-9.0.31
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:65187
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -javaagent:E:\eclipse1\eclipse\configuration\org.eclipse.osgi\418\0\.cp\lib\javaagent-shaded.jar
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=F:\VCM\JpaSpring\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=D:\BACKUP 19.03.2020\Downloads\apache-tomcat-9.0.31
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=F:\VCM\JpaSpring\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=D:\BACKUP 19.03.2020\Downloads\apache-tomcat-9.0.31\endorsed
Jun 03, 2020 12:18:56 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0].
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
Jun 03, 2020 12:18:56 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized [OpenSSL 1.1.1c  28 May 2019]
Jun 03, 2020 12:18:57 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jun 03, 2020 12:18:57 PM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [1,800] milliseconds
Jun 03, 2020 12:18:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
WARNING: Name = CRUDCode Property maxActive is not used in DBCP2, use maxTotal instead. maxTotal default value is 8. You have set value of "100" for "maxActive" property, which is being ignored.
Jun 03, 2020 12:18:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
WARNING: Name = CRUDCode Property maxWait is not used in DBCP2 , use maxWaitMillis instead. maxWaitMillis default value is -1. You have set value of "10000" for "maxWait" property, which is being ignored.
Jun 03, 2020 12:18:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
INFO: Name = CRUDCode Ignoring unknown property: value of "CRUDCode" for "global" property
Jun 03, 2020 12:18:57 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Jun 03, 2020 12:18:57 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.31]
Jun 03, 2020 12:19:02 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 03, 2020 12:19:02 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [338] milliseconds.
Jun 03, 2020 12:19:20 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 03, 2020 12:19:20 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jun 03, 2020 12:19:20 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring DispatcherServlet 'studentDetails'
Jun 03, 2020 12:19:20 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Initializing Servlet 'studentDetails'
Jun 03, 2020 12:19:23 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Completed initialization in 2866 ms
Jun 03, 2020 12:19:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Jun 03, 2020 12:19:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in [25,979] milliseconds
Student name is  Vishnu
Jun 03, 2020 12:28:17 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 5.4.17.Final
Jun 03, 2020 12:30:51 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
Jun 03, 2020 12:31:09 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/initialdb]
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=root, password=****}
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
Jun 03, 2020 12:31:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
Jun 03, 2020 12:32:24 PM org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator initiateService
WARN: HHH000342: Could not obtain connection to query metadata : null
Jun 03, 2020 12:32:26 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
Jun 03, 2020 12:32:29 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 08S01
Jun 03, 2020 12:32:30 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Jun 03, 2020 12:35:21 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [studentDetails] in context with path [/HibernateWithQuery] threw exception [Request processing failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]] with root cause
java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
    at sun.security.ssl.InputRecord.read(InputRecord.java:503)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:961)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375)
    at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:336)
    at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188)
    at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99)
    at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:325)
    at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:164)
    at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1342)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:157)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.addConnections(DriverManagerConnectionProviderImpl.java:331)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:250)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:228)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:369)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:98)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:73)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:107)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:473)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:84)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:689)
    at com.gavs.hibernateutil.HibernateUtil.getSessionFactory(HibernateUtil.java:23)
    at com.gavs.dao.StudentDaoImpl.showRecords(StudentDaoImpl.java:23)
    at com.gavs.controllers.StudentControl.getStudentDetail(StudentControl.java:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

Also I want to mention that this is a dynamic web application where I have put the hibernate.cfg.xml file in the WEB-INF/classes folder within the WebContent folder. This is  A Spring MVC and hibernate project.
Thank You

Body:
String hql="select new com.gavs.beans.Result(s.name as s_name,s.age as s_age,d.dept_name as d_name,c.college_name as c_name)"+
        " from com.gavs.beans.College c" +
        "join com.gavs.beans.Department d on d.institutes.college_id = c.college_id" +
        "join com.gavs.beans.Student s on s.departments.dept_id = d.dept_id" +
        "where s.name = :enteredValue";

You have a missing space between dept_id and where s.name and a few other places (almost all lines are missing a blank character at the end). This probably plays a role in your issue. Consider storing your queries as resources (files) and read them from your code. Building SQL strings in another language is not very elegant (can be alright for simple queries).

The same query with corrected spaces:

String hql=
        "select new com.gavs.beans.Result(s.name as s_name,s.age as s_age,d.dept_name as d_name,c.college_name as c_name)"+
        " from com.gavs.beans.College c" +
        " join com.gavs.beans.Department d on d.institutes.college_id = c.college_id" +
        " join com.gavs.beans.Student s on s.departments.dept_id = d.dept_id " +
        " where s.name = :enteredValue";


来源: stackexchange

问:
How to pass data from HTML page to PHP script without reloading the page?
Goal: I want to Hide "myForm" div when data successfully post to the database and the "section" div will show component when submit button will clicked, its working properly.

Problem / Requirement: Problem is that data not posting to the database, how can i solve this problem to save data to the database and show / hide div after that database operation.

Note: I don't want to reload my page.

HTML Code:

```<code><div id="section" style="display: none;">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae cupiditate culpa reprehenderit animi,
        numquam distinctio repellendus debitis fugit unde consequatur eum magni illo minima amet quidem omnis veniam
        commodi voluptatum!
    </p>
</div>
<div id="myForm">
    <form id="testForm" method="post" action="#">
        <input id="form_name" type="text" name="name" class="form-control">
        <input type="submit" name="submit" class="btn btn-send" value="submit">
    </form>
</div>
</code>```

JavaScript Code:

```<code>const sectionDiv = document.getElementById('section');
const form = document.getElementById('myForm');

form.addEventListener('submit', function (e) {
    e.preventDefault();

    // Please suggest the flow and code for call PHP script from here

    form.style.display = 'none';
    sectionDiv.style.display = 'block';
});
</code>```

Please suggest flow and process in above Javascript code for how to pass my data to below PHP script..

PHP Code:

```<code>include("db.php");

if (isset($_POST['submit']))
{
    $form_name=  $_POST['name'];
    $query = "INSERT INTO `test` (`xxname`) VALUES ('$form_name')";
    if(mysqli_query($conn, $query))
    {
        echo "asdfghjkl";
    }
    else
    {
        echo "ERROR: Could not able to execute $query. " . mysqli_error($conn);
    }
}
</code>```

Thanks for your help in advance..

答:
You have to pass your client request to server side through AJAX, call your server script using AJAX from your javascript code function:</p>

```<code>const sectionDiv = document.getElementById('section');
const form = document.getElementById('myForm');

form.addEventListener('submit', function (e) {

    e.preventDefault();

    let serData = form[0].serialize();

    // Add your AJAX Code here
    $.ajax({
        url: "/form.php", // your PHP script's file name
        type: "post",
        data: serData, // pass your fields here
        success: function(data){
            // do your actions here
            // you can put your condition here like if( data.status == true ) then success other wise failure
            form.style.display = 'none';
            sectionDiv.style.display = 'block';
        },
        error: function (request, status, error) {
             // console your error here
             console.log(error);
        }
    });

});
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Goal: I want to Hide "myForm" div when data successfully post to the database and the "section" div will show component when submit button will clicked, its working properly.

Problem / Requirement: Problem is that data not posting to the database, how can i solve this problem to save data to the database and show / hide div after that database operation.

Note: I don't want to reload my page.

HTML Code:

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae cupiditate culpa reprehenderit animi,
        numquam distinctio repellendus debitis fugit unde consequatur eum magni illo minima amet quidem omnis veniam
        commodi voluptatum!

    <form id="testForm" method="post" action="#">
        <input id="form_name" type="text" name="name" class="form-control">
        <input type="submit" name="submit" class="btn btn-send" value="submit">
    </form>

JavaScript Code:

const sectionDiv = document.getElementById('section');
const form = document.getElementById('myForm');

form.addEventListener('submit', function (e) {
    e.preventDefault();

    // Please suggest the flow and code for call PHP script from here

    form.style.display = 'none';
    sectionDiv.style.display = 'block';
});

Please suggest flow and process in above Javascript code for how to pass my data to below PHP script..

PHP Code:

include("db.php");

if (isset($_POST['submit']))
{
    $form_name=  $_POST['name'];
    $query = "INSERT INTO `test` (`xxname`) VALUES ('$form_name')";
    if(mysqli_query($conn, $query))
    {
        echo "asdfghjkl";
    }
    else
    {
        echo "ERROR: Could not able to execute $query. " . mysqli_error($conn);
    }
}

Thanks for your help in advance..

Body:
You have to pass your client request to server side through AJAX, call your server script using AJAX from your javascript code function:

const sectionDiv = document.getElementById('section');
const form = document.getElementById('myForm');

form.addEventListener('submit', function (e) {

    e.preventDefault();

    let serData = form[0].serialize();

    // Add your AJAX Code here
    $.ajax({
        url: "/form.php", // your PHP script's file name
        type: "post",
        data: serData, // pass your fields here
        success: function(data){
            // do your actions here
            // you can put your condition here like if( data.status == true ) then success other wise failure
            form.style.display = 'none';
            sectionDiv.style.display = 'block';
        },
        error: function (request, status, error) {
             // console your error here
             console.log(error);
        }
    });

});


问:
Why am i getting this error from getSource method in MouseAdapter?
I was trying to change the text "Java" to "Love Java" by using MouseAdapter. The text "Java" comes out when mouseEntered and "Love Java" comes out when mouseExited. So I created class MyMouse extends MouseAdapter and trying to use the methods.

But there is the error message "The method getSource() is undefined for the type MouseEvent". When I searched it, this code is nothing wrong with it but I don't know why I'm getting this error message, and also of course the result is not working.

```<code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MouseEvent extends JFrame{

    MouseEvent(){
        setTitle("Practicing mouse event");
        setLayout(new FlowLayout());
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JLabel lb = new JLabel("Java");
        MyMouse mym = new MyMouse();
        lb.addMouseListener(mym);

        lb.setSize(300,100);
        add(lb);
        setSize(400,200);
        setVisible(true);
    }
    public static void main(String[] args) {
        new MouseEvent();
    }
}

class MyMouse extends MouseAdapter{
    public void mouseEntered(MouseEvent e) {
        JLabel lb = (JLabel)e.getSource();
        lb.setText("Love Java");
    }
    public void mouseExited(MouseEvent e) {
        JLabel lb = (JLabel)e.getSource();
        lb.setText("Java");
    }
}
</code>```

答:
The MouseEvent object e you are using inside public void mouseEntered(MouseEvent e) or public void mouseExited(MouseEvent e) should be from java.awt.event.MouseEvent.

But, as you have named your main class also as MouseEvent, in that case the MouseEvent object e inside mouseEntered() and mouseExited() methods are actually the object of your main class. That's why it was searching for getSource() method in your main class and failed.

Please change your main class name to something other than MouseEvent. For example:

```<code>public class MyMouseEvent extends JFrame {

    MyMouseEvent() {
...
...
    public static void main(String[] args) {
        new MyMouseEvent();
...
</code>```

Body:
I was trying to change the text "Java" to "Love Java" by using MouseAdapter. The text "Java" comes out when mouseEntered and "Love Java" comes out when mouseExited. So I created class MyMouse extends MouseAdapter and trying to use the methods.

But there is the error message "The method getSource() is undefined for the type MouseEvent". When I searched it, this code is nothing wrong with it but I don't know why I'm getting this error message, and also of course the result is not working.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MouseEvent extends JFrame{

    MouseEvent(){
        setTitle("Practicing mouse event");
        setLayout(new FlowLayout());
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JLabel lb = new JLabel("Java");
        MyMouse mym = new MyMouse();
        lb.addMouseListener(mym);

        lb.setSize(300,100);
        add(lb);
        setSize(400,200);
        setVisible(true);
    }
    public static void main(String[] args) {
        new MouseEvent();
    }
}

class MyMouse extends MouseAdapter{
    public void mouseEntered(MouseEvent e) {
        JLabel lb = (JLabel)e.getSource();
        lb.setText("Love Java");
    }
    public void mouseExited(MouseEvent e) {
        JLabel lb = (JLabel)e.getSource();
        lb.setText("Java");
    }
}

Body:
The MouseEvent object e you are using inside public void mouseEntered(MouseEvent e) or public void mouseExited(MouseEvent e) should be from java.awt.event.MouseEvent.

But, as you have named your main class also as MouseEvent, in that case the MouseEvent object e inside mouseEntered() and mouseExited() methods are actually the object of your main class. That's why it was searching for getSource() method in your main class and failed.

Please change your main class name to something other than MouseEvent. For example:

public class MyMouseEvent extends JFrame {

    MyMouseEvent() {
...
...
    public static void main(String[] args) {
        new MyMouseEvent();
...


问:
How to calculate moving sums of rows of unique observation in R (example provided)?
I have a data.frame called df , and I am trying to count unique devices on a moving hour basis with a gap of 4 minutes as shown in expected_df . I have provided an example below . I did not find any query meeting my requirements , hence this ...

Given data frame

```<code>df<-data.frame(customer=rep("xyz",19),
           device=c("a","a","a","a","a","a","b","b","b","b","b","b","c","c","c","c","c","c","c"),
           local_date=rep("2020-06-04",19),
           local_hour=rep(4,19),
           local_minute=c(1:6,4:9,6:12))
</code>```

Expected data frame

```<code>expected_df<-data.frame(customer=rep("xyz",8),local_hour=rep(4,8),
                    local_date=rep("2020-06-04",8),
                    local_minute_bucket=c("1_5","2_6","3_7","4_9","5_9","6_10","7_11","8_12"),
                    unique_devices=c(2,3,3,3,3,3,2,2))
</code>```

答:
here is a data.table approach

```<code>#create an data.table with intervals
library( data.table )
library( lubridate )

#make df a data.table
setDT( df )
#create a proper timestamp
df[, timestamp := as.POSIXct( paste0( local_date, "T", local_hour, ":", local_minute ),
                              format = "%Y-%m-%dT%H:%M" )]
#crete a data.table with intervals
dt.intervals <- data.table( start = seq( min( df$timestamp, na.rm = TRUE ),
                                         max( df$timestamp, na.rm = TRUE ),
                                         by = "1 min" ) )
dt.intervals[, end := start %m+% minutes(4)]
dt.intervals[, local_minute_bucket := paste( format( start, "%M"), format( end, "%M"), sep = "_" )]
#join
ans <- dt.intervals[ df, on = .( start <= timestamp, end >= timestamp ), allow.cartesian = TRUE ]
#and summarise
ans[, .(unique_devides = uniqueN( device )), by = .(customer, local_hour, local_date, local_minute_bucket )]

#    customer local_hour local_date local_minute_bucket unique_devides
# 1:      xyz          4 2020-06-04               01_05              2
# 2:      xyz          4 2020-06-04               02_06              3
# 3:      xyz          4 2020-06-04               03_07              3
# 4:      xyz          4 2020-06-04               04_08              3
# 5:      xyz          4 2020-06-04               05_09              3
# 6:      xyz          4 2020-06-04               06_10              3
# 7:      xyz          4 2020-06-04               07_11              2
# 8:      xyz          4 2020-06-04               08_12              2
# 9:      xyz          4 2020-06-04               09_13              2
#10:      xyz          4 2020-06-04               10_14              1
#11:      xyz          4 2020-06-04               11_15              1
#12:      xyz          4 2020-06-04               12_16              1
</code>```

Body:
I have a data.frame called df , and I am trying to count unique devices on a moving hour basis with a gap of 4 minutes as shown in expected_df . I have provided an example below . I did not find any query meeting my requirements , hence this ...

Given data frame

df<-data.frame(customer=rep("xyz",19),
           device=c("a","a","a","a","a","a","b","b","b","b","b","b","c","c","c","c","c","c","c"),
           local_date=rep("2020-06-04",19),
           local_hour=rep(4,19),
           local_minute=c(1:6,4:9,6:12))

Expected data frame

expected_df<-data.frame(customer=rep("xyz",8),local_hour=rep(4,8),
                    local_date=rep("2020-06-04",8),
                    local_minute_bucket=c("1_5","2_6","3_7","4_9","5_9","6_10","7_11","8_12"),
                    unique_devices=c(2,3,3,3,3,3,2,2))

Body:
here is a data.table approach

#create an data.table with intervals
library( data.table )
library( lubridate )

#make df a data.table
setDT( df )
#create a proper timestamp
df[, timestamp := as.POSIXct( paste0( local_date, "T", local_hour, ":", local_minute ),
                              format = "%Y-%m-%dT%H:%M" )]
#crete a data.table with intervals
dt.intervals <- data.table( start = seq( min( df$timestamp, na.rm = TRUE ),
                                         max( df$timestamp, na.rm = TRUE ),
                                         by = "1 min" ) )
dt.intervals[, end := start %m+% minutes(4)]
dt.intervals[, local_minute_bucket := paste( format( start, "%M"), format( end, "%M"), sep = "_" )]
#join
ans <- dt.intervals[ df, on = .( start <= timestamp, end >= timestamp ), allow.cartesian = TRUE ]
#and summarise
ans[, .(unique_devides = uniqueN( device )), by = .(customer, local_hour, local_date, local_minute_bucket )]

#    customer local_hour local_date local_minute_bucket unique_devides
# 1:      xyz          4 2020-06-04               01_05              2
# 2:      xyz          4 2020-06-04               02_06              3
# 3:      xyz          4 2020-06-04               03_07              3
# 4:      xyz          4 2020-06-04               04_08              3
# 5:      xyz          4 2020-06-04               05_09              3
# 6:      xyz          4 2020-06-04               06_10              3
# 7:      xyz          4 2020-06-04               07_11              2
# 8:      xyz          4 2020-06-04               08_12              2
# 9:      xyz          4 2020-06-04               09_13              2
#10:      xyz          4 2020-06-04               10_14              1
#11:      xyz          4 2020-06-04               11_15              1
#12:      xyz          4 2020-06-04               12_16              1


问:
radio button value for add
Can anyone say if this code is right or wrong?

```<code>If(isset($_POST) && ($_POST[‘GET_PAYMENT’] == ‘1’))
{
    $totalAmount = $_POST[‘GET_PAYMENT’]; //Total amount
    $checkbox_id = $_POST[‘VALUE’]; // The radio button value

    /* Here get the amount values (3,5.5 or 10) from

    Database based on the $checkbox_id and store it in

    $amount variable*/

    $total_amount = $amount + $totalAmount;

    Echo $total_amount;

}
</code>```

this is for my radio button which has seperate value when i clicks any one button it will be add with that previous value

javascript

Javascript function

```<code>Function getPaymentVal()
{

Var checkboxVal = ‘’;

checkboxVal = $("input[@name=’rmr’]:checked").val();

$.ajax({
   type: "POST",
   url: "ajax.php",
   data: "GET_PAYMENT=1&VALUE=”+ checkboxVal,
   success: function(total_amount)
   {
    //Assigning the final value to the hidden value here
    $(‘#totalamount’).val(total_amount);

    //Here changing the display of total amount
    $(‘#repair_total_amount’).html(“Total <span class="repair-finalamount-txt">£ ”+ total_amount+”</span>”);

   }
 });

}
</code>```

答: Look at this code, I think it's possible because of the " and ' characters which is pasted poorly from another different-character-encoding source. You should type it again to see if the errors happen.

ContentLicense: CC BY-SA 2.5

Title: radio button value for add

Body:
Can anyone say if this code is right or wrong?

If(isset($_POST) && ($_POST[‘GET_PAYMENT’] == ‘1’))
{
    $totalAmount = $_POST[‘GET_PAYMENT’]; //Total amount
    $checkbox_id = $_POST[‘VALUE’]; // The radio button value

    /* Here get the amount values (3,5.5 or 10) from

    Database based on the $checkbox_id and store it in

    $amount variable*/

    $total_amount = $amount + $totalAmount;

    Echo $total_amount;

}

this is for my radio button which has seperate value when i clicks any one button it will be add with that previous value

javascript

Javascript function

Function getPaymentVal()
{

Var checkboxVal = ‘’;

checkboxVal = $("input[@name=’rmr’]:checked").val();

$.ajax({
   type: "POST",
   url: "ajax.php",
   data: "GET_PAYMENT=1&VALUE=”+ checkboxVal,
   success: function(total_amount)
   {
    //Assigning the final value to the hidden value here
    $(‘#totalamount’).val(total_amount);

    //Here changing the display of total amount
    $(‘#repair_total_amount’).html(“Total £ ”+ total_amount+””);

   }
 });

}

ContentLicense: CC BY-SA 3.0