first, the realization principle
The Mapper interface development method requires only programmers to write mapper interfaces (equivalent to the DAO Interface), and the MyBatis framework creates interface dynamic proxy objects based on interface definitions, and the proxy object's method body implements the class method with the top DAO interface.
Map
Summary after reading:O/R Mapping is the relational object ing.Databases are used to map classes and data tables.The advantage is that it can automatically generate an object to save, delete, and read SQL statements.Currently, ado.net objectspaces does not support Chinese queries. The version only supports SQL Server 2000 or later;Looking forward to ADO. net2.0
Original article:What is o/R mapper?
Author: Huo www.aspcool.com time: 13:35:56 views:
-missing issues when converting from string JSON to type. Like what Case class = Mapper.readvalue ("{}", Classof[demo]) println (Demo)Demo (false,0,null,0.0)In case of Spray.json occurrence key missing, it will exceptionAnd for the domain key there is a redundant situationJackson ErrorVal demo1 = Mapper.readvalue ("{\" x\ ": true, \" y\ ": 1100, \" c\ ": \" str\ ", \" d\ ": \" Str\ "}", CLA Ssof[demo])Spray.json is no problem.There is no relationship between the order of the variables, and two
Jackson JSON and objects, several transformations of the collectionPackage Com.crm.net.util;import Java.io.bufferedreader;import Java.io.bytearrayinputstream;import Java.io.ioexception;import Java.io.inputstreamreader;import Java.util.list;import Org.codehaus.jackson.jsonparseexception;import Org.codehaus.jackson.map.deserializationconfig;import Org.codehaus.jackson.map.jsonmappingexception;import Org.codehaus.jackson.map.objectmapper;import Org.codeh
Use Jackson to parse a good JSON file here:
Http://sarin.iteye.com/blog/821534
The core part is as follows:Try {Jsonfactory = new mappingjsonfactory ();// JSON parserJsonparser = jsonfactory. createjsonparser (jsontext );// Jump to the start of the result setJsonparser. nexttoken ();// Hashmap that accepts the resultHashmap // While loop traverses the JSON resultWhile (jsonparser. nexttoken ()! = Jsontoken. end_object ){// Jump to valueJsonparser. ne
kind and pure, this world is not worthy of having you such a caring and talented person, this upside down black and white, non-unknown world can not hold you, God loves you, love you, love you, do you know? We love you too, but we cannot violate God's will and can't keep you! I really hope that you will find your happiness and happiness in heaven. God is just, and he will give you the crown that should belong to you! I hope to meet you in heaven in the future, continue to listen to your touchin
();//Here you can see the fetch message byte stream try { if (payload instanceof byte[]) { return This.objectMapper.readValue ((byte[]) payload, javatype);//This is the core of the conversion } else { return This.objectMapper.readValue (String) payload, javatype);} } catch (IOException ex) { throw new messageconversionexception (message, "Could not read JSON:" + ex.getmessage (), ex) ; } }6.
Objective:Jackson Common methods:Jackson is the usual two ways to handle the conversion between generic Java objects and JSON are the writevalueasstring () and ReadValue () methods of the Objectmapper class that can be implemented.However, if it is to be turned into a list collection of the specified generics, such as listCollection Type;To illustrate:If it is a listgettypefactory (). Constructparametrictype (List.class, User.class);If it is a hashmapgettypefactory (). Constructparametrictype (H
Spring-data-jpa -- if one-to-one and others-to-one annotations are used, an error solution will appear during Jackson's json String Conversion,
References:
Http://blog.csdn.net/remote_roamer/article/details/51330843
Http://blog.csdn.net/xiaodaiye/article/details/51118870
In spring-data-jpa, one-to-one and two-to-one annotations are used to produce json strings.
Find the following solutions after reading the information:
Add @ JsonManagedReference to the pojo of the master table to annotate
BackgroundA clean spring+spring mvc+mybatis frame is required, and the framework writes the error to the return JSON link.ProblemCan't json, quote 406SolveNeed to configure the JSON toolkit, here with JacksonMaven JacksonEngineering Environment SPRINGMVC 4.x, incompatible with Jackson2.9 latest version. Here Special Application 2.6 versionSpring MVC ConfigurationOK, reboot does not error (in general is the Jar Treasure conflict), you can normally receive the JSON returned by @responsebody.The ab
Workaround:1. There is an escape character in the JSON string, which can be replaced or the transfer character can be cleared directly after ToString.Reference:https://stackoverflow.com/questions/40986738/ spring-data-rest-no-string-argument-constructor-factory-method-to-deserialize/40986739http://blog.csdn.net/legend_x/article/details/31767083http://www.oschina.net/question/227902_163010https://stackoverflow.com/questions/40166309/ No-string-argument-constructor-factory-method-to-deserialize-fr
The default output of time when we use Jackjson is as follows:Output is a string of time stamps, do not meet our requirements, so think of Jackjson on the processing of time has his default format, and then collect all kinds of information on the Internet, to get a way to solveTo cancel the format of Jackjson default processing time:FALSE);The time format for the output after Setup is "1970-01-01t00:00:00.000+0000".We can customize the time format:SimpleDateFormat mydateformat=New SimpleDateForm
not write, the same. Let me see the result, I this interface is this output: Public security Network prepared query, to http://www.sojson.com/api/gongan/sina.com.cn for example { "data":{ "id": "11000002000016", "sitename": "Sina Net", " SiteDomain ":" sina.com.cn ", " SiteType ":" Interactive ", " CDate ":" 2016-01-21 ", "ComType": "Enterprise", "comname": "Beijing Sina Internet Information Service Co.,
"," visible ": 0," id ": 2," size ":" Medium "," date ":" 08-01-2007 "},{" price ": 83.81," Company ":" Altria GroupInc "," visible ": 0," id ": 3," size ":" Large "," date ":" 08-03-2007 "},{" price ": 52.55, ' company ':" American Express Company ", "Visible": 1, "id": 4, "size": "EXTRATP link router wireless signal can transmit how many metersLarge "," date ":" 01-04-2008 "},{" price ": 64.13," Company ":" American International GroupInc. "," Visible ": 1," id ": 5," size ":" Small "," date
1, column:112] (through reference chain:com.webservice.net.model.getaffairnewslistresponse["list"]-> com.webservice.net.model.affairnewslist["Publishtime"1, column:112] (through reference chain: com.webservice.net.model.getaffairnewslistresponse["List"]->com.webservice.net.model.affairnewslist[" Publishtime "])Encountered such an error, mainly the server data and client data types are inconsistent, the Publishtime data type encountered here, the server is a datetime type, and my client data is a
be useful in a row data entry. Moving these logic over and over makes the row data entry evolve into an activity record, reducing the duplication of business logic.4.2 Field ModelsIf you want to change the structure of the database but do not want to change the domain logic, the use of row data entry is a good choice. In most cases, the data mapper is more suited to the domain model.Row data entry can be used in conjunction with the data
Tags: turn off CTO replacement batch Scanner EXCE EFAULT not LSEI. Overview of SqlsessionIn MyBatis, you can use Sqlsessionfactory to create sqlsession. Once you have a session, you can use it to execute the mapping statement, commit or rollback the connection, and finally, when you no longer need it, you can close the session. After using mybatis-spring, you no longer need to use sqlsessionfactory directly, because your bean can be injected through a thread-safe sqlsession, automatically commit
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.