2013年9月20日星期五

About the JPA entities , generic parent class problem

public class DefaultEntity implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = 1L;

@Id
    @GeneratedValue
private long id;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}
}


@Entity
@Table(name="oa_member")
public class Member extends DefaultEntity {

/**
 * 
 */
private static final long serialVersionUID = 1L;


@Column(length=20)
private String name; //姓名

private String username; //登录名
private String password; //密码

private long roleId;

@Transient
private Role role;
//角色

error : No identifier specified for entity: main.java.com.company.domain.Member.

DefaultEntity is not to deal with the next , or can not find the parent class id
------ Solution -------------------- ------------------------
you made a fatal error , private member variables to inherit it ? ? ?
------ For reference only ---------------------------------------
Ah , such a stupid mistake , confused the
------ For reference only ------------------------------------- -
did not expect or report this error , it is not the problem
------ For reference only ---------------------- -----------------
did not expect or report this error , it is not the problem   you how to change ah ? Still reported this error ? hibernate more stringent , the entity class must have a primary key

没有评论:

发表评论