bitscn.com
最近在深入学习hibernate,在进行批量操作时,发现hibernate批量操作性能非常低.于是就想找一个性能较高的方法,在对jdbc、jdbctemplate、hibernate进行测试后,发现jdbc的执行效率是最高的,jdbctemplate也很相近,hibernate就不考虑了,惨不忍睹啊.下面把代码写出来,希望大家批评指正.
首先domain对象.在这里使用的注解的方式,都是比较新的版本.
user.java 1 package com.bao.sample.s3h4.domain; 2 3 import javax.persistence.column; 4 import javax.persistence.entity; 5 import javax.persistence.generatedvalue; 6 import javax.persistence.generationtype; 7 import javax.persistence.id; 8 import javax.persistence.table; 9 10 import com.bao.sample.base.domain.basedomain;11 12 @entity13 @table(name = t_user)14 public class user extends basedomain {15 16 private static final long serialversionuid = 1l;17 private int id;18 private string username;19 private string password;20 21 /**22 * @description 注解最好标记在get方法上.注意:采用一致的标记方式,注解是以id的标记方式为准的,如果标记在get方法上,则忽略property上的注解.23 * @return24 */25 @id26 @generatedvalue(strategy = generationtype.identity)27 public int getid() {28 return id;29 }30 31 public void setid(int id) {32 this.id = id;33 }34 35 @column(nullable = false)36 public string getusername() {37 return username;38 }39 40 public void setusername(string username) {41 this.username = username;42 }43 44 @column(nullable = false)45 public string getpassword() {46 return password;47 }48 49 public void setpassword(string password) {50 this.password = password;51 }52 53 public user() {54 super();55 }56 57 public user(int id, string username, string password) {58 super();59 this.id = id;60 this.username = username;61 this.password = password;62 }63 64 }
bitscn.com