SkillAgentSearch skills...

Briefest

Briefest ORM is a powerful object/relational mapping solution for Java, and makes it easy to develop persistence logic for applications, libraries, and frameworks.

Install / Use

/learn @javaoffers/Briefest
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<a href="https://github.com/javaoffers/briefest/blob/develop/readmeCN.md">中文</a> BaGuCommunity

Brief

<p> <code>brief</code> Is a high-performance, lightweight, easy to use, zero configuration orm framework. Let complex SQL disappear, development efficiency maximization and less amount of code and sustainable higher readability and maintainability. This is the reason for the existence of the <code>brief</code>. <code>Brief</code>Take you to experience unprecedented silky.<img src="https://5b0988e595225.cdn.sohucs.com/images/20171206/5b69749fcaf34927872b15e21b86f44c.gif" width="20px"> </p>

Introduction

<p> Simplify the development. To write SQL like writing Java code. Here we call JQL. And form a set of JQL API process to reduce the SQL error rate. JQL aimed at the complex SQL is decomposed into simple SQL, this is the core of the development brief. <code>brief</code> Support for multiple table joins and does not require any mapping configuration. Brief Support the new writing style. <code>Mapper</code> The default method can directly manipulate JQL API(The premise is extends <code>BriefMapper</code>). Integrates the function of brief, can directly use the API. Let me written in Java streams JQL, improve the development efficiency. Less code and more smooth writing. The performance is twice that of mybatis. </p>

Lightweight machine version

<p> <code>brief-speedier</code> Can be used alone. Do not rely on any environment. </p>
  • maven

      <properties>
           <brief.version>3.6.10</brief.version>
      </properties>
     <!--brief Lightweight and can be used alone-->
       <dependency>
           <groupId>com.javaoffers</groupId>
           <artifactId>brief-speedier</artifactId>
           <version>${brief.version}</version>
     </dependency>
    
     BriefSpeedier speedier = BriefSpeedier.getInstance(dataSource);
     BriefMapper<User> userBriefMapper = speedier.newDefaultBriefMapper(User.class);
     userList = userBriefMapper.select().colAll().where().limitPage(1, 10).exs();
     print(userList);
    

Enhance mybatis

<p> The <code>brief-mybatis</code> is mybatis increased, let <code>mybatis</code> has brief ability. So <code>brief-mybatis</code> is fully compatible with <code>mybatis</code>. If your project is used in the <code>mybatis</code> so you can directly introduced <code>brief-mybatis</code> dependence. Do change, enhance not only introduce it won't affect the existing engineering, silky smooth. Without any configuration. Just need to let your Mapper class inheritance <code>BriefMapper</code> can be used in the feature. </p>
  • maven
    
     <!--The brief-mybatis increased-->
     <dependency>
         <groupId>com.javaoffers</groupId>
         <artifactId>brief-mybatis</artifactId>
         <version>${brief.version}</version>
     </dependency>
    
    

Brief-spring-boot-start

<p> Later will support,support<code>spring-boot</code>. If your spring - the boot project cited mybatis framework, Then you only need to introduce <code>brief-mybatis</code> to mybatis can be enhanced.. </p>

Function is introduced

  • feature

    • High performance queries and insert
    • Don't have to write the native SQL. Can according to the stream of Java API to write.
    • SQL function annotation, simple and easy to use
    • New, supporting the mapper interface class write default default method.
    • Powerful automatic type conversion functions.
    • The optimization of the automatic identification of insert/update batch execution
    • Provide optional automatic identification of difference data real-time update capability
    • Multi-table query does not need to be configured. Automatically map one-to-one, one-to-many, many-to-many.
    • Supports logical deletion, optimistic locking.
    • Integrated with the commonly used API, to directly using the need for development.
    • Support mysql, h2, oracle, sqlserver, clickhouse, sqlite, pgsql grammar standard
    • Table fields automatic decryption (support like fuzzy query).
    • Field query fuzzy desensitization
    • SQL interceptors, are free to customize
    • SQL filter, are free to customize
    • Slow slow SQL monitor. Allow customizable handling of slow SQL.
    • Support json field.
    • Support automatic generation of unique keys
    • Big data streaming
    • Support sharding table
  • Project of actual combat, which has been used internally. The effect is very good.

Based on using

Query operation

