All Projects → zjzcn → esbatis

zjzcn / esbatis

Licence: other
Elasticsearch's Mybatis

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to esbatis

mybatis-examples
mybatis 使用示例
Stars: ✭ 78 (+420%)
Mutual labels:  mybatis
vertx-mybatis
vertx sqlclient template using mybatis NON-BLOCK & ASYNCHRONOUS
Stars: ✭ 23 (+53.33%)
Mutual labels:  mybatis
Java-CMS-Framework-Base jeesite.com
Java管理后台快速开发SSM框架_优化版-JDK1.8 spring,springMVC,MyBatis,mysql,shiro,redis,ehcache
Stars: ✭ 21 (+40%)
Mutual labels:  mybatis
SpringBootMovie
基于Spring Boot的电影网站
Stars: ✭ 56 (+273.33%)
Mutual labels:  mybatis
seckill parent
基于springboot+springcloud的高并发和商品秒杀项目,通过redis,rabbitmq等技术实现秒杀的高并发。
Stars: ✭ 59 (+293.33%)
Mutual labels:  mybatis
NeusoftCloudHospital
东软云医院。爱与健康,连接你我。🏥
Stars: ✭ 37 (+146.67%)
Mutual labels:  mybatis
mybatis-generator-plugin
MyBatis 生成模板代码的逻辑以插件的形式部署
Stars: ✭ 25 (+66.67%)
Mutual labels:  mybatis
learn-java-demo
java学习demo
Stars: ✭ 17 (+13.33%)
Mutual labels:  mybatis
carina-demo
Carina demo project.
Stars: ✭ 40 (+166.67%)
Mutual labels:  mybatis
seezoon-framework-all
Seezoon快速开发平台基于spring mybatis shiro jquery 完全的前后端分离的后台管理系统,采用最简单技术,实现快速开发.
Stars: ✭ 47 (+213.33%)
Mutual labels:  mybatis
MarketServer
基于Springboot + Mybatis框架实现的一个简易的商场购物系统后端。该有的基础功能它都有!
Stars: ✭ 26 (+73.33%)
Mutual labels:  mybatis
SpringBootDataSourceMutil
spring-boot、Spring MVC、Mybatis、JTA实现多数据源动态切换,读写分离,加入Retry重试机制
Stars: ✭ 19 (+26.67%)
Mutual labels:  mybatis
tmontica-admin
티몬 개발인턴 3기 프로젝트 - 사내 카페 주문 시스템(관리자)
Stars: ✭ 12 (-20%)
Mutual labels:  mybatis
pighelper
🐷基于Hybrid+SSM的养猪信息化管理平台,该平台实现了对实时新闻,猪价的爬虫获取,以及各类养殖账单的增删改查等等。该项目适配了移动端界面,最终通过Hybrid混合式App开发技术打包成App,安装在移动端使用
Stars: ✭ 25 (+66.67%)
Mutual labels:  mybatis
SimpleCurd
2个类,实现类ActiveRecord,无需写Mapper, mybatis增强
Stars: ✭ 14 (-6.67%)
Mutual labels:  mybatis
read
学习笔记 dubbo,rocketmq 源码解析
Stars: ✭ 33 (+120%)
Mutual labels:  mybatis
PECI-Java-MAR-2015
Repositorio del curso de Java de Mar 2015
Stars: ✭ 29 (+93.33%)
Mutual labels:  mybatis
cc-s
一个基于spring boot、druid、mybatis、mysql的后端基础
Stars: ✭ 22 (+46.67%)
Mutual labels:  mybatis
SpringBootIntegration
SpringBoot集成学习项目 SpringBoot Integration
Stars: ✭ 20 (+33.33%)
Mutual labels:  mybatis
Online-Testing-Platform
在线考试系统 colleges online examination system base on spring-boot and MyBatis
Stars: ✭ 21 (+40%)
Mutual labels:  mybatis

Maven

<dependency>
    <groupId>com.github.zjzcn</groupId>
    <artifactId>esbatis</artifactId>
    <version>1.0.1</version>
</dependency>

Exemple

1. Mapper file

<?xml version="1.0" encoding="UTF-8" ?>
<mapper namespace="com.github.esbatis.test.DemoDao">
<index id="index" method="put" url="demo/demo/${demo.id}">
    {
        "id" : ${demo.id},
        "age" : ${demo.age},
        "date" : "${demo.date}"
    }
</index>

