0

これらは私のクラスです:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Test_A 
{
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    protected Integer aId;
    public  String bleh;
}

@Embeddable
public class Test_B extends Test_A 
{
    public String foo;
}

@Entity
public class Test_Main 
{
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    protected Integer mainId;

    public Test_B testB;

    public Test_Main ()
    {
        testB = new Test_B();
        testB.foo="bar";
        testB.bleh="duh";
    }
}

これにより、次のテーブルが生成されます。

Table: Test_A
aId
bleh

Table: Test_Main
mainId
foo

新しい Test_Main を作成して永続化すると、次のようにテーブルに入力されます。

Test_A: <blank>
Test_Main.mainId: 1
Test_Main.foo:    "bar"

Test_A の継承は JOINED であるため、Test_A に行があり、Test_main に外部キーがあることを期待していました。

Test_A.aId:  1
Test_A.bleh: "duh"

Test_Main.mainId: 1
Test_Main.aID:    1
Test_Main.foo:    "bar"

独自のテーブルを持つ必要がある Test_A の他のサブクラスがあるため、JOINED は必須です。Test_A に入力し、Test_B の物理テーブルを必要とせずに外部キーを Test_Main に取得する方法はありますか?

4

0 に答える 0