java – mappedBy引用未知的目标实体属性

我有一个问题,在我的注释对象中设置一对多的关系。

我有以下:

@MappedSuperclass
public abstract class MappedModel
{
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="id",nullable=false,unique=true)
    private Long mId;

然后这个

@Entity
@Table(name="customer")
public class Customer extends MappedModel implements Serializable
{

    /**
   * 
   */
  private static final long serialVersionUID = -2543425088717298236L;


  /** The collection of stores. */
    @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  private Collection<Store> stores;

和这个

@Entity
@Table(name="store")
public class Store extends MappedModel implements Serializable
{

    /**
   * 
   */
  private static final long serialVersionUID = -9017650847571487336L;

  /** many stores have a single customer **/
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn (name="customer_id",referencedColumnName="id",nullable=false,unique=true)
  private Customer mCustomer;

我在这里做错了

mappedBy属性引用客户,而属性是mCustomer,因此错误消息。因此,要么将映射更改为:

/** The collection of stores. */
@OneToMany(mappedBy = "mCustomer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Collection<Store> stores;

或者将实体属性更改为客户(这是我会做的)。

mappedBy引用指示“查看名为’customer’的bean属性上我有一个集合的东西来查找配置。

http://stackoverflow.com/questions/4011472/mappedby-reference-an-unknown-target-entity-property

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:java – mappedBy引用未知的目标实体属性