问:
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

答:
Please remove the keyword as from your hql and have a try?

```<code>String hql="select new com.gavs.beans.Result(s.name,s.age,d.dept_name,c.college_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>```

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:
Please remove the keyword as from your hql and have a try?

String hql="select new com.gavs.beans.Result(s.name,s.age,d.dept_name,c.college_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 can access particular String from Resource file with using Resource.getString(id) in Android
I want to know that I have the string.xml Resource file which contains status messages. Now I want to process them according their id. I have written the following code but it fails on Message = res.getString(Msgid); and logs Resource not found Exception.

Can any one help me?

```<code>public void FileStatusMsg(int Msgid)

        {
                String Message = null;
                Resources res = this.getResources();

                Message = res.getString(Msgid);

                //Display Status Messages..
                AlertDialog.Builder builder = new AlertDialog.Builder(OfficeLinQ.this);
                builder.setMessage(Message).setCancelable(false).setPositiveButton(
                        "OK", new DialogInterface.OnClickListener()
                        {
                            public void onClick(DialogInterface dialog, int id)
                            {
                                dialog.cancel();
                            }
                        });
                AlertDialog alert = builder.create();
                alert.show();
            }
</code>```

答:
Suppose you have a value

```<code><string name="msg">Message</string>
</code>```

inside strings.xml.

To access this value, in your activity give:

```<code>this.getText(R.string.msg).toString()
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I want to know that I have the string.xml Resource file which contains status messages. Now I want to process them according their id. I have written the following code but it fails on Message = res.getString(Msgid); and logs Resource not found Exception.

Can any one help me?

public void FileStatusMsg(int Msgid)

        {
                String Message = null;
                Resources res = this.getResources();

                Message = res.getString(Msgid);

                //Display Status Messages..
                AlertDialog.Builder builder = new AlertDialog.Builder(OfficeLinQ.this);
                builder.setMessage(Message).setCancelable(false).setPositiveButton(
                        "OK", new DialogInterface.OnClickListener()
                        {
                            public void onClick(DialogInterface dialog, int id)
                            {
                                dialog.cancel();
                            }
                        });
                AlertDialog alert = builder.create();
                alert.show();
            }

Body:
Suppose you have a value

<string name="msg">Message</string>

inside strings.xml.

To access this value, in your activity give:

this.getText(R.string.msg).toString()


问:
How do I make a progress bar for loading pandas DataFrame from a large xlsx file?
from https://pypi.org/project/tqdm/:

```<code>import pandas as pd
import numpy as np
from tqdm import tqdm

df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))
tqdm.pandas(desc="my bar!")p`
df.progress_apply(lambda x: x**2)
</code>```

I took this code and edited it so that I create a DataFrame from load_excel rather than using random numbers:

```<code>import pandas as pd
from tqdm import tqdm
import numpy as np

filename="huge_file.xlsx"
df = pd.DataFrame(pd.read_excel(filename))
tqdm.pandas()
df.progress_apply(lambda x: x**2)
</code>```

This gave me an error, so I changed df.progress_apply to this:

```<code>df.progress_apply(lambda x: x)
</code>```

Here is the final code:

```<code>import pandas as pd
from tqdm import tqdm
import numpy as np

filename="huge_file.xlsx"
df = pd.DataFrame(pd.read_excel(filename))
tqdm.pandas()
df.progress_apply(lambda x: x)
</code>```

This results in a progress bar, but it doesn't actually show any progress, rather it loads the bar, and when the operation is done it jumps to 100%, defeating the purpose.

My question is this:  How do I make this progress bar work?

What does the function inside of progress_apply actually do?

Is there a better approach?  Maybe an alternative to tqdm?

Any help is greatly appreciated.

答:
DISCLAIMER: This works only with xlrd engine and is not thoroughly tested!

How it works? We monkey-patch xlrd.xlsx.X12Sheet.own_process_stream method that is responsible to load sheets from file-like stream. We supply own stream, that contains our progress bar. Each sheet has it's own progress bar.

When we want the progress bar, we use load_with_progressbar() context manager and then do pd.read_excel('<FILE.xlsx>').

```<code>import xlrd
from tqdm import tqdm
from io import RawIOBase
from contextlib import contextmanager

class progress_reader(RawIOBase):
    def __init__(self, zf, bar):
        self.bar = bar
        self.zf = zf

    def readinto(self, b):
        n = self.zf.readinto(b)
        self.bar.update(n=n)
        return n

@contextmanager
def load_with_progressbar():

    def my_get_sheet(self, zf, *other, **kwargs):
        with tqdm(total=zf._orig_file_size) as bar:
            sheet = _tmp(self, progress_reader(zf, bar), **kwargs)
        return sheet

    _tmp = xlrd.xlsx.X12Sheet.own_process_stream

    try:
        xlrd.xlsx.X12Sheet.own_process_stream = my_get_sheet
        yield
    finally:
        xlrd.xlsx.X12Sheet.own_process_stream = _tmp

import pandas as pd

with load_with_progressbar():
    df = pd.read_excel('sample2.xlsx')

print(df)
</code>```

