Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.16 KB | None | 0 0
  1. select * from APP_USER
  2.  
  3. ERROR: relation "app_user" does not exist
  4. LINE 1: select * from APP_USER
  5. ^
  6. ********** Error **********
  7.  
  8. ERROR: relation "app_user" does not exist
  9. SQL state: 42P01
  10.  
  11. select * from "APP_USER"
  12.  
  13. <dependencies>
  14.  
  15. <dependency>
  16. <groupId>org.springframework.boot</groupId>
  17. <artifactId>spring-boot-starter-web</artifactId>
  18. </dependency>
  19.  
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-actuator</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-data-jpa</artifactId>
  27. </dependency>
  28. <dependency>
  29. <groupId>org.springframework.boot</groupId>
  30. <artifactId>spring-boot-starter-security</artifactId>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.springframework.boot</groupId>
  34. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.thymeleaf.extras</groupId>
  38. <artifactId>thymeleaf-extras-tiles2</artifactId>
  39. <version>2.1.1.RELEASE</version>
  40. </dependency>
  41.  
  42. <dependency>
  43. <groupId>org.postgresql</groupId>
  44. <artifactId>postgresql</artifactId>
  45. <version>9.4-1201-jdbc41</version>
  46. <scope>runtime</scope>
  47. </dependency>
  48. <dependency>
  49. <groupId>org.springframework.boot</groupId>
  50. <artifactId>spring-boot-starter-test</artifactId>
  51. <scope>test</scope>
  52. </dependency>
  53.  
  54. </dependencies>
  55.  
  56. spring.datasource.driverClassName=org.postgresql.Driver
  57. spring.datasource.url=jdbc:postgresql://localhost:5432/boek
  58. spring.datasource.username=postgres
  59. spring.datasource.password=ABCD123$
  60.  
  61. spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
  62. spring.jpa.generate-ddl=false
  63.  
  64. #spring.jpa.hibernate.ddl-auto=create
  65. spring.jpa.show-sql=true
  66.  
  67. @Entity
  68. @Table(name = "APP_USER")
  69. public class User implements Serializable {
  70.  
  71. private static final long serialVersionUID = -1152779434213289790L;
  72.  
  73. @Id
  74. @Column(name="ID", nullable = false, updatable = false)
  75. @GeneratedValue(strategy=GenerationType.AUTO)
  76. private long id;
  77.  
  78. @Column(name="NAME", nullable = false)
  79. private String name;
  80.  
  81. @Column(name="USER_NAME", nullable = false, unique = true)
  82. private String username;
  83.  
  84. @Column(name="PASSWORD", nullable = false)
  85. private String password;
  86.  
  87. @Column(name="EMAIL", nullable = false, unique = true)
  88. private String email;
  89.  
  90. @Column(name="ROLE", nullable = false)
  91. private RoleEnum role;
  92.  
  93. <form role="form" action="#" th:action="@{/user/create}" th:object="${userDTO}" method="post">
  94.  
  95. @RequestMapping(value = "/user/create", method = RequestMethod.POST)
  96. public String handleUserCreateForm(@Valid @ModelAttribute("form") UserDTO form, BindingResult bindingResult) {
  97. if (bindingResult.hasErrors()) {
  98. return "user_create";
  99. }
  100. try {
  101. userService.create(form);
  102. } catch (DataIntegrityViolationException e) {
  103. bindingResult.reject("email.exists", "Email already exists");
  104. return "user_create";
  105. }
  106. return "redirect:/users";
  107. }
  108.  
  109. private void validateEmail(Errors errors, UserDTO form) {
  110. if (userService.getUserByEmail(form.getEmail()).isPresent()) {
  111. errors.reject("email.exists", "User with this email already exists");
  112. }
  113. }
  114.  
  115. @Override
  116. public Optional<User> getUserByEmail(String email) {
  117. return userRepository.findOneByEmail(email);
  118. }
  119.  
  120. @Repository
  121. public interface UserRepository extends CrudRepository<User, Serializable> {
  122.  
  123. Optional<User> findOneByEmail(String email);
  124. }
  125.  
  126. org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  127. at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:238)
  128. at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:221)
  129. at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
  130. at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
  131. at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
  132. at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
  133. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  134. at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)
  135. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  136. at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
  137. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  138. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
  139. at com.sun.proxy.$Proxy75.findOneByEmail(Unknown Source)
  140. at com.myapp.service.impl.UserServiceImpl.getUserByEmail(UserServiceImpl.java:32)
  141. at com.myapp.model.validator.UserValidator.validateEmail(UserValidator.java:40)
  142. at com.myapp.model.validator.UserValidator.validate(UserValidator.java:30)
  143. at org.springframework.validation.DataBinder.validate(DataBinder.java:785)
  144. at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.validateIfApplicable(ModelAttributeMethodProcessor.java:164)
  145. at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:111)
  146. at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)
  147. at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)
  148. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:129)
  149. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
  150. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
  151. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
  152. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
  153. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
  154. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  155. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
  156. at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
  157. at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
  158. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
  159. at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  160. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  161. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  162. at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  163. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  164. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  165. at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:295)
  166. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  167. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  168. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  169. at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:102)
  170. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  171. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  172. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  173. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
  174. at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
  175. at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
  176. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  177. at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
  178. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  179. at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
  180. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  181. at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
  182. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  183. at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
  184. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  185. at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
  186. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  187. at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
  188. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  189. at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:105)
  190. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  191. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  192. at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
  193. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  194. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  195. at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
  196. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  197. at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
  198. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  199. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  200. at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
  201. at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
  202. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  203. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  204. at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  205. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  206. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  207. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  208. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
  209. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  210. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  211. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  212. at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:68)
  213. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  214. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  215. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  216. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
  217. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
  218. at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
  219. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
  220. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  221. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  222. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
  223. at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
  224. at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
  225. at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
  226. at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
  227. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  228. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  229. at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  230. at java.lang.Thread.run(Thread.java:745)
  231. Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  232. at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
  233. at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
  234. at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
  235. at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
  236. at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:91)
  237. at org.hibernate.loader.Loader.getResultSet(Loader.java:2066)
  238. at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1863)
  239. at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1839)
  240. at org.hibernate.loader.Loader.doQuery(Loader.java:910)
  241. at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355)
  242. at org.hibernate.loader.Loader.doList(Loader.java:2554)
  243. at org.hibernate.loader.Loader.doList(Loader.java:2540)
  244. at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370)
  245. at org.hibernate.loader.Loader.list(Loader.java:2365)
  246. at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497)
  247. at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
  248. at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236)
  249. at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1300)
  250. at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
  251. at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
  252. at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:495)
  253. at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:71)
  254. at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:202)
  255. at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:74)
  256. at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:99)
  257. at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:90)
  258. at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:415)
  259. at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:393)
  260. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  261. at org.springframework.data.repository.core.support.RepositoryFactorySupport$DefaultMethodInvokingMethodInterceptor.invoke(RepositoryFactorySupport.java:506)
  262. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  263. at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
  264. at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
  265. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
  266. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  267. at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
  268. ... 98 more
  269. Caused by: org.postgresql.util.PSQLException: ERROR: relation "app_user" does not exist
  270. Posição: 177
  271. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270)
  272. at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1998)
  273. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
  274. at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:570)
  275. at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:420)
  276. at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:305)
  277. at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82)
  278. ... 129 more
  279.  
  280. CREATE TABLE APP_USER ...
  281.  
  282. CREATE TABLE "APP_USER" ...
  283.  
  284. Properties jpaProperties = new Properties();
  285.  
  286. ..
  287.  
  288. jpaProperties.put("hibernate.default_schema", "my_default_schema");
  289. entityManagerFactoryBean.setJpaProperties(jpaProperties);
  290.  
  291. @Entity
  292. @Table(name = "APP_USER",schema="xxxxx")
  293.  
  294. public class User implements Serializable {
  295.  
  296. private static final long serialVersionUID = -1152779434213289790L;
  297.  
  298. @Id
  299. @Column(name="ID", nullable = false, updatable = false)
  300. @GeneratedValue(strategy=GenerationType.AUTO)
  301. private long id;
  302.  
  303. @Column(name="NAME", nullable = false)
  304. private String name;
  305.  
  306. @Column(name="USER_NAME", nullable = false, unique = true)
  307. private String username;
  308.  
  309. @Column(name="PASSWORD", nullable = false)
  310. private String password;
  311.  
  312. @Column(name="EMAIL", nullable = false, unique = true)
  313. private String email;
  314.  
  315. @Column(name="ROLE", nullable = false)
  316. private RoleEnum role;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement