Used to hibernate, and then replaced by MyBatis will encounter some abnormal problems, as the following error prompt, with the MyBatis query, pass in a string argument, and when judged, the error is reported
There is no getter for property named ' Modulecode ' in ' class java.lang.String
DAO Layer Invocation Mode
/* DAO Layer Query * /@Overridepublic list<cityface> findcityfacebycondition (String eqdate) {return Sqlsession.selectlist (CityFace.class.getName () + "_mapper.findcityfacebycondition", eqdate); }
Common error notation:XML Mapping SQL
<select id= "findcityfacebycondition" parametertype= "String" resulttype= "Cityface" >select * FROM (SELECT Unitname, To_char (rdate, ' yyyy-mm ') Rdate,analysistype, scope from cityscapeanalysis) pivot (sum (scope) for Analysistype In (' Esscope ' esscope, ' eoscope ' Eoscope, ' gcscope ' Gcscope, ' cscope ' Cscope) ' <if test= ' eqdate!= ' "' >where Rdate = #{eqdate}</if></select>
Need to be modified to:
<select id= "findcityfacebycondition" parametertype= "String" resulttype= "Cityface" >select * FROM (SELECT Unitname, To_char (rdate, ' yyyy-mm ') Rdate,analysistype, scope from cityscapeanalysis) pivot (sum (scope) for Analysistype In (' Esscope ' esscope, ' eoscope ' Eoscope, ' gcscope ' Gcscope, ' Cscope ' Cscope)) <if test= ' _parameter!= ' ' > where rdate = #{_parameter}</if></select>
Whatever your parameters are, change to "_parameter", but the ID doesn't have to be changed.
Java Invocation ID Example
@Overridepublic visitlogs Findvisitlogsbyid (int id) {return sqlsession.selectone (Visitlogs.class.getName () + "_ Mapper.findvisitlogsbyid ", id);}
XML mapping
<!--query user--><select id= "Findvisitlogsbyid" parametertype= "int" resultmap= "resultvisitlogs" by ID >select * From Visitlogs where id=#{id}</select>
——————————————————————————— Split Line ————————————————————————————
The above is a single string value, if it is multiple values can be used to encapsulate the map object and the Bean class object, and then can be used in a common way to receive, such as the following case
Java Call Map sample
@Overridepublic appuser Loginuser (string userName, string password) {map<string, string> Map = new Hashmap<strin G, string> (); Map.put ("name", UserName), Map.put ("password", password); return Sqlsession.selectone ( AppUser.class.getName () + "_mapper.loginuser", map);}
XML mapping
<!--login user--><select id= "loginuser" parametertype= "map" resulttype= "Appuser" >select * from App_user where Name=#{name} and Password=#{password}</select>
Java invoke Bean class example
@Overridepublic appuser Loginuser (string userName, string password) {appuser user = new Appuser (); User.setname (UserName) ; User.setpassword (password); return Sqlsession.selectone (AppUser.class.getName () + "_mapper.loginuser", user);}
XML mapping
<!--login user--><select id= "loginuser" parametertype= "Appuser" resulttype= "Appuser" >select * from App_user Where Name=#{name} and password=#{password}</select>
Java Invocation ID Example
@Overridepublic visitlogs Findvisitlogsbyid (int id) {return sqlsession.selectone (Visitlogs.class.getName () + "_ Mapper.findvisitlogsbyid ", id);}
XML mapping
<!--query user--><select id= "Findvisitlogsbyid" parametertype= "int" resultmap= "resultvisitlogs" by ID >select * From Visitlogs where id=#{id}</select>
MyBatis incoming SQL query for ID type, string type, map type, ben type parameter