|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
手机用到的是用j2me所编出来的小程序。
Hibernate3.2撑持JPA注解,Spring集成JPA是可选的。
上面是Spring集成JPA的一个例子。
实体类MyUser,利用JPA注解完成到数据库表myUser的映照,以下所示:
package org.shirdrn.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;
@Entity
public class MyUser {
private Long id;
private String userName;
private String password;
private String gender;
private Integer age;
private Integer birthYear;
private String addr;
private String email;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name="userName")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Column(name="password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="gender")
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
@Column(name="age")
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
@Column(name="addr")
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
@Column(name="email")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Transient
public Integer getBirthYear() {
return new Integer(2008-age);
}
public void setBirthYear(Integer age) {
this.birthYear = new Integer(2008-age);
}
}
<p>
先谈谈我对java的一些认识。我选择java,是因为他语法简单,功能强大,从web,到桌面,到嵌入式,无所不能。但当我进一步了解了java后,感叹,java原来也有许多缺点。 |
|