Today we have a strange problem, and at first we define a global variable with the following code:@property (strong,nonatomic) nsdictionary *newhomedatadictionary;The result has been reported error: property's synthesized getter follows Cocoa naming convention for returning ' owned ', looked for a long time also find no problem, then the front new word, found can , and it was discovered that Apple banned all variables defined by the New keyword, and l
Customizing the Person classclass Person: NSObject { var name: String? var age: Int?}Getter Settervar _name: String?var name: String? { get { return _name } set { _name = newValue }}
SwiftGetter Setter in the above form is seldom used
Didset
In OC, we usually want to do some extra work after assigning a value to a variable.
The most classic application is to complete the cell's fill with the model's setup method when
If you use spring.net as your IOC container, be sure to pay attention to this problem. --spring.net currently does not support access qualifiers of getter and setter.
We usually use the setter attribute for dependency injection, for example, public Class.
{
# Region B
Private B;
Public B
{
Get {return B ;}
Set {B = value ;}
}
# Endregion
}
Public Class B{}
For the above definition, it is completely normal to configure a Class A object in spring.net a
In object-oriented language, attributes are usually set to private, and then the getter and setter methods are added for access. Some people say that this is essentially different from setting an attribute as public. Simply calculate the attribute as public. Some people have refuted this and destroyed the encapsulation. But what are the disadvantages of destroying encapsulation?
When I was reading a handout on C ++ at Stanford University today, I saw
Mybatis single parameter if judgment (for exception: There is no getter for property...), mybatisgetter
We all know that mybatis can directly use
1. General Code
However, there is a difference between single parameter and multi-parameter judgment. When our input parameter is an entity object or map, it is no problem to use the if parameter to judge.
But when our input parameter is java. lang. Integer or java. lang. String, you need to pay attenti
This article for Bo Master original, without permission may not be reproduced:Exception display:The DAO layer defines the interface as: Public int getclienttotal ();The SQL in MyBatis is: Select COUNT (*) as Oldnum from Tbl__client_info if test= "Zoneid!=null and!quot;quot ;. Equals (Zoneid.trim ()) "> = #{zoneid} if> At run time, the console reports an exception:Caused By:org.apache.ibatis.reflection.ReflectionException:There is no
Query with MyBatis, only one parameter passed in (not map) such as int, error for property named ' Sleevetype ' in ' class Java.lang.IntegerThe reason is that the test conditions are wrong, ifTest= "Sleevetype==0">Exclusive -exclusive=1if> ifTest= "Sleevetype!=0">Non-exclusive -Sleeve_type=#{sleevetype} and Exclusive=0if>Correct wording: ifTest= "_parameter==0">Exclusive -exclusive=1if> ifTest= "_parameter!=0">Non-exclusive -Sleeve_type=#{sleevetype} and Exclusive=0if
Often the details of the wrong thing is the most deadly thing, when you look at the code, logically no problem, but also exposed some inexplicable selves here wrong, you BaiduSaid the reason is also a mess of chicken ribs! Very helpless, tangled for a long time, wasting a lot of precious times ... Look at the code!UpdateID= "Updateuser2"ParameterType= "User">Update Ckx_userSet> offTest= "UserName! = NULL">Username=#{username},if> ifTest= "PassWord! = NULL">Password=#{passwo
In the new ECMAScript5, two new syntactic sugars have been added, and these two syntactic sugars are the same.var obj = (function() { var num = ten; return { get N () { return num; }, set N (v) { = v; } =Console.log (OBJ.N);Get means to read a value, in fact the implementation of get and set is a function, note that these two methods can only be used in the object, the other need to: remove, previously we write object properties need
The error is that the following line is in one of the classes under your project@property (retain, nonatomic) NSString *newimage;The mistake was to use the New keyword, so I changed the new word to news.Strictly speaking, the main cause of the error is to follow the memory management principles when declaring attributes, i.e. do not use certain keywordsCompilation Error property ' s synthesized getter follows COCOA naming convention for returning ' o
When using Mybaitis to pass parameters, if only one parameter of type string is passed in, the XML file should use _parameter instead of the parameter name.The correct wording:[HTML]View Plain
span style="FONT-SIZE:18PX;" > -
Select id= "iscargobillnoexist" resulttype="Java.lang.Integer">
Select COUNT (1)
From T_entry_cargo_receiver_info
where 1=1
if test="_parameter! = null" >
and cargo_bill_no = #{_parameter,jdbctype=VARCHAR}
If>
Select>span>
The wrong
When using Mybaitis to pass parameters, if only one parameter of type string is passed in, the XML file should use _parameter instead of the parameter name. The correct wording:[HTML]View Plaincopyprint?
span style="FONT-SIZE:18PX;" > -
Select id= "iscargobillnoexist" resulttype="Java.lang.Integer">
Select COUNT (1)
From T_entry_cargo_receiver_info
where 1=1
if test="_parameter! = null" >
and cargo_bill_no = #{span style="color: #ff0000;" >_parameterspan;,jdbctype=VA
You can completely not rewrite these two methods, but when you get used to the two methods you will find that can greatly simplify the codeFor example, you have a label in your class, and then you define a public property lablecolor to get the color of this label fontIf you do not use the Get method, each time the font color of the label changes you have to assign a value to Lablecolor, so as to ensure that the obtained color is right, but if you rewrite the Lablecolor get method, just return [
In Mapper.xml, if the single parameter is a string type, and the parameters are judged in the SQL statement, the following is the same as if the If judgment appears. It is necessary to replace the parameters in the judgment with _parameter.In addition, it is null to determine whether a field is empty in orcal, in the same vein, it is not NULL to judge not to be empty.Error query:Id= "Select"Resultmap= "Resultmap"parametertype= "String" select Name,code,parent,level from Table = "Code!
When querying with MyBatis, a string is passed in to pass parameters, and when judged, it is reported is for ' Modulecode ' inch ' class java.lang.String Error wording:SelectId="Queryallparentmodule" Resulttype="Jobmodule" ParameterType="Jobmodule"> SelectModulecode, ModuleName, Modulevalue, Linkurl, rank, Parentmodule=IsNull(Parentmodule,1), Moduledescription fromJob_modulewhere> Choose> whenTest="Modulecode!=NULL andModulecode!="'">Modulecode=#{module
46738747Using the MyBatis pass-through parameter, if you use the Interface:Public interface Usermapper {Query users by nameList}?Mapping.xml:?Selectt_id as ID,T_name as name,T_password as passwordFrom Mybatis_userwhere 1=1and T_name=#{name}ORDER BY t_idThere is no getter for property named ' ID ' in class ' java.lang.String '
First, the problem foundSelect Num,name,phone from Studentand num = #{num}The MyBatis query passes in a string-pass parameter, and is reported to there is no getters for the property named ' Num ' in ' Class java.lang.String '.Second, solve the problemSelect Num,name,phone from student _parameter!=null and_parameter! =" >and num = #{_parameter}Regardless of the parameter name, change to "_parameter".Third, the reason analysisMyBatis by default with ONGL parsing parameters, so the object tree wi
I. Discovering problemsSelect Bzwzname, sum (buynumber) as Stocknumber from X_bzwz_ruku Group by Bzwzname_parameter!=null and name_parameter! =" "> have bzwzname like '% ' | | #{name_parameter}| | ' % ' Regardless of the parameter name, change to "_parameter".Three. cause AnalysisMyBatis by default with ONGL parsing parameters, so the object tree will automatically take the form of string.name values, causing error. The public List methodName (@Param (value= "name") String name can also be used
Before modificationSelectID= "Getgroupid"ParameterType= "Java.lang.Long"Resulttype= "Com.capinfo.weibo.system.entity.ColumnGroup">SELECT * from Common_columngroup Cwhere> ifTest= "Accountid!=null">C.accountid=#{parameter} and c.type=2if> where> Select>If the incoming type is a long type, the parameter needs to be uniformly modified to [_parameter], and the modified SQL statement is as follows (whatever your parameters are, change to "_parameter")SelectID= "Getgroupid"ParameterType= "
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.