<p> Before we see operation, we first look at the data structure: there are two key annotation. @BaseModelUsed to represent the class belongs to the Model classes (class name is the same as the table name, the Model will Help the camel class name converted to underline the name of the table, attribute the same), @BaseUniqueIndicates the only class attributes (corresponding to A unique attribute in A table, when the primary key used in the table that can be more). We will be in the final detailed explanation of the use of annotations. The following is the basic use </p>
@BaseModel
public class User {

   @BaseUnique
   private Long id;

   private String name;

   private String birthday;
   
   private Work work;
   
   private IsDel isDel;
   
   private Version version;  

   @CaseWhen(whens = {
           @CaseWhen.When(when = "money < 10", then = "'pool'"),
           @CaseWhen.When(when = "money > 10000", then = "'rich'")},
           elseEnd = @CaseWhen.Else("'civilian'")
   )
   private String moneyDes;    

   private ExtraInfo extraInfo; //json column

   private List<UserOrder> orders; //Multi-table association zero configuration

   // .... getter setter
}

@BaseModel
public class UserOrder {

   @BaseUnique
   private int id;
   private String orderName;
   private String orderMoney;
     
   //getter, setter  methods  
} 

//json column. Just implement the Json Column interface.
public class ExtraInfo implements JsonColumn {
   private String nickName;
   private Integer age;

   public String getNickName() {
       return nickName;
   }

   public void setNickName(String nickName) {
       this.nickName = nickName;
   }

   public Integer getAge() {
       return age;
   }

   public void setAge(Integer age) {
       this.age = age;
   }

}

A full table query

List<User>  users = crudUserMapper 
                   .select() 
                   .colAll() 
                   .where() 
                   .exs(); 

<p> The JQL will eventually be translated into the select id, name, XXX.. From the user. Query all the table fields colall mean here. If you want to query the specified fields, such as your name and birthday field, can do it:</p>
The query specified table fields
List<User> users = crudusermapper
                   .select()
                   .col (user:: getbirthday)
                   .col (user:: getname)
                   .where()
                   .exs();
The query specified conditions
<p> By col() specifies fields to query. Here's where the where keyword in the () and SQL is the same. Such as to query a user id value is 1, you can write like this: </p>
User user = crudusermapper
            .select() 
            .colAll() 
            .where() 
            .eq(User::getId, 1) 
            .ex();
Paging query
 int pageNum = 1;
 int pageSize = 10;
 List<User> users = crudusermapper
                    .select()
                    .col (user:: getbirthday)
                    .col (user:: getname)
                    .where()
                    .limitPage(1, 10)//  1: the first page, query 10 data
                    .exs();
 
Statistical query
List<User> users = this.crudUserMapper
                       .select()
                       .col(User::getId)
                       .innerJoin(UserTeacher::new)
                       .col(UserTeacher::getTeacherId)
                       .on()
                       .oeq(User::getId, UserTeacher::getId)
                       .innerJoin(Teacher::new)
                       .col(Teacher::getId)
                       .col(AggTag.MAX, Teacher::getName)
                       .on()
                       .oeq(UserTeacher::getTeacherId, Teacher::getId)
                       .where()
                       .gt(User::getId, 0)
                       .groupBy(Teacher::getId)
                       .groupBy(UserTeacher::getTeacherId)
                       .groupBy(User::getId)
                       .having()
                       .gt(AggTag.MAX, User::getId, 0)
                       .gt(AggTag.MAX, UserTeacher::getId, 0)
                       .gt(AggTag.MAX, Teacher::getId, 0)
                       .orderA(User::getId)
                       .orderA(UserTeacher::getId)
                       .orderA(Teacher::getId)
                       .exs();
<p> You will find that there are two special function of exs(), the ex() these two functions on behalf of the trigger. Exs() is usually used to query more data, and returns the result to the list, while the ex T () is used to return a result; JQL must pass to trigger the where and the ex/exs. Most work situations, WHERE behind will add filter conditions, in addition to the special all table data statistics, this design also is very good remind you remember to fill in the WHERE condition, of course, if you don't need to add any WHERE conditions for all table data in the query, you can use the WHERE() the ex(), WHERE() exs() </p>

The insert

Id exOne = crudUserMapper
                .insert()
                .col(User::getBirthday, new Date())
                .col(User::getName, "Jom")
                .ex();
<p> A simple insert statement, returns a wrapper class Id, are usually the primary key of the newly inserted data. An insert it's as simple as that. There's a more simple way to in
View on GitHub
GitHub Stars43
CategoryData
Updated8h ago
Forks6

Languages

Java

Security Score

95/100

Audited on Mar 31, 2026

No findings