0

だから、私は2つのエンティティを持っています:

Orders
    id
    product_id
    quantity
    ...

Products
    id
    name
    desc
    ...

私の Orders テーブルは次のようになります (実際にはそうではありませんが、アイデアはわかります)。

Orders
==================================
    id        product_id        quantity
    1         42                100
    2         55                150
    3         99                200

PUTこれで、リソースに対して を実行するとOrders、1 日中数量を変更できます。しかし、結果を変えようとしてproduct_idも何も起こりません。注文を照会して製品を参照できるため、マッピングは正しいはずです。

しかし、参考までに、私のマッピングは次のようになります。

@Entity
@Table(name = "Orders")
public class Order {
    ...
    @ManyToOne(fetch = FetchType.EAGER)  // also tried LAZY
    @JoinColumn(name = "product_id")
    private Product;
    ...
}

@Entity
@Table(name = "Products")
public class Product {
    ...
    @Column(name="ProductKey")
    private product_id;
    ...
}

私が見逃しているものはありますか?

ああ、SQL Server 2008 を使用して、spring-data-rest-webmvc 1.0.0-RELEASE、spring-data-jpa

ありがとう。

4

0 に答える 0