---
title: "JPA的实体映射"
author: "duyunfengsolo"
date: "2009-12-15T10:43:33Z"
tags: []
categories: ["企业架构"]
slug: "jpa"
draft: false
lastmod: "2009-12-15T10:43:33Z"
id: 548679
url: "https://solodu.iteye.com/blog/548679"
---

```
@Entity
@Table(name = "ps_pictures")
public class PsPictures{
   @Column(name="thumbnail_path")
   private String thumbnailPath;

  @ManyToOne
  private Gallery gallery;
  如果已经有了上面的那个多对多的映射的话，但是想利用ps_pictures表里面的gallery_id这个字段的话(因为在实体里面这个字段被映射为Gallery的实体了，所以没有那个gallery_id的这个字段了)，如果想用可以这样写：
  @Column(name="gallery_id",updatable=false)
    private Long galleryId;
}
```