Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use weed3-3.1.Xml sql

Shulou Source: shulou.com Published: 2022-06-02 09:44:21 10月03日 Update

This article mainly explains how to use weed3-3.1.Xml sql. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn how to use weed3-3.1.Xml sql.

Weed3 A Micro ORM Framework (Only 0.1Mb Oh)

Source code: github.com/noear/weed3 Source code: gitee.com/noear/weed3

Use of Conventions ***

1. convention resources/weed3/is xml sql root directory

2. Project start compilation parameters: -parameters

Prepare to start with a simple example.

This time you need to quote a meven plug-in (played mybatis all understand)

frame references

org.noear weed3 3.2.2.4

meven plug-in references (used to generate mapper classes)

org.noear weed3-maven-plugin 3.2.2.2 First, write a simple XML file.

resources/weed3/DbUserApi.xml

SELECT * FROM `user` WHERE id=@{user_id} There are two ways to call XML SQL.

Via db.call ("@... ") call

DbContext db = new DbContext(...); UserModel um = db.call("@weed3demo.xmlsql.user_get") .set("user_id") .getItem(UserModel.class);

Generate Mapper interfaces for use with dynamic proxies

1. Use the meven plugin to generate it (double-click: weed3:generator)

2. Java file generated (java/weed3demo/xmlsql/DbUserApi.java)

package weed3demo.xmlsql;@Namespace("weed3demo.xmlsql")public interface DbUserApi{ /** */ weed3demo.mapper.UserModel user_get(int user_id);}

3. try

//global public static void main(String[] args){ //configure a context with a name (for xml mapper) DbContext db = new DbContext(...). nameSet("testdb");//Get xml mapper DbUserApi dbUserApi = XmlMapper.get(DbUserApi.class) through proxy; //Use it UserModel tmp = dbUserApi.user_get(10);} At this point, I believe that everyone has a deeper understanding of "weed3-3.1.Xml sql usage", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Methods generation usage plug-ins content files frameworks source code agents learning conventions practical deeper upper and lower context examples information global interest dynamic Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info MySQL Linux Shulou Technology