Roo、Hibernate、および Postgres を使用するのは初めてです。これまで Java、JDBC、MySQL に取り組んできましたが、最近以前のプラットフォームに変更する必要がありました。
Roo と既存の Postgres データベースを使用して、Spring Web MVC に基づく基本的な CRUD Web アプリを作成しようとしました。読み取り、表示、更新、および削除機能はすべて正常に機能しますが、作成/挿入機能は機能しません。非常に基本的なアプリであり、他の機能は正常に動作しているため、何が問題なのか本当にわかりません。グーグルで検索してみましたが、問題を解決するものは何も見つかりませんでした。誰でもできることは何でも助けていただければ幸いです。
バージョンの詳細:
JDK: 1.7u25
Spring: 3.2.3.RELEASE
Database: Postgres 9.2
IDE: Spring Tool Suite 3.2.0.RELEASE
RAD: Spring Roo 1.2.4.RELEASE
JDBC Driver: 9.1-901-1.jdbc4
*データベース スキーマ: パブリック
-- 学生向けのテーブル構造
DROP TABLE IF EXISTS "public"."student";
CREATE TABLE "public"."student" (
"uid" int2 NOT NULL PRIMARY KEY,
"name" varchar(30) COLLATE "default" NOT NULL,
"math" int2 NOT NULL,
"science" int2 NOT NULL,
"english" int2 NOT NULL,
"total" int2,
"grade" varchar(2) COLLATE "default"
);
-- 天気のテーブル構造
DROP TABLE IF EXISTS "public"."weather";
CREATE TABLE "public"."weather" (
"city" varchar(30) COLLATE "default",
"temp_hi" int2,
"temp_lo" int2,
"prcp" float4,
"date" date,
"uid" int2 REFERENCES "public"."student" ("uid")
);
applicationContext.xml
<context:component-scan base-package="com.springtest.sample">
<context:exclude-filter expression=".*_Roo_.*" type="regex"/>
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="${database.driverClassName}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="testOnBorrow" value="true"/>
<property name="testOnReturn" value="true"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="1800000"/>
<property name="numTestsPerEvictionRun" value="3"/>
<property name="minEvictableIdleTimeMillis" value="1800000"/>
<property name="validationQuery" value="SELECT version();"/>
</bean>
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
<property name="persistenceUnitName" value="persistenceUnit"/>
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
WEB-INF\views\weathers\create.jspx (ドメインの天気のレコードを作成するために roo が作成したと思われます。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<form:create compositePkField="id" id="fc_com_springtest_sample_domain_Weather" modelAttribute="weather" path="/weathers" render="${empty dependencies}" z="PF86xg+kbnl7RAqTjojWlF4Z3qE=">
<field:input disableFormBinding="true" field="id.city" id="c_com_springtest_sample_domain_Weather_id_city" required="true" z="ckELowpSAQzvf9cAv6oCYkRbCvk="/>
<field:input disableFormBinding="true" field="id.tempHi" id="c_com_springtest_sample_domain_Weather_id_tempHi" required="true" validationMessageCode="field_invalid_integer" z="VLv8DnAYnP8Q7dWMOUFpOsX1gN4="/>
<field:input disableFormBinding="true" field="id.tempLo" id="c_com_springtest_sample_domain_Weather_id_tempLo" required="true" validationMessageCode="field_invalid_integer" z="wxk3KZImWeSNkXxtgFk8xmg7hOQ="/>
<field:input disableFormBinding="true" field="id.prcp" id="c_com_springtest_sample_domain_Weather_id_prcp" required="true" validationMessageCode="field_invalid_number" z="g0pZudMkjApBEG0kGtrzcEMdIXo="/>
<field:datetime dateTimePattern="${weather_id.date_date_format}" disableFormBinding="true" field="id.date" id="c_com_springtest_sample_domain_Weather_id_date" required="true" z="mxySE+ylX1MvkpeC32dz6kE1yO4="/>
<field:input disableFormBinding="true" field="id.uid" id="c_com_springtest_sample_domain_Weather_id_uid" required="true" validationMessageCode="field_invalid_integer" z="B7pFK6f2H5X8jUsDisVjPiKRaqg="/>
</form:create>
<form:dependency dependencies="${dependencies}" id="d_com_springtest_sample_domain_Weather" render="${not empty dependencies}" z="5v9Q9zzCQAQ4XyDzykoEl2YVqjI="/>
</div>
WEB-INF\views\students\create.jspx
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<form:create id="fc_com_springtest_sample_domain_Student" modelAttribute="student" path="/students" render="${empty dependencies}" z="4DI952XoJPRi7uvp6wH3vh4jH+c=">
<field:simple field="weathers" id="c_com_springtest_sample_domain_Student_weathers" messageCode="entity_reference_not_managed" messageCodeAttribute="Weather" z="kF6JmO7MlzSoqhfAd2ZHM5ai8Kc="/>
<field:input field="name" id="c_com_springtest_sample_domain_Student_name" required="true" z="OSD2mrzOmmRQA6VBIJPVNVnSCWI="/>
<field:input field="math" id="c_com_springtest_sample_domain_Student_math" required="true" validationMessageCode="field_invalid_integer" z="VIm+H0xvZNmMgWvRhcVKfhL1520="/>
<field:input field="science" id="c_com_springtest_sample_domain_Student_science" required="true" validationMessageCode="field_invalid_integer" z="Uyq3S34h4XdMpkGZ0/lOm8daWWA="/>
<field:input field="english" id="c_com_springtest_sample_domain_Student_english" required="true" validationMessageCode="field_invalid_integer" z="3TeOvLZYSl+T2s9ClWQmMc+XJX0="/>
<field:input field="total" id="c_com_springtest_sample_domain_Student_total" validationMessageCode="field_invalid_integer" z="ksAXIgx4f3bLj1Mn3bmEMqZU8OI="/>
<field:input field="grade" id="c_com_springtest_sample_domain_Student_grade" z="wuIbwBuzL0bBpARHtTH1bb9L6IA="/>
</form:create>
<form:dependency dependencies="${dependencies}" id="d_com_springtest_sample_domain_Student" render="${not empty dependencies}" z="0oOOhh7rARbZ6RteFU2igEZ3BTE="/>
</div>
さて、重要なものをすべて貼り付けたと思います。何が重要で何が重要でないのかよくわからないので、情報が多すぎてすみません!
エラーの詳細:
データ アクセスの失敗
例外メッセージ:
org.hibernate.exception.SQLGrammarException: could not extract ResultSet; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
例外スタック トレース:
org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:321)
org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:33)
com.springtest.sample.domain.Student_Roo_Jpa_ActiveRecord.persist_aroundBody10(Student_Roo_Jpa_ActiveRecord.aj:43)
com.springtest.sample.domain.Student_Roo_Jpa_ActiveRecord$AjcClosure11.run(Student_Roo_Jpa_ActiveRecord.aj:1)
org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:59)
org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:65)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:63)
com.springtest.sample.domain.Student_Roo_Jpa_ActiveRecord.ajc$interMethod$com_springtest_sample_domain_Student_Roo_Jpa_ActiveRecord$com_springtest_sample_domain_Student$persist(Student_Roo_Jpa_ActiveRecord.aj:41)
com.springtest.sample.domain.Student.persist(Student.java:1)
com.springtest.sample.domain.Student_Roo_Jpa_ActiveRecord.ajc$interMethodDispatch1$com_springtest_sample_domain_Student_Roo_Jpa_ActiveRecord$com_springtest_sample_domain_Student$persist(Student_Roo_Jpa_ActiveRecord.aj)
com.springtest.sample.web.StudentController_Roo_Controller.ajc$interMethod$com_springtest_sample_web_StudentController_Roo_Controller$com_springtest_sample_web_StudentController$create(StudentController_Roo_Controller.aj:30)
com.springtest.sample.web.StudentController.create(StudentController.java:1)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:722)