Most of our programming processes use excellent ORM frameworks, such as MYBATIS,HIBERNATE,SPRINGJDBC, but these are not dependent on data-driven JDBC support. Although it is very convenient to use, but it is difficult to encounter some problems, such as trouble me a sleepless night, JDBC generated execution data, we look at the specific.
Typically, we use the MyBatis framework to manipulate relational databases, which are basically crud operations. The company is currently using the SQL Server database, but I have a problem with the update operation, as follows:
Mapper.xml content:
<update id= "Updatedriverinfobyucode" parametertype= "Com.sypro.earth.model.DriverInfo" >
update d_ Driverinfo
<set >
<if test= "drivername!= null" >
drivername = #{drivername,jdbctype=nvarchar },
</if>
</set>
<where>
Ucode=#{ucode,javatype=string,jdbctype=varchar, Typehandler=com.sypro.earth.typehandler.exampletypehandler}
</where>
</update>
The test code is as follows:
@Test public
void Test8 () {
driverinfo driverinfo=new driverinfo ();
Driverinfo.setdrivername ("Wang Xiao");
Driverinfo.setucode ("TY888888");
Driverinfomymapper.updatedriverinfobyucode (Driverinfo);
}
Just update the driver's name according to the work number, but the SQL statements detected with SQL Server monitoring are generally as follows:
(@P0 nvarchar (4000), @P1 nvarchar (4000)) Update D_driverinfo
SET drivername = @P0,
Of course I'm going to post my database connection string here:
Jdbc\:sqlserver\://127.0.0.1;databasename\=new;
This time the execution plan can look at:
Http://www.jb51.net/article/90264.htm
Can be seen very slowly, but by slightly modifying the connection string:
Jdbc\:sqlserver\://127.0.0.1;databasename\=new;sendstringparametersasunicode=false
Then execute the test code and you can see
(@P0 varchar (8000), @P1 varchar (8000)) Update d_driverinfo
SET drivername = @P0,
where ucode= @P1
Batch update implementation speed significantly improved, as for why change and the pros and cons please see the following official website documents
Https://technet.microsoft.com/zh-cn/library/ms378857%28SQL.90%29.aspx
Https://technet.microsoft.com/zh-cn/library/ms378988%28v=sql.90%29.aspx
http://d.hatena.ne.jp/gnarl/20110706/1309945379
The above is a small set to introduce the MyBatis through the JDBC data driven by the implementation of the statement problem, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!