在创建内存中的数据库时出现错误。当我在Tomcat Server上启动我的程序时,它似乎运行得很好,直到我尝试将其插入到数据库中。我的Tomcat日志显示了以下内容:
Hibernate: alter table BrokerReferrerJoin drop constraint FK_cfc92321040c4c7e94cd7d7f0f0
Hibernate: alter table BrokerTable drop constraint FK_85c86a6cd9d14a23840e4746545
Hibernate: alter table LeadTable drop constraint FK_26c301acde8d4daa93734bda8ff
Hibernate: alter table LeadTable drop constraint FK_d358f93455874bcba7ed6afd996
Hibernate: alter table ReferrerBrokerJoin drop constraint FK_60dc4e2e6a44406a8fdf4e869e8
Hibernate: alter table ReferrerTable drop constraint FK_910ad4a791e9434da73fbc24ba5
Hibernate: drop table BrokerReferrerJoin if exists
Hibernate: drop table BrokerTable if exists
Hibernate: drop table LeadTable if exists
Hibernate: drop table Person if exists
Hibernate: drop table ReferrerBrokerJoin if exists
Hibernate: drop table ReferrerTable if exists
Hibernate: alter table BrokerReferrerJoin drop constraint FK_7100b66fe58043ed9fcba0c116c
Hibernate: alter table BrokerTable drop constraint FK_b5a6bbb0789c46b39597c4eb788
Hibernate: alter table LeadTable drop constraint FK_e19293e489d2443f80cef09bf10
Hibernate: alter table LeadTable drop constraint FK_0a56acd9932f4f4f930f1b4c23b
Hibernate: alter table ReferrerBrokerJoin drop constraint FK_c700fee7563d461fb33336901e7
Hibernate: alter table ReferrerTable drop constraint FK_c449adf2fb9e4f4d985c944d852
Hibernate: drop table BrokerReferrerJoin if exists
Hibernate: drop table BrokerTable if exists
Hibernate: drop table LeadTable if exists
Hibernate: drop table Person if exists
Hibernate: drop table ReferrerBrokerJoin if exists
Hibernate: drop table ReferrerTable if exists
Hibernate: create table BrokerReferrerJoin (FlexRowIDLink varchar(255) not null, InternalReferrerIDLink varchar(255) not null)
Hibernate: create table BrokerTable (AdminID varchar(255), isAdmin boolean, FlexRowID varchar(255) not null, primary key (FlexRowID))
Hibernate: create table LeadTable (LeadID varchar(255) generated by default as identity (start with 1), Amount double, FlexRowID varchar(255), LeadEmail varchar(50), LeadFName varchar(50) not null, HPhoneNo integer, LeadLName varchar(50) not null, MPhoneNo bigint, Notes varchar(4095), WPhoneNo integer, Status varchar(255), LoanType varchar(255), leadBroker_FlexRowID varchar(255), leadReferrer_FlexRowID varchar(255), primary key (LeadID))
Hibernate: create table Person (FlexRowID varchar(255) not null, CreatedOn date, Email varchar(255), FName varchar(255), LName varchar(255), LastUpdated date, OrgID varchar(255), OrgName varchar(255), Username varchar(255), primary key (FlexRowID))
Hibernate: create table ReferrerBrokerJoin (InternalReferrerIDLink varchar(255) not null, FlexRowIDLink varchar(255) not null)
Hibernate: create table ReferrerTable (LTSRowID varchar(255), FlexRowID varchar(255) not null, primary key (FlexRowID))
Hibernate: alter table BrokerReferrerJoin add constraint UK_bc91f298149c4420bc453811411 unique (InternalReferrerIDLink)
Hibernate: alter table BrokerReferrerJoin add constraint FK_7100b66fe58043ed9fcba0c116c foreign key (FlexRowIDLink) references BrokerTable
Hibernate: alter table BrokerTable add constraint FK_b5a6bbb0789c46b39597c4eb788 foreign key (FlexRowID) references Person
Hibernate: alter table LeadTable add constraint FK_e19293e489d2443f80cef09bf10 foreign key (leadBroker_FlexRowID) references BrokerTable
Hibernate: alter table LeadTable add constraint FK_0a56acd9932f4f4f930f1b4c23b foreign key (leadReferrer_FlexRowID) references ReferrerTable
Hibernate: alter table ReferrerBrokerJoin add constraint UK_836e448745504545aaa39709e22 unique (FlexRowIDLink)
Hibernate: alter table ReferrerBrokerJoin add constraint FK_c700fee7563d461fb33336901e7 foreign key (FlexRowIDLink) references BrokerTable
Hibernate: alter table ReferrerTable add constraint UK_b0c668bb487b4a1d8b5f7b9657b unique (LTSRowID)
Hibernate: alter table ReferrerTable add constraint FK_c449adf2fb9e4f4d985c944d852 foreign key (FlexRowID) references Person
18:52:45.573 [http-bio-8080-exec-3] ERROR com.au.curtin.Lead.HibernateLeadDao - The sessionFactory was set: org.springframework.orm.hibernate4.LocalSessionFactoryBean@6c80d028
18:52:45.592 [http-bio-8080-exec-3] ERROR com.au.curtin.Lead.LeadServiceClass - The HibernateLeadDao was set: com.au.curtin.Lead.HibernateLeadDao@1c90a278
18:52:49.862 [http-bio-8080-exec-7] ERROR com.au.curtin.LoginController - Starting logger
18:52:54.253 [http-bio-8080-exec-9] ERROR com.au.curtin.LeadController - Returning Referrer Home View
18:53:01.035 [http-bio-8080-exec-10] ERROR com.au.curtin.LeadController - org.springframework.validation.BeanPropertyBindingResult: 0 errors
18:53:01.035 [http-bio-8080-exec-10] ERROR com.au.curtin.Lead.LeadServiceClass - Home Phone Number: 94572707Work Phone Number : nullMobile Phone Number: nullEmail :
18:53:01.098 [http-bio-8080-exec-10] ERROR com.au.curtin.Lead.LeadServiceClass - com.au.curtin.Lead.HibernateLeadDao@1c90a278
18:53:01.098 [http-bio-8080-exec-10] ERROR com.au.curtin.Lead.HibernateLeadDao - Lead : Lead [leadID=null, flexRowID=null, leadFirstName=James, leadLastName=Massey, leadHomePhoneNumber=94572707, leadWorkPhoneNumber=null, leadMobilePhoneNumber=null, borrowingAmount=1000.0, leadEmail=, loanType=null, leadNotes=, leadBroker=null, leadReferrer=null, loanStatus=null]Session is: SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[] unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])
Hibernate: insert into LeadTable (LeadID, Amount, FlexRowID, leadBroker_FlexRowID, LeadEmail, LeadFName, HPhoneNo, LeadLName, MPhoneNo, Notes, leadReferrer_FlexRowID, WPhoneNo, Status, LoanType) values (default, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)我不知道为什么它突然导致了这个错误。所有字段都设置了注释。这是我的Spring .xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<tx:annotation-driven transaction-manager="transactionManager" />
<jdbc:embedded-database id="LTSDatabase" type="HSQL" />
<context:component-scan base-package="x.y" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="LTSDatabase" />
<property name="annotatedClasses">
<list>
<value>x.y.Lead</value>
<value>x.y.Broker</value>
<value>x.y.Referrer</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="PersistenceAnnotationPostProcessor"
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="hibernateExceptionTranslator"
class="org.springframework.orm.hibernate4.HibernateExceptionTranslator" />
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
id="PersistenceExceptionTranslator" depends-on="hibernateExceptionTranslator" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>正如您所看到的,我正在使用注释来设置数据库和事务。我不知道为什么会发生这个错误。如果有人知道为什么会这样,请告诉我。
我正在使用Spring3、Hibernate 4.2和Tomcat7,如果它们有帮助的话。
发布于 2013-05-21 13:03:07
如果这对任何人有帮助,我的问题是我试图将我的字段作为我的主键声明为一个字符串。Hibernate不能处理非数值的自动生成的主键。
https://stackoverflow.com/questions/16564050
复制相似问题