This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12110|Reply: 1

[Source] Spring and MyBatis integrate the text type pit in the automatically generated code

[Copy link]
Posted on 9/5/2018 5:12:16 PM | | | |
Problem description

If there is a text or blob field in the database table. The auto-generated database profile is as follows, with several additional methods and resultMaps ending in withBlobs:

If the query or update data is still used using selectByExample or updateByExample, the text or blob data obtained is null.As shown in the following figure:



Doing it right

You should use either selectByExampleWithBLOBs or updateByExampleWithBLOBs.




In the code generated by mybatis reverse engineeringselectByExample and selectByExampleWithBLOBs, what's the difference between these two methods?

Problem Analysis:

1> The resultMap returned by the two methods is different

selectByExample method returns: BaseResultMap

selectByExampleWithBLOBs method returns: ResultMapWithBLOBs

ResultMapWithBLOBs inherits the BaseResultMap and has its own special field, which is usually of type longvarchar,

2> use scenarios are different

If you want to retrieve large fields, you need to use selectByExampleWithBLOBs, and in general, you can use selectByExample.





Previous:SQL Server jobs
Next:Mybatis automatically generates an Xml file, and XXX will be generated by default for field types such as text...
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com