如题。。在网上搜了半天也找不到答案,希望大家能给点例子。只想问一点就是。
那句annotation语句该怎么写?有3种继承,1个是单表继承的,其他两个都是多表继承,3种类型分别该怎么写呢?不是EJB哦。普通hibernate@这里的内容
public class A{}
@还有这里的内容
public class B extends A{}
那句annotation语句该怎么写?有3种继承,1个是单表继承的,其他两个都是多表继承,3种类型分别该怎么写呢?不是EJB哦。普通hibernate@这里的内容
public class A{}
@还有这里的内容
public class B extends A{}
解决方案 »
- HTTP Status 500 - Dispatch[/monitor] to method totalSheetMonitor returned an exc
- 关于线程的一个问题
- hibernate关联关系映射生成单向一对一关系表的问题
- 乱码问题,急需解决,超急等待,从今晚一直等到明早,大家一定帮顶!万分感谢
- 初学J2EE,使用那些书好?
- Is struts still important?
- Hibernate 怎样获取数据库信息
- wsad问题,修改了xml文件是不是要重新编译整个项目?
- 100分求购JAVA 2实用教程 这本电子书 分不够可再加
- 关于iPlanet Directory Server 5.1,怎样配置客户认证证书
- javascript 字符串传值问题
- Wepshere 能否增加页面相应时间
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;@MappedSuperclass
public class IdEntity { private Long id; @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
} public void setId(Long id) {
this.id = id;
}
}
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import com.zhjb.entity.IdEntity;
import org.springside.modules.utils.CollectionUtils;@Entity
@Table(name = "ROLES")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Role extends IdEntity { private String name; private Set<Authority> auths = new LinkedHashSet<Authority>(); public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinTable(name = "ROLES_AUTHORITIES", joinColumns = { @JoinColumn(name = "ROLE_ID") }, inverseJoinColumns = { @JoinColumn(name = "AUTHORITY_ID") })
@OrderBy("id")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public Set<Authority> getAuths() {
return auths;
} public void setAuths(Set<Authority> auths) {
this.auths = auths;
} @Transient
public String getAuthNames() throws Exception {
return CollectionUtils.fetchPropertyToString(auths, "displayName", ", ");
} @SuppressWarnings("unchecked")
@Transient
public List<Long> getAuthIds() throws Exception {
return CollectionUtils.fetchPropertyToList(auths, "id");
} @Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}