<search id="findDemo" method="post" url="/demo/demo/_search?pretty=true ">
    {
        "query": {
            "bool": {
                "must": [
                    {
                        "term": {
                            "id": "${id}"
                        }
                    }
                ]
            }
        }
    }
</search>

<update id="update" method="post" url="/demo/demo/1/_update">
    {
        "doc":{
        "id" : ["4", "2"]
        }
    }
</update>

<bulk id="bulk" method="post" url="_bulk">
    { "index" : { "_index" : "demo", "_type" : "demo", "_id" : "AV5cARtspYdDC3WQaBdK1" } }
    { "id" : [1] }
    { "delete" : { "_index" : "demo", "_type" : "demo", "_id" : "AV5cARtspYdDC3WQaBdK" } }
</bulk>

<mget id="mget" method="post" url="_mget">
{
"docs" : [
    {
    "_index" : "demo",
    "_type" : "demo",
    "_id" : "60"
    }
    ]
}
</mget>

<update_by_query id="updateByQuery" method="post" url="demo/demo/_update_by_query">
    {
    "query": {
    "match": {
    "message": "some message"
    }
    }
    }
</update_by_query>

<index id="insertPolygon" method="put" url="/demo/demo1/1?pretty=true ">
    {
        "name" : "sh",
        "location" : {
            "type" : "polygon",
            "coordinates" : [[
            [4.88330,52.38617],
            [4.87463,52.37254],
            [4.87875,52.36369],
            [4.88939,52.35850],
            [4.89840,52.35755],
            [4.91909,52.36217],
            [4.92656,52.36594],
            [4.93368,52.36615],
            [4.93342,52.37275],
            [4.92690,52.37632],
            [4.88330,52.38617]
            ]]
        }
    }
</index>
</mapper>

*Placeholder is ${}, not #{}.

2. DemoDao file(Parameter must have @Param)

@Repository
public interface DemoDao {
    Long index(@Param("demo") Demo demo);
}

3. Data model

public class Demo {
    private Long id;
    private String createdAt;
    private String updatedAt;
    private List<Long> age;
}

4. Spring integration

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring.xml");
    DemoDao demoDao = applicationContext.getBean(DemoDao.class);
    Demo demo = new Demo();
    demo.setId(3L);
    demo.setCreatedAt(LocalDate.now().toString());
    demo.setUpdatedAt(LocalDate.now().toString());

    demoDao.index(demo);

5. Spring config

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <array>
            <value>classpath:config.properties</value>
        </array>
    </property>
</bean>

<bean id="restClient" class="com.github.esbatis.client.RestClient">
    <constructor-arg name="hosts" value="${es.hosts}" />
</bean>

<bean id="mapperFactory" class="com.github.esbatis.spring.MapperFactoryBean">
    <property name="restClient" ref="restClient" />
    <property name="mapperLocations" >
        <list>
            <value>classpath*:mapper/*.xml</value>
        </list>
    </property>
    <property name="executorFilters">
        <list>
            <bean class="com.github.esbatis.test.TimeSpanFilter" />
        </list>
    </property>
</bean>

<bean id="scannerConfigurer" class="com.github.esbatis.spring.MapperScannerConfigurer">
    <property name="mapperFactoryBeanId" value="mapperFactory" />
    <property name="basePackage" value="com.github.esbatis.test" />
    <property name="annotationClass" value="org.springframework.stereotype.Repository" />
</bean>
</beans>

6. Executor filter

public class TimeSpanFilter implements ExecutorFilter {

private ThreadLocal<Long> timestamp = new ThreadLocal<>();

@Override
public void exception(FilterContext context) {
    System.out.println("------------exception----------");
    timestamp.remove();
    context.getException().printStackTrace();
}

@Override
public void before(FilterContext context) {
    timestamp.set(System.currentTimeMillis());
}

@Override
public void after(FilterContext context) {
    Long start = timestamp.get();
    timestamp.remove();
    System.out.println("time span = " + (System.currentTimeMillis() - start));
}
}

7. Date format

ES built in format: strict_date_optional_time
Date type format(ISO8601): yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

8. Result handler

@Result(UserResultHandler.class)
Integer avgUser(@Param("index") String index, @Param("type") String type,
                @Param("list") List<String> list, @Param("user") User user);

// result handler
public class UserResultHandler implements ResultHandler<Integer> {
@Override
public Integer handleResult(String result) {
    System.out.println(result);
    return 10;
}

}

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].