Hibernate实体注解,spring配置文件怎么写

importjavax.persistence.Column;importjavax.persistence.Entity;importjavax.persistence... import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="tb_Student")
public class StuEntity {
@Id
@Column(name="stuId")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
@Column(name="stuName",length=10,nullable=false)
private String name;
@Column(name="stupwd",length=10,nullable=false)
private String pwd;
@Column(name="stuAddress",length=20,nullable=false)
private String address;
@Column(name="stuPhone",length=20,nullable=false)
private String phone;

public StuEntity(){}

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 getPwd() {
return pwd;
}

public void setPwd(String pwd) {
this.pwd = pwd;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public StuEntity(String name, String pwd, String address,
String phone) {
this.name = name;
this.pwd = pwd;
this.address = address;
this.phone = phone;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + id;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((phone == null) ? 0 : phone.hashCode());
result = prime * result + ((pwd == null) ? 0 : pwd.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
StuEntity other = (StuEntity) obj;
if (address == null) {
if (other.address != null)
return false;
} else if (!address.equals(other.address))
return false;
if (id != other.id)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (phone == null) {
if (other.phone != null)
return false;
} else if (!phone.equals(other.phone))
return false;
if (pwd == null) {
if (other.pwd != null)
return false;
} else if (!pwd.equals(other.pwd))
return false;
return true;
}

}
配置怎么写。 在线等。。。急急急。
展开
 我来答
养初厹06
2012-06-08 · TA获得超过203个赞
知道小有建树答主
回答量:784
采纳率:0%
帮助的人:416万
展开全部
注解不需要配置了,不好使么
追问
实体类多了,.hbm.xml文件要写很多,麻烦。 注解相对好点。 但是不知道怎么在spring配置怎么写。
追答
@Entity
@Table(name="tb_Student")
这种注解是不需要配置的,他直接生成了配置文件,能够直接应用了。一般需要实现序列接口
implements java.io.Serializable
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式