ibatis

iBatis学习(一)

我的未来我决定 提交于 2019-12-02 17:47:26
iBatis是一个ORM框架,是一种典型的交互式框架 下面构建一个使用iBatis框架的Java应用程序 系统环境 (1)语言:Java,JDK1.8 (2)数据库:MySQL5.7.11 (3)依赖JAR包:ibatis-2.3.3.720.jar、mysql-connector-java-5.1.38-bin.jar (4)开发工具:Eclispe 项目结构 数据库表dept结构 POJO类 package gc.ibatis.model; /** * 2016-03-20 * @author Administrator * 部门信息POJO类 */ public class Dept { private Integer deptNo; private String deptName; private String deptLocation; public Integer getDeptNo() { return deptNo; } public void setDeptNo(Integer deptNo) { this.deptNo = deptNo; } public String getDeptName() { return deptName; } public void setDeptName(String deptName) { this.deptName =

spring+ibatis整合之jar包引入配置篇

我的未来我决定 提交于 2019-12-02 14:52:36
1.spring-2.5.6.SEC03,再加上spring-webmvc- 3.2.3,马上动手springmvc的工作, 2.使用了spring的注解方式,发生了在spring-2.5.6.SEC03的spring-core包缺少对springmvc的@Controller等一些的注释的支持,于是再引入spring-core- 3.2.3,启动时报spring-2.5.6.SEC03和spring-core中asm.jar冲突。。。,后来直接去掉了spring-2.5.6.SEC03,问题解决。 总结:如果你一定要使用spring-2.5.6.SEC03,不建议使用spring3.0的注释方式。 3.web.xml配置 spring-mvc.xml的配置: 来源: oschina 链接: https://my.oschina.net/u/1174056/blog/141086

How do you write arrays to an Oracle 10g XE db using iBatis?

强颜欢笑 提交于 2019-12-02 08:40:10
I have looked for the answer to this high and low but cannot get the answer. Basically I have an object I am writing to my db using iBatis. This works fine with primitive types like strings, int's etc but one of the attributes of my object is an array of other objects. I would like to be able to persist this and then later call the 'selectById' statement and retrieve the full object including the array. Here is the code I have so far: Mapper.xml <insert id="insertTrade" parameterClass="TradeObject"> insert into TESTTABLE ( ORDERID, MAXPX, COMMISSION, ACCOUNTGRP ) values ( #orderID#, #maxPx#,

数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器

随声附和 提交于 2019-12-02 07:33:14
第1章 引言 随着互联网应用的广泛普及,海量数据的存储和访问成为了系统设计的瓶颈问题。对于一个大型的 互联网应用,每天几十亿的PV无疑对数据库造成了相当高的负载。对于系统的稳定性和扩展性造成了极大的问题。通过数据切分来提高网站性能,横向扩展数据层 已经成为架构研发人员首选的方式。水平切分数据库,可以降低单台机器的负载,同时最大限度的降低了了宕机造成的损失。通过负载均衡策略,有效的降低了单台 机器的访问负载,降低了宕机的可能性;通过集群方案,解决了数据库宕机带来的单点数据库不能访问的问题;通过读写分离策略更是最大限度了提高了应用中读取 (Read)数据的速度和并发量。目前国内的大型互联网应用中,大量的采用了这样的数据切分方案,Taobao,Alibaba,Tencent,它们大 都实现了自己的分布式数据访问层(DDAL)。以实现方式和实现的层次来划分,大概分为两个层次(Java应用为例):JDBC层的封装,ORM框架层的 实现。就JDBC层的直接封装而言,现在国内发展较好的一个项目是被称作“变形虫”(Amoeba)的项目,由阿里集团的研究院开发,现在仍然处于测试阶 段(beta版),其运行效率和生产时效性有待考究。就ORM框架层的实现而言,比如Taobao的基于ibatis和Spring的的分布式数据访问 层,已有多年的应用,运行效率和生产实效性得到了开发人员和用户的肯定

Return Multiple Types from a Single ibatis Query

╄→尐↘猪︶ㄣ 提交于 2019-12-02 06:54:35
I have a search form that needs to include results from two different tables. The tables have no relationship to each other and our separate. In my example scenario, we have gas stations and grocery stores. The grocery store table might have attributes like freezerSize, produceStorage, numberOfCarts. The gas stations table might have gasTankSizeInGallons, windowCleanerInGallons, etc.... There are some shared fields between the two tables (i.e. - numberOfEmployees, squareFeetOfStoreSpace, numberOfShelves, etc...). My search query needs to sort and display the gas stations and grocery stores

Return Multiple Types from a Single ibatis Query

对着背影说爱祢 提交于 2019-12-02 06:39:09
问题 I have a search form that needs to include results from two different tables. The tables have no relationship to each other and our separate. In my example scenario, we have gas stations and grocery stores. The grocery store table might have attributes like freezerSize, produceStorage, numberOfCarts. The gas stations table might have gasTankSizeInGallons, windowCleanerInGallons, etc.... There are some shared fields between the two tables (i.e. - numberOfEmployees, squareFeetOfStoreSpace,

How to Return NULL-values in iBatis?

大兔子大兔子 提交于 2019-12-02 05:41:07
Let's say I have an Oracle database and an interface like this: public interface DaoMapper { @Select({ "SELECT col1, col2, col3", "FROM my_table" }) List<Map<String, Object>> getUntyped(); } If I call getUntyped() and all columns have a value the map contains three entries. However, if col2 is NULL , the map has only two entries. In many cases this isn't a problem, but in a generic part of our code I actually want to call .values() on that map and want a list consisting of three entries. Any entry may be null (or an empty string as that's the same in Oracle). Actually, what I would be really

SSM(Spring-SpringMVC-Mybaits)常见面试题整理

流过昼夜 提交于 2019-12-02 05:34:34
一、Spring面试题 1、Spring 在ssm中起什么作用? Spring:轻量级框架 作用:Bean工厂,用来管理Bean的生命周期和框架集成。 两大核心: ①. IOC/DI(控制反转/依赖注入) :把dao依赖注入到service层,service层反转给action层,Spring顶层容器为BeanFactory。 ②. AOP:面向切面编程 2、Spring的事务? 编程式事务管理:编程方式管理事务,极大灵活性,难维护。 声明式事务管理:可以将业务代码和事务管理分离,用注解和xml配置来管理事务。 3、IOC 在项目中的作用? 作用:Ioc解决对象之间的依赖问题,把所有Bean的依赖关系通过配置文件或注解关联起来,降低了耦合度。 4、Spring的配置文件中的内容? 开启事务注解驱动 事务管理器 开启注解功能,并配置扫描包 配置数据库 配置SQL会话工厂,别名,映射文件 不用编写Dao层的实现类 5、Spring下的注解? 注册:@Controller @Service @Component 注入:@Autowired @Resourcebr/>请求地址:@RequestMapping 返回具体数据类型而非跳转:@ResponseBody 6、Spring DI 的三种方式? 构造器注入:通过构造方法初始化 setter方法注入:通过setter方法初始化 接口注入

作业1 2019/10/23

风格不统一 提交于 2019-12-02 01:46:55
使用注解模式: 接口: package com.test; import com.pojo.Goods; import org.apache.ibatis.annotations.Select; import java.util.List; import java.util.Map; public interface IgoodsMapper { /** * 需求: 通过商品名称 (模糊查询)、供应商(供应商id)、是否付款 * 查询到 订单编码,商品名称,供应商名称,账单,金额,是否付款,创建时间 */ @Select("SELECT g.goodsCode,g.goodsName,p.provider_name,g.money, g.payState,g.timeStart FROM goods g,provider p WHERE g.goodsName LIKE concat('%',#{goods_Name},'%') AND p.provider_id = #{provider_id} AND g.payState = #{goods_payState} AND g.goods_id = p.goods_id") List<Goods> getGoodsList(Map<String,String> map); } IgoodsMapper 测试类: package

【Mybatis框架】输出映射resultType与resultMap

强颜欢笑 提交于 2019-12-01 23:08:05
如果你搜索只是返回一个值,比如说String ,或者是int,那你直接用resultType就行了。 但是你如果是返回一个复杂的对象,就必须定义好这个对象的resultMap的result map。 如果你搜索只是返回一个值,比如说String ,或者是int,那你直接用resultType就行了。 但是你如果是返回一个复杂的对象,就必须定义好这个对象的resultMap的result map。 举个例子吧,例子以ibatis为例: 你有个User 对象, 拥有两个字段id,name。 1.你要获取id为123的name String name = (String) queryForObject("getUserNameByID", id); <select id="getUserNameByID" resultType="java.lang.String"> Select name from User where id =#id# </select> 2.你要获取整个User对象 User user = (User) queryForObject("getUserByID", id); <resultMap class="包.User" id="User"> <result property="id" column="ID" /> <result property="name"