@ElementCollection应自动创建要嵌入的集合的表。但它并没有创造。显示以下错误

时间:2012-08-19 03:06:38

标签: hibernate jpa

package com.qpi.dao;


import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
/*import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
*/import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


@Entity
@Table(name="QPI_Report")
public class FinalCheckListReport {

    @Id 
    private Integer projectId;

    @Temporal(TemporalType.DATE)
    private Date date ;

    @ElementCollection
    private Collection<PMGenericPoints> genericcheckpoints = new ArrayList<PMGenericPoints>();

    @ElementCollection
    private Collection<ClosurePoints> closurepoints = new ArrayList<ClosurePoints>();

    @ElementCollection
    private Collection<DevPoints> devPoints = new ArrayList<DevPoints>();

    @ElementCollection
    private Collection<CarPoints> carPoints = new ArrayList<CarPoints>();

    @ElementCollection
    private Collection<TriggerBasedPoints> triggerpoints = new ArrayList<TriggerBasedPoints>();

    @ElementCollection
    private Collection<MetricsPoints> metricspoints = new ArrayList<MetricsPoints>();

    @ElementCollection
    private Collection<CMPoints> cmPoints = new ArrayList<CMPoints>();

    @ElementCollection
    private Collection<MaintenancePoints> maintenancePoints = new ArrayList<MaintenancePoints>();

    @ElementCollection
    private Collection<IsmsPoints> ismspoints = new ArrayList<IsmsPoints>();

    @ElementCollection
    private Collection<KtAndInitiationPoints> kt = new ArrayList<KtAndInitiationPoints>();

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Integer getProjectId() {
        return projectId;
    }

    public void setProjectId(Integer projectId) {
        this.projectId = projectId;
    }

    public Collection<PMGenericPoints> getGenericcheckpoints() {
        return genericcheckpoints;
    }

    public void setGenericcheckpoints(
            Collection<PMGenericPoints> genericcheckpoints) {
        this.genericcheckpoints = genericcheckpoints;
    }

    public Collection<ClosurePoints> getClosurepoints() {
        return closurepoints;
    }

    public void setClosurepoints(Collection<ClosurePoints> closurepoints) {
        this.closurepoints = closurepoints;
    }

    public Collection<DevPoints> getDevPoints() {
        return devPoints;
    }

    public void setDevPoints(Collection<DevPoints> devPoints) {
        this.devPoints = devPoints;
    }

    public Collection<CarPoints> getCarPoints() {
        return carPoints;
    }

    public void setCarPoints(Collection<CarPoints> carPoints) {
        this.carPoints = carPoints;
    }

    public Collection<TriggerBasedPoints> getTriggerpoints() {
        return triggerpoints;
    }

    public void setTriggerpoints(Collection<TriggerBasedPoints> triggerpoints) {
        this.triggerpoints = triggerpoints;
    }

    public Collection<MetricsPoints> getMetricspoints() {
        return metricspoints;
    }

    public void setMetricspoints(Collection<MetricsPoints> metricspoints) {
        this.metricspoints = metricspoints;
    }

    public Collection<CMPoints> getCmPoints() {
        return cmPoints;
    }

    public void setCmPoints(Collection<CMPoints> cmPoints) {
        this.cmPoints = cmPoints;
    }

    public Collection<MaintenancePoints> getMaintenancePoints() {
        return maintenancePoints;
    }

    public void setMaintenancePoints(Collection<MaintenancePoints> maintenancePoints) {
        this.maintenancePoints = maintenancePoints;
    }

    public Collection<IsmsPoints> getIsmspoints() {
        return ismspoints;
    }

    public void setIsmspoints(Collection<IsmsPoints> ismspoints) {
        this.ismspoints = ismspoints;
    }

    public Collection<KtAndInitiationPoints> getKt() {
        return kt;
    }

    public void setKt(Collection<KtAndInitiationPoints> kt) {
        this.kt = kt;
    }

}

** * ** * ** * 的** * ** * ** * *** 运行时出错的 ** * ** * ** * ** * ** * ***

2012年8月19日上午8:30:22 org.apache.catalina.core.StandardWrapperValve调用 严重:Servlet [dispatcher]的Servlet.service()在路径[/ QPIAutomation]的上下文中引发异常[请求处理失败;嵌套异常是org.hibernate.exception.SQLGrammarException:无法根本原因插入集合: [com.qpi.dao.FinalCheckListReport.carPoints#1]] java.sql.BatchUpdateException:表'qpi.finalchecklistreport_carpoints'不存在     at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1693)     在com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1108)     在org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)     在org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:56)     在org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1206)     在org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:58)     在org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)     在org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)     在org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:188)     在org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)     在org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)

1 个答案:

答案 0 :(得分:0)

您是否在Persistence.xml中设置了hbm2ddl.auto属性?这是通过Hibernate创建表等所必需的。有关详细说明,请参阅this question