在Mybatis传值想后台传条件值问题

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_34178998/article/details/83026174

今天遇到一个问题一直报错,我需要向后台传递要查询的条件。

<!-- 根据分组id查询全部信号灯设备 -->
	<select id="selectLightByGroupid" resultMap="DevTrafficLightVo">
		SELECT
		<!-- rg_rgl_group_info.ID AS ID, -->
		rg_rgl_group_info.NAME AS NAME,
		rg_dev_traffic_light.DEV_NAME AS
		DEV_NAME,
		rg_dev_traffic_light.id,
		( SELECT camera_id FROM
		rg_light_camera_link WHERE rg_dev_traffic_light.ID =
		rg_light_camera_link.TRAFFIC_LIGHT_ID )
		AS cameraId,
		rg_cross.CROSS_NAME AS crossName
		FROM
		(
		(
		rg_cross
		JOIN
		rg_dev_traffic_light
		)
		JOIN rg_rgl_group_info
		)
		WHERE
		(
		
		rg_dev_traffic_light.CROSS_ID = rg_cross.ID
		
		AND 
		rg_cross.GROUP_ID =
		rg_rgl_group_info.ID
		
		<if test="groupid != null">
			AND rg_rgl_group_info.ID = #{groupid}
		</if>
		
		)
	</select>

开始时,是直接传递<if>标签中的数据,但是一直报错

There is no getter for property named 'groupid' in 'class java.lang.Long'

后来从网上查到,需要将if标签中的数据

<if test="_parameter != null">
	AND rg_rgl_group_info.ID = #{groupid}
</if>

参考我之前有篇文章。

展开阅读全文

传址与传值问题

03-08

