JOIN US框架-3(hibernate怎么变成这么好用了?)

来源:互联网 发布:刚开的淘宝店卖什么好 编辑:程序博客网 时间:2024/04/28 22:09

JOIN US框架中,hibernate变成这样了,哦,可恶的hql和实体类我们不用了,我们的机制是最后都是通过sql走的,效率取决于你的sql的效率,和ibatis的半自动有点像了,所有的表都在这里,pojo类也是用myeclipse自动生成的,无hibernate xml映射文件了,你见过吗?

这里笔者只截几个图示范

1:单表插入

2:单表修改

3:多表查询

4:多表编辑事务提交(事务提交的一种方式)


 /**
  * 添加卖家
  *
  * @param tSellerbasicinfo
  *            卖家基本信息
  * @param tSellerdetailinfo
  *            卖家详细信息
  * @return 添加结果
  */
 public boolean insertSeller(TSellerbasicinfo tSellerbasicinfo,
   TSellerdetailinfo tSellerdetailinfo,
   TSellersysrolerelation tSellersysrolerelation) {

  // ISQLModel list
  ArrayList<ISQLModel> list = new ArrayList<ISQLModel>();

  // 设置参数
  // 卖家基本信息
  tSellerbasicinfo.setId(UUIDUtil.getUUID()); // uuid
  tSellerbasicinfo.setSellerPassword(securityUtil
    .generateSellerDefaultPwd()); // 默认登陆密码
  tSellerbasicinfo.setSellerRegisterTime(timeUtil.getCurrTimeBySeconds()); // 注册时间
  tSellerbasicinfo.setDeleteFlag((short) 0); // 删除标记
  // 卖家详细信息
  tSellerdetailinfo.setId(tSellerbasicinfo.getId()); // 用户ID
  tSellerdetailinfo.setDeleteFlag((short) 0);// 删除标记
  // 卖家系统角色关系
  tSellersysrolerelation.setId(UUIDUtil.getUUID()); // uuid
  tSellersysrolerelation.setSellerId(tSellerbasicinfo.getId()); // 用户id
  tSellersysrolerelation.setDeleteFlag((short) 0);// 删除标记
  // 账户信息表
  TAccount tAccount = new TAccount();// 账户信息表
  tAccount.setId(UUIDUtil.getUUID()); // uuid
  tAccount.setAccountNum(dataTableUtil.getTableGenerateSwiftNum()); // 账户流水号
  tAccount.setAccountBalance(0d); // 账户余额
  tAccount.setUserType(ServerUserTypeEnum.userType_2.getCode()); // 用户类型-卖家
  tAccount.setUserId(tSellerbasicinfo.getId()); // 用户ID
  tAccount.setDeleteFlag((short) 0);// 删除标记

  // IDAO对象
  IInsertSQLModel tSellerbasicinfoModel = new IInsertSQLModel(
    BITableEnum.t_sellerbasicinfo.getTableName(),
    beanMapUtil.objToHashMap(tSellerbasicinfo)); // 卖家基本信息
  IInsertSQLModel tSellerdetailinfoModel = new IInsertSQLModel(
    BITableEnum.t_sellerdetailinfo.getTableName(),
    beanMapUtil.objToHashMap(tSellerdetailinfo)); // 卖家详细信息
  IInsertSQLModel tSellersysrolerelationModel = new IInsertSQLModel(
    BITableEnum.t_sellersysrolerelation.getTableName(),
    beanMapUtil.objToHashMap(tSellersysrolerelation)); // 卖家系统角色关系
  IInsertSQLModel tAccountModel = new IInsertSQLModel(
    BITableEnum.t_account.getTableName(),
    beanMapUtil.objToHashMap(tAccount)); // 账户信息

  // IDAO对象添加到list
  list.add(tSellerbasicinfoModel);
  list.add(tSellerdetailinfoModel);
  list.add(tSellersysrolerelationModel);
  list.add(tAccountModel);

  // 数据库操作
  return sIDAO.iUpdateListBySQL(list, true);
 }


5:查询数量


0 0