Screenshot of progress bar:

ContentLicense: CC BY-SA 4.0

Body:
from https://pypi.org/project/tqdm/:

import pandas as pd
import numpy as np
from tqdm import tqdm

df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))
tqdm.pandas(desc="my bar!")p`
df.progress_apply(lambda x: x**2)

I took this code and edited it so that I create a DataFrame from load_excel rather than using random numbers:

import pandas as pd
from tqdm import tqdm
import numpy as np

filename="huge_file.xlsx"
df = pd.DataFrame(pd.read_excel(filename))
tqdm.pandas()
df.progress_apply(lambda x: x**2)

This gave me an error, so I changed df.progress_apply to this:

df.progress_apply(lambda x: x)

Here is the final code:

import pandas as pd
from tqdm import tqdm
import numpy as np

filename="huge_file.xlsx"
df = pd.DataFrame(pd.read_excel(filename))
tqdm.pandas()
df.progress_apply(lambda x: x)

This results in a progress bar, but it doesn't actually show any progress, rather it loads the bar, and when the operation is done it jumps to 100%, defeating the purpose.

My question is this:  How do I make this progress bar work?

What does the function inside of progress_apply actually do?

Is there a better approach?  Maybe an alternative to tqdm?

Any help is greatly appreciated.

Body:
DISCLAIMER: This works only with xlrd engine and is not thoroughly tested!

How it works? We monkey-patch xlrd.xlsx.X12Sheet.own_process_stream method that is responsible to load sheets from file-like stream. We supply own stream, that contains our progress bar. Each sheet has it's own progress bar.

When we want the progress bar, we use load_with_progressbar() context manager and then do pd.read_excel('<FILE.xlsx>').

import xlrd
from tqdm import tqdm
from io import RawIOBase
from contextlib import contextmanager

class progress_reader(RawIOBase):
    def __init__(self, zf, bar):
        self.bar = bar
        self.zf = zf

    def readinto(self, b):
        n = self.zf.readinto(b)
        self.bar.update(n=n)
        return n

@contextmanager
def load_with_progressbar():

    def my_get_sheet(self, zf, *other, **kwargs):
        with tqdm(total=zf._orig_file_size) as bar:
            sheet = _tmp(self, progress_reader(zf, bar), **kwargs)
        return sheet

    _tmp = xlrd.xlsx.X12Sheet.own_process_stream

    try:
        xlrd.xlsx.X12Sheet.own_process_stream = my_get_sheet
        yield
    finally:
        xlrd.xlsx.X12Sheet.own_process_stream = _tmp

import pandas as pd

with load_with_progressbar():
    df = pd.read_excel('sample2.xlsx')

print(df)

Screenshot of progress bar:


问:
NSOperation and reloading the parser
I have a parser class that is subclass of NSOperation. It is used to parse the xml and table view is reloaded when the parse is completed. I have a refresh UIBarButtonItem that is used to call the parser and parse the new xml from the link again.

```<code>-(void)refresh {
   [self.queue cancelAllOperations]; //cancel all the current operations
   [self.queue release];
   self.queue=nil;
   self.arrayOfAllPhotos = nil; // The array to load table view
   [self performSelectorOnMainThread:@selector(doItAgain) withObject:nil waitUntilDone:NO];
</code>```

}

```<code>-(void)doItAgain {
   [tableView reloadData];
   NSURL *url = [NSURL URLWithString:@"some url"];
   NSURLRequest *request = [NSURLRequest requestWithURL:url];
   NSURLConnection *aconnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
   self.myConnection = aconnection;
   [aconnection release];
</code>```

}

But, as press refresh button, the app crashes with no message. How do I release the NSOperationQueue and start a new parsing again to load data ?

答:
if queue is defined as retained property then here:

```<code>   [self.queue release];
   self.queue=nil;
</code>```

you are overreleasing queue: it is first released manually, then in the setter method since queue is still not nil and different than nil it will be again released and set to nil and second release will cause the crash.

this will be enough:

```<code>   self.queue=nil;
</code>```

Title: NSOperation and reloading the parser

Body:
I have a parser class that is subclass of NSOperation. It is used to parse the xml and table view is reloaded when the parse is completed. I have a refresh UIBarButtonItem that is used to call the parser and parse the new xml from the link again.

-(void)refresh {
   [self.queue cancelAllOperations]; //cancel all the current operations
   [self.queue release];
   self.queue=nil;
   self.arrayOfAllPhotos = nil; // The array to load table view
   [self performSelectorOnMainThread:@selector(doItAgain) withObject:nil waitUntilDone:NO];

}

-(void)doItAgain {
   [tableView reloadData];
   NSURL *url = [NSURL URLWithString:@"some url"];
   NSURLRequest *request = [NSURLRequest requestWithURL:url];
   NSURLConnection *aconnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
   self.myConnection = aconnection;
   [aconnection release];

}

But, as press refresh button, the app crashes with no message. How do I release the NSOperationQueue and start a new parsing again to load data ?

Body:
if queue is defined as retained property then here:

   [self.queue release];
   self.queue=nil;

you are overreleasing queue: it is first released manually, then in the setter method since queue is still not nil and different than nil it will be again released and set to nil and second release will cause the crash.

this will be enough:

   self.queue=nil;


问:
Recursive summing up elements of a two-dimensional array?
I am an algorithm beginner and just started reading "Data Structure and Algorithms in Java" by Michael Rich. He presents a binary recursion based function called "BinarySum(A,i,n)".

```<code> BinarySum(A,i,n)
 Input:An array A and integer i and n
 Output: The sum of n integers in A starting and index i
 if n==1 then
  return A[i];
 return BinarySum(A,i,[n/2])+BinarySum(A,i+[n/2],[n/2])
</code>```

And we will initially start the call by BinarySum(A,0,n).

In the excercise that follows, there is a question asking me to describe a way to use recursion to add all the elements of a n*n two dimensional array of integers. The hint he gives is we can follow the style of BinarySum(A,i,n) by using two recursive calls.

I am stuck on this, I could think of the solution like loop through each row of n*n matrix, then for each row, I call BinarySum(A,i,n), then sum together. But I really don't think that is the purpose of this exercise.

Had thought about other possible solutions, but I am stuck on using recursion achieving it. Could experts give some hints? Thanks.

答:
```<code>  // Break the 2D array into shorter arrays via rows
  // Initial n is A.length - 1
  public int binarySum(int[][] A, int j, int n){
    if(j > n) return 0;
    if(j == n ) return binarySum(A[j], 0, A[j].length - 1);
    int m = (j + n) / 2;
    return binarySum(A, j, m) + binarySum(A, m + 1, n);
  }

  //Break the array into smaller arrays via cols
  public int binarySum(int[] A, int i, int n){
    if( i > n) return 0;
    if(i == n) return A[i];
    int m = (i + n) / 2;
    return binarySum(A, i, m) + binarySum(A, m+1, n);
  }
</code>```

Body:
I am an algorithm beginner and just started reading "Data Structure and Algorithms in Java" by Michael Rich. He presents a binary recursion based function called "BinarySum(A,i,n)".

 BinarySum(A,i,n)
 Input:An array A and integer i and n
 Output: The sum of n integers in A starting and index i
 if n==1 then
  return A[i];
 return BinarySum(A,i,[n/2])+BinarySum(A,i+[n/2],[n/2])

And we will initially start the call by BinarySum(A,0,n).

In the excercise that follows, there is a question asking me to describe a way to use recursion to add all the elements of a n*n two dimensional array of integers. The hint he gives is we can follow the style of BinarySum(A,i,n) by using two recursive calls.

I am stuck on this, I could think of the solution like loop through each row of n*n matrix, then for each row, I call BinarySum(A,i,n), then sum together. But I really don't think that is the purpose of this exercise.

Had thought about other possible solutions, but I am stuck on using recursion achieving it. Could experts give some hints? Thanks.


问:
setting attribute value of an element as a numeric value stored in a variable in jQuery
```<code>jQuery(".slick-next").click(function(){
    var i = parseInt(i)+1;
    jQuery("[data-slick-index=i]").addClass("slick-current");
});
</code>```

I want to add a class slick-current to the element which has attribute value i which is a numeric value.I tried the above code,but failed.Anyone pls help.

答:
You can do it like this:

```<code> jQuery(".slick-next").click(function(){
    var i = parseInt(i)+1;
    jQuery("[data-slick-index=" + i + "]").addClass("slick-current");
 });
</code>```

Note that I'm unsure about your variable declaration for i: That i is declared as parseInt(i) suggests that i is already declared before to have any value at all, and in this case you would declare the same variable twice.

Body:
jQuery(".slick-next").click(function(){
    var i = parseInt(i)+1;
    jQuery("[data-slick-index=i]").addClass("slick-current");
});

I want to add a class slick-current to the element which has attribute value i which is a numeric value.I tried the above code,but failed.Anyone pls help.

Body:
You can do it like this:

 jQuery(".slick-next").click(function(){
    var i = parseInt(i)+1;
    jQuery("[data-slick-index=" + i + "]").addClass("slick-current");
 });

Note that I'm unsure about your variable declaration for i: That i is declared as parseInt(i) suggests that i is already declared before to have any value at all, and in this case you would declare the same variable twice.


问:
Paginate one page with different tabs Laravel
I want to paginate in a blade file different tabs , each tabs show different collections of object but each time i go to next page in one page it redirects to the first tab and also paginate each tab not just the one i wanted to paginate.

Blade Part Where i have tabs

```<code>    <div class="container">
        <div class="section-bg-color">
            <div class="row">
                <div class="col-lg-12">
                    <!-- My Account Page Start -->
                    <div class="myaccount-page-wrapper">
                        <!-- My Account Tab Menu Start -->
                        <div class="row">
                            <div class="col-lg-3 col-md-4">
                                <div class="myaccount-tab-menu nav" role="tablist" id="myTab">
                                    <a href="#dashboad" class="active" data-toggle="tab"><i class="fa fa-dashboard"></i>Dashboard</a>
                                    <a href="#users" data-toggle="tab"><i class="fa fa-user"></i>Gestione Utenti</a>
                                    <a href="#comics" data-toggle="tab"><i class="fa fa-book"></i>Gestione Fumetti</a>
                                    <a href="#reviews" data-toggle="tab"><i class="fa fa-map-marker"></i>Gestione Recensione</a>
                                </div>
                            </div>

                            <!-- My Account Tab Menu End -->
                            <!-- My Account Tab Content Start -->
                            <div class="col-lg-9 col-md-8">
                                <div class="tab-content" id="myaccountContent">
                                    <!-- Single Tab Content Start -->
                                    <div class="tab-pane fade show active" id="dashboad" role="tabpanel">
                                        <div class="myaccount-content">
                                            <h5>Dashboard</h5>
                                            <div class="welcome">
                                                <p>Ciao, <strong>{{ $user->username }}</strong>! (Non sei <strong>{{ $user->username }}</strong>?<a href="{{ url('/logout') }}" class="logout"> Logout</a>)</p>
                                            </div>
                                            <p class="mb-0">I tuoi dati:</p>
                                            <p class="mb-0">E-mail:   <strong>{{ $user->email }} </strong></p>
                                        </div>
                                        <div class="myaccount-content">
                                            @php
                                                $notifications = \App\Http\Controllers\NotificationController::getNotification($user->id);
                                            @endphp
                                            <h5>Notifiche</h5>
                                            @if($notifications->count() < 1)
                                                <div class="myaccount-content">
                                                    <h5>Non ci sono ancora notifiche</h5>
                                                </div>
                                            @else
                                                <div class="myaccount-table table-responsive text-center">
                                                    <table class="table table-bordered">
                                                        <thead class="thead-light">
                                                        <tr>
                                                            <th>Data</th>
                                                            <th>testo</th>
                                                            <th>stato</th>
                                                            <th>Action</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        @foreach($notifications as $notification)
                                                            <tr>
                                                                <td>{{ $notification->date }}</td>
                                                                <td>
                                                                    @if(strlen($notification->notification_text) > 50 )
                                                                        @php
                                                                            $subnotification = substr($notification->notification_text, 0, 50)
                                                                        @endphp
                                                                        {{ $subnotification }}...
                                                                    @else
                                                                        {{ $notification->notification_text }}
                                                                    @endif
                                                                </td>
                                                                @if($notification->state == 1)
                                                                    <td>
                                                                        Letto
                                                                    </td>
                                                                    <td>
                                                                        <a href="{{ url('/accountArea') }}" class="btn btn-sqr">View</a>
                                                                    </td>
                                                                @else
                                                                    <td>
                                                                        Non letto
                                                                    </td>
                                                                    <td>
                                                                        <a href="{{ route('notificaLetta', ['id' => $notification->id]) }}" class="btn btn-sqr">View</a>
                                                                    </td>
                                                                @endif
                                                            </tr>
                                                        @endforeach
                                                        </tbody>
                                                    </table>
                                                </div>
                                            @endif
                                        </div>
                                    </div>
                                    <!-- Single Tab Content End -->
                                @if(session('message'))
                                    {{session('message')}}
                                @endif
                                    <!-- Single Tab Content Start -->
                                    <div class="tab-pane fade" id="users" role="tabpanel">
                                        <div class="myaccount-content">
                                            <h5>Utenti</h5>
                                            <div class="myaccount-table table-responsive text-center">
                                                <table class="table table-bordered">
                                                    <thead class="thead-light">
                                                    <tr>
                                                        <th>Nickname</th>
                                                        <th>Phone</th>
                                                        <th>Email</th>
                                                        <th>Tipologia</th>
                                                        <th>Elimina</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($users as $user)
                                                    <tr>
                                                        <td>{{$user->username}}</td>
                                                        <td>{{$user->phone_number}}</td>
                                                        <td>{{$user->email}}</td>
                                                        @if($user->hasGroup('il gruppo degli utenti'))
                                                        <td>Utente</td>
                                                        @else
                                                            <td>Venditore</td>
                                                        @endif
                                                        <td><a class="btn btn-danger" onclick="return myFunction();"  href="{{route('user-delete', $user->id)}}"><i class="fa fa-trash"></i></a></td>
                                                        <script>
                                                            function myFunction() {
                                                                if(!confirm("Sei sicuro di voler eliminare questo utente"))
                                                                    event.preventDefault();
                                                            }
                                                        </script>
                                                    </tr>
                                                    @endforeach
                                                    {{ $users->links() }}
                                                    </tbody>

                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- Single Tab Content End -->

                                    <!-- Single Tab Content Start -->
                                    <div class="tab-pane fade" id="comics" role="tabpanel">
                                        <div class="myaccount-content">
                                            <h5>Fumetti</h5>
                                            <div class="myaccount-table table-responsive text-center">
                                                <table class="table table-bordered">
                                                    <thead class="thead-dark">
                                                    <tr>
                                                        <th>Titolo</th>
                                                        <th>ISBN</th>
                                                        <th>Quantità</th>
                                                        <th>Utente</th>
                                                        <th>Elimina</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($comics as $comic)
                                                        @php
                                                            $userNeed = App\User::where('id','=',$comic->user_id)->first();
                                                        @endphp
                                                        <tr>
                                                            <td>{{$comic->comic_name}}</td>
                                                            <td>{{$comic->ISBN}}</td>
                                                            <td>{{$comic->quantity}}</td>
                                                            <td>{{$userNeed->username}}</td>
                                                            <td><a class="btn btn-danger" onclick="return myFunction();"  href="{{route('comic-delete', $comic->id)}}"><i class="fa fa-trash"></i></a></td>
                                                            <script>
                                                                function myFunction() {
                                                                    if(!confirm("Sei sicuro di voler eliminare questo fumetto"))
                                                                        event.preventDefault();
                                                                }
                                                            </script>
                                                        </tr>
                                                    @endforeach
                                                    {{ $comics->links() }}
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- Single Tab Content End -->

                                    <!-- Single Tab Content Start -->
                                    <div class="tab-pane fade" id="reviews" role="tabpanel">
                                        <div class="myaccount-content">
                                            <h5>Recensione</h5>
                                            <div class="myaccount-table table-responsive text-center">
                                                <table class="table table-bordered">
                                                    <thead class="thead-dark">
                                                    <tr>
                                                        <th>Titolo</th>
                                                        <th>Fumetto</th>
                                                        <th>Recensore</th>
                                                        <th>Elimina</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($reviews as $review)
                                                        @php
                                                            $userReview = App\User::where('id','=',$review->user_id)->first();
                                                            $comicReview = App\Comic::where('id','=',$review->comic_id)->first();
                                                        @endphp
                                                        <tr>
                                                            <td>{{$review->review_title}}</td>
                                                            <td>{{$comicReview->comic_name}}</td>
                                                            <td>{{$userReview->username}}</td>
                                                            <td><a class="btn btn-danger" onclick="return myFunction();"  href="{{route('review-delete-local', $review->id)}}"><i class="fa fa-trash"></i></a></td>
                                                            <script>
                                                                function myFunction() {
                                                                    if(!confirm("Sei sicuro di voler eliminare questa recensione"))
                                                                        event.preventDefault();
                                                                }
                                                            </script>
                                                        </tr>
                                                    @endforeach
                                                    {{ $reviews->links() }}
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div> <!-- My Account Tab Content End -->
                        </div>
                    </div> <!-- My Account Page End -->
                </div>
            </div>
        </div>
    </div>
</div>

</code>```

And this is my route
Route

```<code>Route::get('/adminArea', function () {
    $user = \Illuminate\Support\Facades\Auth::user();
    $users = \App\User::where('username','!=','admin')->orderBy('username', 'asc')->paginate(12);
    $comics =Comic::orderBy('comic_name', 'asc')->paginate(12);
    $reviews = \App\Review::orderBy('review_title', 'asc')->paginate(12);
    return view('adminPanel')
        ->with(compact('user'))
        ->with(compact('users'))
        ->with(compact('comics'))
        ->with(compact('reviews'));
})->name('AdminAccount');
</code>```

In the end what i want to do is to paginate each tab differently meaning if a put the next on the comics i don't want to show also in the user tab the second page of user. The problem is that it use the same pagination url for each tabs so i was wondering if the solution is to give each tab an indipendent url

答:
It redirects to the first tab because you use javascript tabs with active class added to first tab. To resolve problem with tabs you need to change for each tabs nav to:
href="#dashboad" class="{{ (Route::currentRouteName() == 'YOUR-ROUTE-NAME) ? 'active' : '' }}" ...

Also here:

<div class="tab-pane fade show {{ (Route::currentRouteName() == 'YOUR-ROUTE-NAME) ? 'active' : '' }}"...

But your problems with paginations will remain.

Here are 2 solutions:

Use JS tabs and get data via Ajax request.

Use 4 separated routes for each collection and add routes to tabs corresponding above example.

I hope it was clear.

Body:
I want to paginate in a blade file different tabs , each tabs show different collections of object but each time i go to next page in one page it redirects to the first tab and also paginate each tab not just the one i wanted to paginate.

Blade Part Where i have tabs

                                    Dashboard
                                    Gestione Utenti
                                    Gestione Fumetti
                                    Gestione Recensione

Dashboard

Ciao, {{ $user->username }}! (Non sei {{ $user->username }}? Logout)

I tuoi dati:

E-mail:   {{ $user->email }}

                                            @php
                                                $notifications = \App\Http\Controllers\NotificationController::getNotification($user->id);
                                            @endphp

Notifiche

                                            @if($notifications->count() < 1)

Non ci sono ancora notifiche

                                            @else

                                                            Data
                                                            testo
                                                            stato
                                                            Action

                                                        @foreach($notifications as $notification)

                                                                {{ $notification->date }}

                                                                    @if(strlen($notification->notification_text) > 50 )
                                                                        @php
                                                                            $subnotification = substr($notification->notification_text, 0, 50)
                                                                        @endphp
                                                                        {{ $subnotification }}...
                                                                    @else
                                                                        {{ $notification->notification_text }}
                                                                    @endif

                                                                @if($notification->state == 1)

                                                                        Letto

                                                                        View

                                                                @else

                                                                        Non letto

                                                                         $notification->id]) }}" class="btn btn-sqr">View

                                                                @endif

                                                        @endforeach

                                            @endif

                                @if(session('message'))
                                    {{session('message')}}
                                @endif

Utenti

                                                        Nickname
                                                        Phone
                                                        Email
                                                        Tipologia
                                                        Elimina

                                                    @foreach($users as $user)

                                                        {{$user->username}}
                                                        {{$user->phone_number}}
                                                        {{$user->email}}
                                                        @if($user->hasGroup('il gruppo degli utenti'))
                                                        Utente
                                                        @else
                                                            Venditore
                                                        @endif
                                                        id)}}">

                                                    @endforeach
                                                    {{ $users->links() }}

Fumetti

                                                        Titolo
                                                        ISBN
                                                        Quantità
                                                        Utente
                                                        Elimina

                                                    @foreach($comics as $comic)
                                                        @php
                                                            $userNeed = App\User::where('id','=',$comic->user_id)->first();
                                                        @endphp

                                                            {{$comic->comic_name}}
                                                            {{$comic->ISBN}}
                                                            {{$comic->quantity}}
                                                            {{$userNeed->username}}
                                                            id)}}">

                                                    @endforeach
                                                    {{ $comics->links() }}

Recensione

                                                        Titolo
                                                        Fumetto
                                                        Recensore
                                                        Elimina

                                                    @foreach($reviews as $review)
                                                        @php
                                                            $userReview = App\User::where('id','=',$review->user_id)->first();
                                                            $comicReview = App\Comic::where('id','=',$review->comic_id)->first();
                                                        @endphp

                                                            {{$review->review_title}}
                                                            {{$comicReview->comic_name}}
                                                            {{$userReview->username}}
                                                            id)}}">

                                                    @endforeach
                                                    {{ $reviews->links() }}

And this is my route
Route

Route::get('/adminArea', function () {
    $user = \Illuminate\Support\Facades\Auth::user();
    $users = \App\User::where('username','!=','admin')->orderBy('username', 'asc')->paginate(12);
    $comics =Comic::orderBy('comic_name', 'asc')->paginate(12);
    $reviews = \App\Review::orderBy('review_title', 'asc')->paginate(12);
    return view('adminPanel')
        ->with(compact('user'))
        ->with(compact('users'))
        ->with(compact('comics'))
        ->with(compact('reviews'));
})->name('AdminAccount');

In the end what i want to do is to paginate each tab differently meaning if a put the next on the comics i don't want to show also in the user tab the second page of user. The problem is that it use the same pagination url for each tabs so i was wondering if the solution is to give each tab an indipendent url

Body:
It redirects to the first tab because you use javascript tabs with active class added to first tab. To resolve problem with tabs you need to change for each tabs nav to:
<a href="#dashboad" class="{{ (Route::currentRouteName() == 'YOUR-ROUTE-NAME) ? 'active' : '' }}" ...

Also here:
<!-- Single Tab Content Start -->
<div class="tab-pane fade show {{ (Route::currentRouteName() == 'YOUR-ROUTE-NAME) ? 'active' : '' }}"...

But your problems with paginations will remain.

Here are 2 solutions:

Use JS tabs and get data via Ajax request.

Use 4 separated routes for each collection and add routes to tabs corresponding above example.

I hope it was clear.


问:
Converting oracle's "connect by prior" to mariaDB
I have to move from Oracle to MariaDB 10.3.21.
spent the whole day on this.
I made a query with "start with" and "connect by prior" and "order sibling by" for oracle.

```<code>        select * from (select * from table_name ";
        where num = 1045 ) ";
        start with parentid = 0 ";
        connect by prior id = parentid ";
        order siblings by parentid asc ";
</code>```

but MariaDB doesn't work.
used recursive but didn't go well.
anyone can share a good idea?

this is the original table.

```<code>------------------------------------
num     id   parentid       data1
------------------------------------
1045    11      4          zzzzz
1048    3       0          a3
1048    1       0          a1
1050    21      17         eeeee
1048    2       0          a2
1048    4       1          a1-1
1048    5       4          a1-1-1
1048    6       3          a3-1
------------------------------------
</code>```

and I won't make the same result with MariaDB.

```<code>------------------------------------
num     id   parentid       data1
------------------------------------
1048    1       0          a1
1048    4       1          a1-1
1048    5       4          a1-1-1
1048    2       0          a2
1048    3       0          a3
1048    6       3          a3-1
-------------------------------------
</code>```

any good ideas?
thanks always.

答:
Looks like common table expressions are the new way to go with this:

https://mariadb.com/resources/blog/connect-by-is-dead-long-live-cte-in-mariadb-server-10-2/

Body:
I have to move from Oracle to MariaDB 10.3.21.
spent the whole day on this.
I made a query with "start with" and "connect by prior" and "order sibling by" for oracle.

        select * from (select * from table_name ";
        where num = 1045 ) ";
        start with parentid = 0 ";
        connect by prior id = parentid ";
        order siblings by parentid asc ";

but MariaDB doesn't work.
used recursive but didn't go well.
anyone can share a good idea?

this is the original table.

------------------------------------
num     id   parentid       data1
------------------------------------
1045    11      4          zzzzz
1048    3       0          a3
1048    1       0          a1
1050    21      17         eeeee
1048    2       0          a2
1048    4       1          a1-1
1048    5       4          a1-1-1
1048    6       3          a3-1
------------------------------------

and I won't make the same result with MariaDB.

------------------------------------
num     id   parentid       data1
------------------------------------
1048    1       0          a1
1048    4       1          a1-1
1048    5       4          a1-1-1
1048    2       0          a2
1048    3       0          a3
1048    6       3          a3-1
-------------------------------------

any good ideas?
thanks always.


问:
How can I get http request in Kotlin (Android Studio)
I have problem with getting HTTP request on kotlin. I have a simple server written python and I want to write a client in kotlin (Android studio). I want to get a request than curl (curl localhost:8080/state). Can someone help me pls?

server:

```<code>import enum

from bottle import route, run, template

class Signs(enum.Enum):
    SCRISSORS = enum.auto()
    STONE = enum.auto()
    PAPER = enum.auto()
    NOTHING = enum.auto()

board_state = [Signs.NOTHING, Signs.NOTHING]

final_states = {
    (Signs.STONE, Signs.SCRISSORS): "Player 1 wins",
    (Signs.SCRISSORS, Signs.STONE): "Player 2 wins",
    (Signs.PAPER, Signs.STONE): "Player 1 wins",
    (Signs.STONE, Signs.PAPER): "Player 2 wins",
    (Signs.SCRISSORS, Signs.PAPER): "Player 1 wins",
    (Signs.PAPER, Signs.SCRISSORS): "Player 2 wins",
}

@route('/<raw_player>/<raw_sign>')
def play(raw_player, raw_sign):
    try:
        player = int(raw_player) - 1
    except:
        return "Invalid player, expecting int"

    try:
        sign = Signs[raw_sign.upper()]
    except:
        return "Invalid sign"

    if not player in {0, 1}:
        return "Invalid player number"

    board_state[player] = sign
    return "OK\n"

@route('/state')
def state():
    if board_state[0] is Signs.NOTHING and board_state[1] is Signs.NOTHING:
        return "Nobody played\n"

    if board_state[0] is Signs.NOTHING:
        return "Waiting for player 1\n"

    if board_state[1] is Signs.NOTHING:
        return "Waiting for player 2\n"

    if board_state[0] is board_state[1]:
        return "Draw\n"

    return final_states[tuple(board_state)] + "\n"

@route('/reset')
def reset():
    board_state[0] = Signs.NOTHING
    board_state[1] = Signs.NOTHING
    return "OK\n"

run(host='localhost', port=8080)
</code>```

client:

```<code>package com.example.barcang

import android.content.Intent
import android.os.Bundle
import android.widget.ImageButton
import androidx.appcompat.app.AppCompatActivity
import java.util.*

class kmnActivity : AppCompatActivity() {
    val EXTRA_TEXT = "com.example.application.example.EXTRA_TEXT"
    var uuid = UUID.randomUUID().toString()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_kmn)

        val kamenButton = findViewById<ImageButton>(R.id.kamen)
        val papierButton = findViewById<ImageButton>(R.id.papier)
        val nozniceButton = findViewById<ImageButton>(R.id.noznice)

        kamenButton.setOnClickListener {
            //here i want get 'curl localhost:8080/1/stone'
            openRollActivity()
        }

        papierButton.setOnClickListener {
            //here i want get 'curl localhost:8080/1/paper'
            openRollActivity()
        }

        nozniceButton.setOnClickListener {
            //here i want get 'curl localhost:8080/1/scrissors
            openRollActivity()
        }
    }

    fun openRollActivity() {
        val intent = Intent(this@kmnActivity, rollActivity::class.java)
        intent.putExtra("id", uuid)
        startActivity(intent)
    }
}
</code>```

if i click on button papierButton(translate paperButton) i want get http request on my server (curl localhost:8080/1/paper)

答:
One way is to use ktor http client.

Include it in your dependencies. i.e. build.gradle.kts:

```<code>implementation("io.ktor:ktor-client-core:1.3.2")
implementation("io.ktor:ktor-client-android:1.3.2")
</code>```

Use it in your project:

runBlocking {
    val client = HttpClient() {
        engine {
            // this is an example how you can tweak client options
            followRedirects = true
        }
    }
    val response = client.get<String>("http://localhost:8080/1/stone")
}
```

