jpa配置问题

cc不会飞 cc不会飞 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
ejb中开发jpa时,通过数据库表来生成实体类的时候,一个customer有一个cart表
这是购物车类
@Entity
@Table(name="cart")
public class Cart implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private int id;

@Column(nullable=false, precision=10)
private BigDecimal totalPrice;

@Column(nullable=false)
private int totalQuantity;

//bi-directional one-to-one association to Customer
@OneToOne
@JoinColumn(name="id", nullable=false, insertable=false, updatable=false)
private Customer customer;
----------------------

这是用户类
@Entity
@Table(name="customer")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private int id;

@Lob()
private String autograph;

@Column(length=255)
private String email;

@Column(length=255)
private String gender;

@Lob()
@Column(name="img_url")
private String imgUrl;

@Column(length=255)
private String nickname;

@Column(length=255)
private String password;

@Column(length=255)
private String phone;

@Column(length=255)
private String username;

//bi-directional one-to-one association to Cart
@OneToOne(mappedBy="customer")
private Cart cart;

但是启动jboss时会出现如下错误,这是为什么?
org.hibernate.AnnotationException: Unknown mappedBy in: com.b2b.entities.Customer.cart, referenced property unknown: com.b2b.entities.Cart.customer
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
cc不会飞
Java EE 67,535 成员 225,843 内容