做了个例子rnModule module1rn Sub aa(ByRef p() As Integer, ByVal q() As Integer, ByRef s() As Integer, ByVal t() As Integer)rn Dim i As Integerrn Console.WriteLine("传递进过程的数组值")rn Console.Write("P:")rn For i = 0 To UBound(p)rn Console.Write(CStr(p(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("Q:")rn For i = 0 To UBound(q)rn Console.Write(CStr(q(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("S:")rn For i = 0 To UBound(s)rn Console.Write(CStr(s(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("T:")rn For i = 0 To UBound(t)rn Console.Write(CStr(t(i)) + " ")rn Nextrn Console.WriteLine()rnrn For i = 0 To UBound(p)rn p(i) = p(i) + i ^ 3rn Nextrn For i = 0 To UBound(q)rn q(i) = q(i) + i ^ 3rn Nextrn For i = 0 To UBound(s)rn s(i) = s(i) + i ^ 3rn Nextrn For i = 0 To UBound(t)rn t(i) = t(i) + i ^ 3rn Nextrn Console.WriteLine("运行后数组值")rn Console.Write("P:")rn For i = 0 To UBound(p)rn Console.Write(CStr(p(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("Q:")rn For i = 0 To UBound(q)rn Console.Write(CStr(q(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("S:")rn For i = 0 To UBound(s)rn Console.Write(CStr(s(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("T:")rn For i = 0 To UBound(t)rn Console.Write(CStr(t(i)) + " ")rn Nextrn Console.WriteLine()rn End Subrn Sub main()rn Dim x() As Integer = 10, 10, 10rn Dim y() As Integer = 10, 10, 10rn Dim m() As Integer = 10, 10, 10rn Dim n() As Integer = 10, 10, 10rn Dim i As Integerrn Console.WriteLine("原始数组值")rn Console.Write("X:")rn For i = 0 To UBound(x)rn Console.Write(CStr(x(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("Y:")rn For i = 0 To UBound(y)rn Console.Write(CStr(y(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("M:")rn For i = 0 To UBound(m)rn Console.Write(CStr(m(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("N:")rn For i = 0 To UBound(n)rn Console.Write(CStr(n(i)) + " ")rn Nextrn Console.WriteLine()rnrn Call aa(x, y, m, n)rn Console.WriteLine("运行后的数组值")rn Console.Write("X:")rn For i = 0 To UBound(x)rn Console.Write(CStr(x(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("Y:")rn For i = 0 To UBound(y)rn Console.Write(CStr(y(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("M:")rn For i = 0 To UBound(m)rn Console.Write(CStr(m(i)) + " ")rn Nextrn Console.WriteLine()rn Console.Write("N:")rn For i = 0 To UBound(n)rn Console.Write(CStr(n(i)) + " ")rn Nextrn Console.WriteLine()rn Console.ReadLine()rn End SubrnEnd Modulernrn得到的答案是rn原始数组值rnX:10 10 10rnY:10 10 10rnM:10 10 10rnN:10 10 10rn传递进过程的数组值rnP:10 10 10rnQ:10 10 10rnS:10 10 10rnT:10 10 10rn运行后数组值rnP:10 11 18rnQ:10 11 18rnS:10 11 18rnT:10 11 18rn运行后的数组值rnX:10 11 18rnY:10 11 18 //本人疑问:此处是传值的,应该还原成Y:10 10 10,为什么数值却被保留下来了rnM:10 11 18rnN:10 11 18 //本人疑问:此处是传值的,应该还原成N:10 10 10,为什么数值却被保留下来了rnrn请各位帮小弟被惑啊rnrnrnrn 论坛

传值与传址的简单问题

03-01

代码;rnrnpublic class PassByValue1 rn int i=0;rn PassByValue1(int newValue) rn i=newValue;rn rn static void changeInt(int value)rn value=98;rn System.out.println("value in changeInt()="+value);rn rn static void changeObjRef(PassByValue1 obj)rn obj=new PassByValue1(99);rn System.out.println("obj.i in changeObjRef()="+obj.i);rn rn static void changeObjAttr(PassByValue1 obj)rn obj.i=100;rn System.out.println("obj.i in changeObjAttr()="+obj.i);rn rn public static void main(String[] args) rn int value=2;rn System.out.println("value before changeInt()="+value);rn changeInt(value);rn System.out.println("value after changeInt()="+value);rn PassByValue1 obj=new PassByValue1(2);rn System.out.println("------------");rn System.out.println("obj before changeObjRef()="+obj);rn System.out.println("obj.i before changeObjRef()="+obj.i);rn changeObjRef(obj);rn System.out.println("obj.i after changeObjRef()="+obj.i);rn System.out.println("obj after changeObjRef()"+obj);rn System.out.println("------------");rn System.out.println("obj before changeObjAttr()="+obj);rn System.out.println("Obj.i before changeObjAttr()="+obj.i);rn changeObjAttr(obj);rn System.out.println("obj.i after changeObjAttr()="+obj.i);rn System.out.println("obj agter changeObjAttr()="+obj);rn rnrn结果:rnrnvalue before changeInt()=2rnrnvalue in changeInt()=98rnrnvalue after changeInt()=2rnrn------------rnrnobj before changeObjRef()=passbyvalue1.PassByValue1@5d87b2rnrnobj.i before changeObjRef()=2rnrnobj.i in changeObjRef()=99rnrnobj.i after changeObjRef()=2rnrnobj after changeObjRef()passbyvalue1.PassByValue1@5d87b2rnrn------------rnrnobj before changeObjAttr()=passbyvalue1.PassByValue1@5d87b2rnrnObj.i before changeObjAttr()=2rnrnobj.i in changeObjAttr()=100rnrnobj.i after changeObjAttr()=100rnrnobj agter changeObjAttr()=passbyvalue1.PassByValue1@5d87b2rnrn如何理解以上结果?特别是rnobj before changeObjRef()=passbyvalue1.PassByValue1@5d87b2rnrnobj.i before changeObjRef()=2rnrnobj.i in changeObjRef()=99rnrnobj.i after changeObjRef()=2rnrnobj after changeObjRef()passbyvalue1.PassByValue1@5d87b2rnrn------------rnrnobj before changeObjAttr()=passbyvalue1.PassByValue1@5d87b2rnrnObj.i before changeObjAttr()=2rnrnobj.i in changeObjAttr()=100rnrnobj.i after changeObjAttr()=100rnrnobj agter changeObjAttr()=passbyvalue1.PassByValue1@5d87b2rn 论坛

函数参数传值和传地址的问题

08-02

先说一下我对delphi函数参数传值和传地址的理解,一般我认为在参数中不带var的传进去是参数值的副本,带var的传的是地址,不知道我理解的是否片面。rn今天在使用TiniFiles的TIniFile.ReadSections(Strings: TStrings)时候忽然想这个Strings按我的理解应该是传值,所以说传进去的参数在退出函数后应该不会变,但是做个试验后发现它是会变的,以下是测试的代码:rn这是ini文件的内容:rn[Test]rna=rnb=rnc=rn[code=Delphi(Pascal)]unit Unit1;rnrninterfacernrnusesrn Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,rn Dialogs,IniFiles, StdCtrls;rnrntypern TForm1 = class(TForm)rn Button1: TButton;rn Button2: TButton;rn Button3: TButton;rn procedure Button1Click(Sender: TObject);rn procedure Button2Click(Sender: TObject);rn procedure Button3Click(Sender: TObject);rn privatern Private declarations rn publicrn Public declarations rn procedure A(x:string);rn procedure B(var y : string);rn end;rnrnvarrn Form1: TForm1;rnrnimplementationrnrn$R *.dfmrnrnprocedure TForm1.Button1Click(Sender: TObject);rnvarrn ini : TIniFile;rn ls : TStringList;rnbeginrn tryrn ls := TStringList.Create;rn ini := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Test.ini');rn ini.ReadSections('Test',ls);rn ShowMessage(ls.CommaText); //ls内容是a,b,c,不应该是空的吗?rn finallyrn ini.Free;rn FreeAndNil(ls); rn end; rnend;rnprocedure TForm1.A(x : string);rnbeginrn x := x+'###';rnend;rnprocedure TForm1.Button2Click(Sender: TObject);rnvarrn x1 : string;rnbeginrn x1 := 'Test';rn A(x1);rn ShowMessage(x1); // 这个x1还是‘Test’rnend;rnprocedure TForm1.B(var y : string);rnbeginrn y := y+'###';rnend;rnprocedure TForm1.Button3Click(Sender: TObject);rnvarrn x1 : string;rnbeginrn x1 := 'Test';rn B(x1);rn ShowMessage(x1); //这个x1是‘Test###’,按照我理解的是对的,我长期也是这么用的rnend;rnrnend.rn[/code]rn如果是我理解错了,那真正的应该怎么解释? 论坛

没有更多推荐了,返回首页