0

次の2つのエンティティがありますが、TrainerのoneToManyリレーション行で、@ JoinColumnアノテーションを使用しているときに、「jointabletrainer_batchが見つかりません」というエラーメッセージが表示されます。プログラムは以下の通りです...

@実在物
@Table(name = "trainer")
パブリッククラストレーナー{

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    int id;
    文字列名;
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "trainerid")
    Set batchs = new HashSet();
    public String getName(){
        戻り名;
    }
    public void setName(String name){
        this.name = name;
    }
    public Set getBatches(){
        バッチを返します。
    }
    public void setBatches(Batch batch){
        batches.add(batch);
    }


}


@実在物
@Table(name = "batch")
パブリッククラスバッチ{

    public String getSlot(){
        リターンスロット;
    }
    public void setSlot(String slot){
        this.slot=スロット;
    }
    public String getTopic(){
        トピックを返す;
    }
    public void setTopic(String topic){
        this.topic=トピック;
    }
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    int id;
    文字列スロット;
    文字列トピック;

}

persistance.xmlは以下のとおりです

<?xml version = "1.0" encoding = "UTF-8"?>
<persistence xmlns = "http://java.sun.com/xml/ns/persistence"
    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation = "http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd "version =" 1.0 ">

    <persistence-unit name = "one_to_many_pk_fkPU" transaction-type = "RESOURCE_LOCAL">
        <provider> org.hibernate.ejb.HibernatePersistence </ Provider>
        <プロパティ>
            <プロパティ名="hibernate.connection.driver_class"値="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
            <property name = "hibernate.connection.url" value = "jdbc:sqlserver:// localhost:1433; DatabaseName = test; MARS_Connection = yes;" />
            <プロパティ名="hibernate.connection.username"値="sa"/>
            <プロパティ名="hibernate.connection.password"値="テスト"/>
            <property name = "hibernate.dialect" value = "org.hibernate.dialect.SQLServerDialect" />
        </プロパティ>
    </persistence-ユニット>

</永続性>

4

1 に答える 1

0

generic を Batch として使用する必要があります。次のような関係を使用します。 Set<Batch> batches=new HashSet<Batch>();

于 2012-12-19T04:16:22.870 に答える