jpa配置问题
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
这是购物车类
@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
...全文
相关推荐
JPA环境支持(JAP的环境配置)
JPA环境支持 JPA环境支持 JPA环境支持 JPA环境支持
jboss、eclipse的jpa连接mysql不成熟的例子
详见csdn上的问题贴:jboss7 mysq5 eclipse luna应用JPA报错,有高手指教一下吗,谢谢哈
Hibernate使用JPA注解代码
Hibernate5.1.fianl整合JPA注解方式异常:persistence.Table.indexes()[Ljavax/persistence/Index;
Spirngboot+JPA+Oracle环境配置
有效解决 Schema-validation: missing table org.springframework.boot.context.event.ApplicationFailedEvent cannot be cast to org.springframework.boot.web.context.WebServerInitializedEvent Unable to build Hibernate SessionFactory Error executing DDL via JDBC Statement ORA-00955: 名称已由现有对象使用
wlp-spring-data-jpa-querydsl-npe:重现SO问题的示例代码
样例代码 用于重现示例代码 。


