CN104484177B - A kind of method of mybatis NameSpaces mapping - Google Patents

A kind of method of mybatis NameSpaces mapping Download PDF

Info

Publication number
CN104484177B
CN104484177B CN201410788407.5A CN201410788407A CN104484177B CN 104484177 B CN104484177 B CN 104484177B CN 201410788407 A CN201410788407 A CN 201410788407A CN 104484177 B CN104484177 B CN 104484177B
Authority
CN
China
Prior art keywords
namespace
mapping
prefix
name
fully
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410788407.5A
Other languages
Chinese (zh)
Other versions
CN104484177A (en
Inventor
苏祖辉
支兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing LES Information Technology Co. Ltd
Original Assignee
Nanjing LES Information Technology Co. Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing LES Information Technology Co. Ltd filed Critical Nanjing LES Information Technology Co. Ltd
Priority to CN201410788407.5A priority Critical patent/CN104484177B/en
Publication of CN104484177A publication Critical patent/CN104484177A/en
Application granted granted Critical
Publication of CN104484177B publication Critical patent/CN104484177B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of method of mybatis NameSpaces mapping, the Map Names prefix that NameSpace and configuration file in sqlmapper files provide is matched.When parsing NameSpace, judge whether NameSpace is complete name, if this is not required to be mapped, if not then being mapped plus prefix.So in project migration process, the Map Names prefix of modification configuration file is only needed, in the case where not changing SQLMapper file name spaces, mapping and the calling of the interface document of different bag prefixes can be completed, the cost that project localization is implemented and transplanted effectively is reduced, improves development efficiency.

Description

A kind of method of mybatis NameSpaces mapping
Technical field
The present invention relates to database development technical field, especially a kind of method of framework NameSpace mapping.
Background technology
In current management information system databases exploitation, data access persistent layer ORM frameworks (such as mybatis, Hibernate) using more and more.ORM frameworks are typically adopted using metadata come the relationship map details of description object one, metadata With XML format, and it is stored in the special mapped file of object one.As long as provide the mapping text of lasting classification and database Part, ORM frameworks operationally just can be with reference to the information of mapped file, Object Persistence into database.
In mybatis, developer needs to provide lasting classification and sqlmapper mapped files.Passing through interface mode Under method of calling, it is desirable to which NameSpace and interface fully qualified name are corresponding in sqlmapper files., can when calling interface To find the SQL statement statmentid under corresponding NameSpace by reflection technology.Transplant or localize in project and implement During, the bag name of interface usually needs to change, and this can result in the need for the NameSpace for changing substantial amounts of sqlmapper files. Mybatis provides the calling of interface mappings mode, is brought conveniently to developer.But it is required that in SQLMapper files Namespace must set consistent with the fully-qualified name of interface.Project is in implementation process is localized, it is necessary to which bag path is set It is set to the value specified.Namespace may be needed to change in this large amount of SQLMapper files, and related calling is also required to Modification.Implant system application cost is of a relatively high, and efficiency is also low.
Therefore, it is necessary to a kind of new technical scheme is to solve the above problems.
The content of the invention
The purpose of the present invention is in view of the deficienciess of the prior art, providing a kind of side of mybatis NameSpaces mapping Method, in the case of not changing sqlmapper NameSpaces, by changing the completion of bag prefix and reflecting for interface fully-qualified name Penetrate.
For achieving the above object, the present invention can adopt the following technical scheme that:
A kind of method of mybatis NameSpaces mapping, comprises the following steps:
(a), registration provides the prefix of NameSpace first in framework configuration file, uses configuration attribute propertie To register, the type and value of registration mapping are included in attribute propertie;
(b), can be believed during framework start-up loading according to the correlation of registered propertie information analyses to short name prefix Breath, and complete short name and the mapping of all NameSpace values being resolved to;The name that framework parses sql mapped files first is empty Between, judge whether it is fully-qualified name according to canonical, if it is not, then being mapped according to short name prefix;
(c), obtain the NameSpace if NameSpace is fully-qualified name and be added to buffer area, if not It is then to read short name prefix and be combined with NameSpace and be mapped to fully-qualified name and be added to buffering area;
(d), when user's calling interface, interface fully-qualified name is obtained by reflecting, and arrive corresponding to buffer area lookup Sql maps, and is finally completed the calling of sql sentences.
NameSpace mapping method disclosed in this invention, realized based on canonical method.By in sqlmapper files The Map Names prefix that NameSpace and configuration file provide is matched.When parsing NameSpace, whether NameSpace is judged It is complete name, if this is not required to be mapped, if not then being mapped plus prefix.So in project migration process, only Need the Map Names prefix of modification configuration file.In the case where not changing SQLMapper file name spaces, can complete not Mapping and calling with the interface document of bag prefix, the cost that project localization is implemented and transplanted effectively is reduced, improves exploitation effect Rate.
Embodiment
Described in detail below with bright preferred embodiment.The short name mapping of the present invention is developed using java, configuration File underlying attribute is propertie, and the attribute is used for registering short name configuration information, mainly realizes herein below:
Configuration information title, the title keep unique in the frame
The value of configuration information, can be specific value or the value of regular expression
In order that with log-on message more specification, mybatis NameSpaces short name of the invention mapping is registered using key-value pair Information (is technically not limited to use key-value pair) certainly, so propertie attributes general description is such as:
The method that the present invention will disclose a mybatis NameSpaces mapping, do not changing SQLMapper file designations sky Between in the case of, mapping and the calling of the interface document of different bag prefixes can be completed, effectively reduce project localization implement and The cost of transplanting, improve development efficiency.
NameSpace mapping method disclosed in this invention, realized based on canonical method.By in sqlmapper files The Map Names prefix that NameSpace and configuration file provide is matched.When parsing NameSpace, whether NameSpace is judged It is complete name, if this is not required to be mapped, if not then being mapped plus prefix.So in project migration process, only Need the Map Names prefix of modification configuration file.

Claims (1)

  1. A kind of 1. method of mybatis NameSpaces mapping, it is characterised in that comprise the following steps:
    (a), registration provides the prefix of NameSpace first in framework configuration file, is come using configuration attribute propertie Register, the type and value of registration mapping are included in attribute propertie;
    (b), during framework start-up loading can according to the relevant information of registered propertie information analyses to short name prefix, And complete short name and the mapping of all NameSpace values being resolved to;Framework parses the NameSpace of sql mapped files, root first Judge whether it is fully-qualified name according to canonical;
    (c), obtain the NameSpace if NameSpace is fully-qualified name and be added to buffer area, if it is not, then Read short name prefix and be combined with NameSpace and be mapped to fully-qualified name and be added to buffering area;(d), when user calls During interface, interface fully-qualified name is obtained by reflecting, and to sql mappings corresponding to buffer area lookup, is finally completed sql sentences Calling.
CN201410788407.5A 2014-12-17 2014-12-17 A kind of method of mybatis NameSpaces mapping Active CN104484177B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410788407.5A CN104484177B (en) 2014-12-17 2014-12-17 A kind of method of mybatis NameSpaces mapping

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410788407.5A CN104484177B (en) 2014-12-17 2014-12-17 A kind of method of mybatis NameSpaces mapping

Publications (2)

Publication Number Publication Date
CN104484177A CN104484177A (en) 2015-04-01
CN104484177B true CN104484177B (en) 2017-12-05

Family

ID=52758721

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410788407.5A Active CN104484177B (en) 2014-12-17 2014-12-17 A kind of method of mybatis NameSpaces mapping

Country Status (1)

Country Link
CN (1) CN104484177B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046170B (en) * 2019-04-22 2021-07-27 深圳乐信软件技术有限公司 Statement execution method, device, equipment and medium based on multi-file management
US11595493B2 (en) 2020-09-28 2023-02-28 Oracle International Corporation System and method for namespace masking in an integration flow

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101339559A (en) * 2008-07-18 2009-01-07 北京航空航天大学 Long lasting implementing method for data
CN103744680A (en) * 2014-01-16 2014-04-23 北京邮电大学 Method and device for business process processing
CN103942281A (en) * 2014-04-02 2014-07-23 北京中交兴路车联网科技有限公司 Method and device for operating object persistently stored

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101339559A (en) * 2008-07-18 2009-01-07 北京航空航天大学 Long lasting implementing method for data
CN103744680A (en) * 2014-01-16 2014-04-23 北京邮电大学 Method and device for business process processing
CN103942281A (en) * 2014-04-02 2014-07-23 北京中交兴路车联网科技有限公司 Method and device for operating object persistently stored

Also Published As

Publication number Publication date
CN104484177A (en) 2015-04-01

Similar Documents

Publication Publication Date Title
US20230041991A1 (en) Density-based dynamic geohash
US10657111B2 (en) Computer-implemented method for storing unlimited amount of data as a mind map in relational database systems
US10546057B2 (en) Spreadsheet program-based data classification for source target mapping
EP2924588A1 (en) Report creation method, device and system
RU2008147401A (en) SYSTEM AND METHOD FOR PROVIDING A VIRTUAL DATABASE ENVIRONMENT AND FORMING DIGITAL CARD INFORMATION
CN103838837B (en) Remote sensing Metadata integration method based on semantic template
CN105808609A (en) Discrimination method and equipment of point-of-information data redundancy
CN104063365B (en) The method that object is inserted into PDF document
RU2003119092A (en) SYSTEM AND METHOD OF SUPPORTING "OWN" XML IN "OWN" XML IN A TEXT PROCESSOR DOCUMENT
US9773028B2 (en) Manipulating non-schema attributes for objects in a schema based directory
CN103473289A (en) Device and method for completing communication addresses
CN104462421A (en) Multi-tenant expanding method based on Key-Value database
CN103500060B (en) The manufacture method of electronic chart, producing device, display packing and display device
US8015195B2 (en) Modifying entry names in directory server
CN104317909A (en) Method and device for verifying data of points of interest
CN106469372A (en) A kind of address mapping method and device
US20180357330A1 (en) Compound indexes for graph databases
CN104484177B (en) A kind of method of mybatis NameSpaces mapping
CN105808627A (en) POI information updating method and device, POI information search method and device as well as POI data packet generation method and device
CN103079194B (en) Service adaptation method, apparatus and system
CN104808995B (en) A kind of method and apparatus for across application collection application content
CN107562955A (en) A kind of rapid generation of SQL statement
CN107273443A (en) A kind of hybrid index method based on big data model metadata
CN110032574B (en) SQL statement processing method and device
CN116362219A (en) Information extraction template generation method and device, medium and equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant