欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Hibernate使用注解

程序员文章站 2022-05-23 22:13:26
...
//类标志
@Entity
@Table(name = "TC_CONTACT")
public class TContract extends BaseDomain

//id主键标志
@Id
@GeneratedValue(generator = "identifier", strategy = GenerationType.IDENTITY)
@SequenceGenerator(name = "identifier", allocationSize = 1)
@Column(name = "ID")

//列标示
@Column(name = "link_man_no", nullable = false, insertable = false, updatable = false)
@Column(name = "CREATED_ON", unique = false, 
	insertable = false, updatable = false)

@Transient
private String updateTime;

//多对一
@ManyToOne(targetEntity = TactivatableItem.class)
@Cascade(value = {CascadeType.PERSIST, CascadeType.MERGE })
@JoinColumn(name = "LINE_ITEM_ID")
public TactivatableItem getActivatableItem()
{
   return activatableItem;
}

//一对多
@OneToMany(targetEntity = TentitlementFeatureDetail.class, fetch = FetchType.EAGER, mappedBy = "feature")
@Cascade(value = {CascadeType.DELETE_ORPHAN, CascadeType.SAVE_UPDATE })
public List<TentitlementFeatureDetail> getDetailList()
{
    return detailList;
}

@OneToMany(fetch = FetchType.LAZY, mappedBy = "tactivatableItem", targetEntity = Tfulfillment.class)
@Cascade(value = {CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN })

@OneToMany(targetEntity = TentitlementFeature.class, fetch = FetchType.LAZY, mappedBy = "activatableItem")
@Cascade(value = {CascadeType.DELETE_ORPHAN, CascadeType.SAVE_UPDATE })


//多对多
@ManyToOne(targetEntity = Tproduct.class)
@Cascade(value = {CascadeType.PERSIST, CascadeType.MERGE })
@JoinColumn(name = "PRODUCT_ID")

@ManyToOne(fetch = FetchType.LAZY, targetEntity = TLogoInfo.class)
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "LOGO_INFO_ID")