package com.bao.sample.s3h4.domain; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import com.bao.sample.base.domain.BaseDomain; @Entity @Table(name = "t_user") public class User extends BaseDomain { private static final long serialVersionUID = 1L; private int id; private String username; private String password; /** * @Description 注解最好标记在get方法上.注意:采用一致的标记方式,注解是以Id的标记方式为准的,如果标记在get方法上,则忽略property上的注解. * @return */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) public int getId() { return id; } public void setId(int id) { this.id = id; } @Column(nullable = false) public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @Column(nullable = false) public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public User() { super(); } public User(int id, String username, String password) { super(); this.id = id; this.username = username; this.password = password; } }
接下来是Dao接口,继承一个BaseDao接口.
复制代码 代码如下:
package com.bao.sample.s3h4.dao; import java.util.List; import com.bao.sample.base.dao.BaseDao; import com.bao.sample.s3h4.domain.User; public interface UserBatchDao extends BaseDao<User> { /** * @Description 批量增加操作 * @return -1:操作失败;0:执行正常;>0:执行成功的数目 */ public int batchAddUsingJdbc(List<User> users); public int batchAddUsingHibernate(List<User> users); public int batchAddUsingJdbcTemplate(List<User> users); }