Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use weed3-3.1.Xml sql

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report