在hibernate利用生成数据库时,出现异常 15
org.hibernate.MappingException:Couldnotdeterminetypefor:com.forum.model.User,attable:...
org.hibernate.MappingException: Could not determine type for: com.forum.model.User, at table: Message, for columns: [org.hibernate.mapping.Column(user1)]
User类
@Entity
public class User {
//下面是User的属性
//主要是id,姓名,邮箱地址,登录密码,自身的帖子
private int id;
private String name;
private String password;
private String mail;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
@Entity
@IdClass(MessagePK.class)
public class Message {
private User user1;
private User user2;
private Date date;
private String content;
private boolean received;
@Id
@Column(name="u1")
public User getUser1() {
return user1;
}
public void setUser1(User user1) {
this.user1 = user1;
}
@Id
@Column(name="u2")
public User getUser2() {
return user2;
}
public void setUser2(User user2) {
this.user2 = user2;
}
@Id
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public boolean isReceived() {
return received;
}
public void setReceived(boolean received) {
this.received = received;
}
} 展开
User类
@Entity
public class User {
//下面是User的属性
//主要是id,姓名,邮箱地址,登录密码,自身的帖子
private int id;
private String name;
private String password;
private String mail;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
@Entity
@IdClass(MessagePK.class)
public class Message {
private User user1;
private User user2;
private Date date;
private String content;
private boolean received;
@Id
@Column(name="u1")
public User getUser1() {
return user1;
}
public void setUser1(User user1) {
this.user1 = user1;
}
@Id
@Column(name="u2")
public User getUser2() {
return user2;
}
public void setUser2(User user2) {
this.user2 = user2;
}
@Id
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public boolean isReceived() {
return received;
}
public void setReceived(boolean received) {
this.received = received;
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询