In the above example I asked for the response as a string, but you could either get an HTTP response, or deserialised object. Refer to ktor's documentation for more examples.

Body:
I have problem with getting HTTP request on kotlin. I have a simple server written python and I want to write a client in kotlin (Android studio). I want to get a request than curl (curl localhost:8080/state). Can someone help me pls?

server:

import enum

from bottle import route, run, template

class Signs(enum.Enum):
    SCRISSORS = enum.auto()
    STONE = enum.auto()
    PAPER = enum.auto()
    NOTHING = enum.auto()

board_state = [Signs.NOTHING, Signs.NOTHING]

final_states = {
    (Signs.STONE, Signs.SCRISSORS): "Player 1 wins",
    (Signs.SCRISSORS, Signs.STONE): "Player 2 wins",
    (Signs.PAPER, Signs.STONE): "Player 1 wins",
    (Signs.STONE, Signs.PAPER): "Player 2 wins",
    (Signs.SCRISSORS, Signs.PAPER): "Player 1 wins",
    (Signs.PAPER, Signs.SCRISSORS): "Player 2 wins",
}

@route('/<raw_player>/<raw_sign>')
def play(raw_player, raw_sign):
    try:
        player = int(raw_player) - 1
    except:
        return "Invalid player, expecting int"

    try:
        sign = Signs[raw_sign.upper()]
    except:
        return "Invalid sign"

    if not player in {0, 1}:
        return "Invalid player number"

    board_state[player] = sign
    return "OK\n"

