2013-05-15 31 views
0

我在創建我的內存數據庫時出錯。 當我在我的Tomcat服務器上啓動我的程序時,它似乎運行良好,直到我嘗試插入數據庫。 我的Tomcat的日誌記錄了以下內容:Spring中的休眠數據庫生成錯誤

Hibernate: alter table BrokerReferrerJoin drop constraint FK_cfc40c4c7e94cd7d7f0f0 
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: [email protected]028 
18:52:45.592 [http-bio-8080-exec-3] ERROR com.au.curtin.Lead.LeadServiceClass - The HibernateLeadDao was set: [email protected] 
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 - [email protected] 
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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 

我不知道爲什麼會突然導致該錯誤。 所有字段都設置了註釋。 這裏是我的春天的.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> 

正如你可以看到我使用的註釋設置數據庫,和我交易。 我不知道爲什麼會發生此錯誤。如果有人知道爲什麼會發生這種情況,請告訴我。

我使用Spring 3,Hibernate 4.2和Tomcat 7(如果有幫助的話)。

回答

0

以防萬一這有助於任何人,我的問題是,我試圖讓我的領域,這將是我的主鍵聲明爲一個字符串。 Hibernate無法處理非數字自動生成的主鍵。