我在我的项目中使用JpaRepository,Hibernate和spring-boot并带有nativeQuery,在执行查询时我得到了一个非常奇怪的null值,这是代码:
首先是我的存储库代码(这是返回null的代码):
public interface PaquetesRepository extends JpaRepository<Paquetes, Integer>{
@Query(value = "SELECT * FROM paquetes WHERE tipousuario_id = ?#{#tipoUser}", nativeQuery = true)
Paquetes getPaqueteDelUsuario(int tipoUser);
}
第二个我的服务代码:
@Override
public Paquetes getPaqueteDelUsuario(int tipoUser) {
System.out.println("Check: " + paquetesRepository.getPaqueteDelUsuario(tipoUser) + " , " + tipoUser);
return paquetesRepository.getPaqueteDelUsuario(tipoUser);
}
我的调试返回= Check: null , 2
在我的控制器中,我这样称呼它:
Paquetes paquete = paqueteService.getPaqueteDelUsuario(tipo);
System.out.println("Paquete: " + paquete);
println返回= Paquete: null
我的POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.nekohtml/nekohtml -->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.21</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
还有我的Application.properties:
# ===============================
# = Conexion con la base de datos
# ===============================
spring.datasource.url=jdbc:mysql://url
spring.datasource.username=user
spring.datasource.password =pass
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1
# ===============================
# = JPA / HIBERNATE
# ===============================
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
# ===============================
# = Thymeleaf configuracion
# ===============================
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false
# ===============================
# = Multipart Files
# ===============================
spring.http.multipart.max-file-size=10MB
spring.http.multipart.max-request-size=10MB
# ==============================================================
# = Spring Security / Queries para el Authentication
# ==============================================================
spring.queries.users-query=select email, password, active from user where email=?
spring.queries.roles-query=select u.email, r.role from user u inner join user_role ur on(u.user_id=ur.user_id) inner join role r on(ur.role_id=r.role_id) where u.email=?
spring.queries.pais-query=SELECT * FROM pais
spring.queries.tipousuario-query=SELECT * FROM tipoUsuario
这是我的StackTrace:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "paquete.getTipo()" (usuario/Paquetes)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "paquete.getTipo()" (usuario/Paquetes)
org.thymeleaf.spring4.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:161)
org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:154)
org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59)
org.thymeleaf.standard.expression.Expression.execute(Expression.java:103)
org.thymeleaf.standard.expression.Expression.execute(Expression.java:133)
org.thymeleaf.standard.expression.Expression.execute(Expression.java:120)
org.thymeleaf.standard.processor.attr.AbstractStandardTextChildModifierAttrProcessor.getText(AbstractStandardTextChildModifierAttrProcessor.java:68)
org.thymeleaf.processor.attr.AbstractTextChildModifierAttrProcessor.getModifiedChildren(AbstractTextChildModifierAttrProcessor.java:59)
org.thymeleaf.processor.attr.AbstractChildrenModifierAttrProcessor.processAttribute(AbstractChildrenModifierAttrProcessor.java:59)
org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87)
org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)
org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017)
org.thymeleaf.dom.Node.processNode(Node.java:972)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.Document.process(Document.java:93)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335)
org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:190)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 8): Method call: Attempted to call method getTipo() on null context object
org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:144)
org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:73)
org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:66)
org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87)
org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120)
org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:267)
org.thymeleaf.spring4.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:139)
org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:154)
org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59)
org.thymeleaf.standard.expression.Expression.execute(Expression.java:103)
org.thymeleaf.standard.expression.Expression.execute(Expression.java:133)
org.thymeleaf.standard.expression.Expression.execute(Expression.java:120)
org.thymeleaf.standard.processor.attr.AbstractStandardTextChildModifierAttrProcessor.getText(AbstractStandardTextChildModifierAttrProcessor.java:68)
org.thymeleaf.processor.attr.AbstractTextChildModifierAttrProcessor.getModifiedChildren(AbstractTextChildModifierAttrProcessor.java:59)
org.thymeleaf.processor.attr.AbstractChildrenModifierAttrProcessor.processAttribute(AbstractChildrenModifierAttrProcessor.java:59)
org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87)
org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)
org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017)
org.thymeleaf.dom.Node.processNode(Node.java:972)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
org.thymeleaf.dom.Node.processNode(Node.java:990)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
答案 0 :(得分:1)
在存储库类中尝试一下:
@Query(
value = "SELECT * FROM paquetes WHERE tipousuario_id = ?1",
nativeQuery = true)
Paquetes getPaqueteDelUsuario(Integer tipoUser);
替代选项,您可以使用命名查询(不使用nativeQuery)
paquetesRepository.getPaqueteDelUsuarioByTipousuarioId(tipoUser);
为此,您必须在Entity类中重命名该变量,因为该变量包含下划线。
@Column(name = "tipousuario_id", nullable = false)
private Integer tipousuarioId;
参考链接:https://docs.spring.io/spring-data/jpa/docs/1.4.2.RELEASE/reference/html/jpa.repositories.html