您的位置:首页 > 游戏 > 游戏 > 使用ORM Bee时, Condition, SuidRich的方法中, 字段是否支持使用Orders::getName的形式,避免使用静态字段串写死字段值

使用ORM Bee时, Condition, SuidRich的方法中, 字段是否支持使用Orders::getName的形式,避免使用静态字段串写死字段值

2024/10/6 20:37:58 来源:https://blog.csdn.net/abckingaa/article/details/139566553  浏览:    关键词:使用ORM Bee时, Condition, SuidRich的方法中, 字段是否支持使用Orders::getName的形式,避免使用静态字段串写死字段值

使用ORM Bee时, Condition, SuidRich的方法中, 字段是否支持使用Orders::getName的形式,避免使用静态字段串写死字段值.

可以使用V2.4.0 的ConditionExt和SuidRichExt

需要引用BeeExt.

示例代码如下:

package org.teasoft.exam.bee.osql.ext24;import org.teasoft.bee.osql.Op;
import org.teasoft.bee.osql.api.SuidRich;
import org.teasoft.beex.osql.api.ConditionExt;
import org.teasoft.beex.osql.api.SuidRichExt;
import org.teasoft.beex.osql.shortcut.BFX;
import org.teasoft.exam.bee.osql.entity.Orders;
import org.teasoft.honey.osql.shortcut.BF;/*** @author Kingstar* @since  2.4.0*/
public class TestBFX {public static void main(String[] args) {ConditionExt conditionExt=BFX.getConditionExt();conditionExt.op(Orders::getAbc, Op.eq, "value11");SuidRich suidRich=BF.getSuidRich();suidRich.count(new Orders(), conditionExt);conditionExt.selectField(Orders::getAbc,Orders::getRemark);suidRich.select(new Orders(), conditionExt);SuidRichExt suidRichExt=BFX.getSuidRichExt();suidRichExt.select(new Orders(),Orders::getAbc,Orders::getRemark);}}

日志:

[Bee] LoggerFactory Use the Logger is : org.teasoft.honey.logging.SystemLogger
[Bee] The current Level in SystemLogger is :debug
[INFO] [Bee] ========= BeeInitPreLoadService initLoad...
[INFO] [Bee] ========= Preload class PreLoadInit, load...
[INFO] [Bee] ========= Preload class ExtPreLoadInit, load...
[INFO] [Bee] -------- Bee    2.4.0 -------- 
[INFO] [Bee] -------- Honey  2.4.0 -------- 
[INFO] [Bee] -------- BeeExt 2.4.0 -------- 
[DEBUG] [Bee] ========= Bee    buildId  2.4.0.6
[DEBUG] [Bee] ========= Honey  buildId  2.4.0.6
[DEBUG] [Bee] ========= BeeExt buildId  2.4.0.6
[INFO] [Bee] ========= get the dbName via url is: MySQL
[INFO] [Bee] select fun SQL : select count(*) from orders where abc=?   [values]: value11(String)
[INFO] [Bee] select fun SQL :  ( ExecutableSql )
select count(*) from orders where abc='value11' ;
[WARN] Do not set the database info: bee.db.driverName do not config; 
[DEBUG] Use OriginalConn!
[INFO] [Bee] select SQL: select abc, remark from orders where abc=?   [values]: value11(String)
[INFO] [Bee] select SQL:  ( ExecutableSql )
select abc, remark from orders where abc='value11' ;
[INFO] [Bee]  | <--  select rows: 0
[INFO] [Bee] select SQL(selectFields) : select abc, remark from orders   [values]: 
[INFO] [Bee] select SQL(selectFields) :  ( ExecutableSql )
select abc, remark from orders
[INFO] [Bee]  | <--  select rows: 2

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com