Questions tagged «hibernate-annotations»

4
困惑:使用JPA和Hibernate的@NotNull与@Column(nullable = false)
当它们出现在的字段/获取器上时,它们@Entity之间有什么区别?(我通过Hibernate保留了Entity )。 它们每个都属于什么框架和/或规范? @NotNull位于中javax.validation.constraints。在javax.validation.constraints.NotNulljavadoc中说 带注释的元素不能为空 但是它没有提到数据库中元素的表示形式,那么为什么nullable=false要在列中添加约束呢?

9
Hibernate引发org.hibernate.AnnotationException:未为实体指定标识符:com..domain.idea.MAE_MFEView
为什么会出现此异常? package com.domain.idea; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import org.hibernate.annotations.AccessType; /** * object model for the view [InvestmentReturn].[vMAE_MFE] */ @Entity @Table(name="vMAE_MFE", schema="InvestmentReturn") @AccessType("field") public class MAE_MFEView { /** * trade property is a SuggestdTradeRecommendation object */ @OneToOne(fetch = FetchType.LAZY , cascade = { …

4
休眠注释中的@UniqueConstraint和@Column(unique = true)
@UniqueConstraint和@Column(unique = true)有什么区别? 例如: @Table( name = "product_serial_group_mask", uniqueConstraints = {@UniqueConstraint(columnNames = {"mask", "group"})} ) 和 @Column(unique = true) @ManyToOne(optional = false, fetch = FetchType.EAGER) private ProductSerialMask mask; @Column(unique = true) @ManyToOne(optional = false, fetch = FetchType.EAGER) private Group group;

3
通过引用未知目标实体属性
我在被注释的对象中建立一对多关系时遇到问题。 我有以下内容: @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) …


3
如何使用Hibernate批注标记外键约束?
我正在尝试使用Hibernate批注为数据库表编写模型类。 我有两个表,每个表都有一个主键User和Question。 @Entity @Table(name="USER") public class User { @Id @Column(name="user_id") @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @Column(name="username") private String username; // Getter and setter } 问题表。 @Entity @Table(name="QUESTION") public class Questions extends BaseEntity{ @Id @Column(name="question_id") @GeneratedValue(strategy=GenerationType.AUTO) private int id; @Column(name="question_text") private String question_text; // Getter and setter } 我还有一个表UserAnswer,其中有来自上面两个表的userId和questionId作为外键。 但是我无法在UserAnswer表中找到如何引用这些约束的方法。 @Entity @Table(name="UserAnswer …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.