@route('/state')
def state():
    if board_state[0] is Signs.NOTHING and board_state[1] is Signs.NOTHING:
        return "Nobody played\n"

    if board_state[0] is Signs.NOTHING:
        return "Waiting for player 1\n"

    if board_state[1] is Signs.NOTHING:
        return "Waiting for player 2\n"

    if board_state[0] is board_state[1]:
        return "Draw\n"

    return final_states[tuple(board_state)] + "\n"

@route('/reset')
def reset():
    board_state[0] = Signs.NOTHING
    board_state[1] = Signs.NOTHING
    return "OK\n"

run(host='localhost', port=8080)

client:

package com.example.barcang

import android.content.Intent
import android.os.Bundle
import android.widget.ImageButton
import androidx.appcompat.app.AppCompatActivity
import java.util.*

class kmnActivity : AppCompatActivity() {
    val EXTRA_TEXT = "com.example.application.example.EXTRA_TEXT"
    var uuid = UUID.randomUUID().toString()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_kmn)

        val kamenButton = findViewById<ImageButton>(R.id.kamen)
        val papierButton = findViewById<ImageButton>(R.id.papier)
        val nozniceButton = findViewById<ImageButton>(R.id.noznice)

        kamenButton.setOnClickListener {
            //here i want get 'curl localhost:8080/1/stone'
            openRollActivity()
        }

        papierButton.setOnClickListener {
            //here i want get 'curl localhost:8080/1/paper'
            openRollActivity()
        }

        nozniceButton.setOnClickListener {
            //here i want get 'curl localhost:8080/1/scrissors
            openRollActivity()
        }
    }

    fun openRollActivity() {
        val intent = Intent(this@kmnActivity, rollActivity::class.java)
        intent.putExtra("id", uuid)
        startActivity(intent)
    }
}

if i click on button papierButton(translate paperButton) i want get http request on my server (curl localhost:8080/1/paper)

Body:
One way is to use ktor http client.

Include it in your dependencies. i.e. build.gradle.kts:

implementation("io.ktor:ktor-client-core:1.3.2")
implementation("io.ktor:ktor-client-android:1.3.2")

Use it in your project:

runBlocking {
    val client = HttpClient() {
        engine {
            // this is an example how you can tweak client options
            followRedirects = true
        }
    }
    val response = client.get<String>("http://localhost:8080/1/stone")
}

In the above example I asked for the response as a string, but you could either get an HTTP response, or deserialised object. Refer to ktor's documentation for more examples.