CN104484177A - Mybatis namespace mapping method - Google Patents

Mybatis namespace mapping method Download PDF

Info

Publication number
CN104484177A
CN104484177A CN201410788407.5A CN201410788407A CN104484177A CN 104484177 A CN104484177 A CN 104484177A CN 201410788407 A CN201410788407 A CN 201410788407A CN 104484177 A CN104484177 A CN 104484177A
Authority
CN
China
Prior art keywords
namespace
mapping
name
prefix
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.)
Granted
Application number
CN201410788407.5A
Other languages
Chinese (zh)
Other versions
CN104484177B (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

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a mybatis namespace mapping method. The method comprises the following steps of matching a namespace in an SQLMapper file and a mapping name prefix provided by a configuration file; while resolving the namespace, judging whether the namespace is a complete name or not, if the namespace is a complete name, avoiding mapping, and if the namespace is not a complete name, adding the premix and mapping. Consequently, in an item transplantation process, as long as the mapping name prefix of the configuration file is modified, mapping and calling of different interface files with prefixes can be finished under the condition of not modifying the namespace of the SQLMapper file, so that the item localization implementation and transplantation costs are effectively lowered and the development efficiency is improved.

Description

A kind of method that mybatis NameSpace maps
Technical field
The present invention relates to database development technical field, the method that especially a kind of framework NameSpace maps.
Background technology
In the exploitation of current management information system databases, data access persistent layer ORM framework (as mybatis, hibernate) uses more and more.ORM framework adopts metadata to carry out description object one relationship map details, and metadata generally adopts XML format, and leaves in special object one mapped file.As long as provide the mapped file of lasting classification and database, ORM framework operationally just can with reference to the information of mapped file, Object Persistence in database.
In mybatis, developer needs to provide lasting classification and sqlmapper mapped file.By under interface mode method of calling, require NameSpace and interface fully qualified name correspondence in sqlmapper file.When calling interface, the SQL statement statmentid under corresponding NameSpace can be found by reflection technology.In project transplanting or localized implementation process, the bag name of interface usually needs change, and this can cause the NameSpace needing to revise a large amount of sqlmapper files.Mybatis provides calling of interface mappings mode, brings conveniently to developer.But require that in SQLMapper file, namespace must set consistent with the fully-qualified name of interface.Project is in localized implementation process, and needing bag path setting is the value of specifying.In SQLMapper files a large amount of like this, namespace may need amendment, and relevant calling also needs amendment.Implant system application cost is relatively high, and efficiency is also low.
Therefore, need a kind of new technical scheme to solve the problem.
Summary of the invention
The object of the invention is the deficiency existed for prior art, a kind of method that mybatis NameSpace maps is provided, when not revising sqlmapper NameSpace, complete the mapping with interface fully-qualified name by what revise bag prefix.
For achieving the above object, the present invention can adopt following technical scheme:
The method that mybatis NameSpace maps, comprises the following steps:
(a), first in chassis configuration file, registration provides the prefix of NameSpace, uses configuration attribute propertie to register, and comprises type and value that registration maps in attribute propertie;
Can according to the relevant information of registered propertie information analysis to short name prefix when (b), framework start-up loading, and the mapping of all NameSpace values completing short name and be resolved to; First framework resolves the NameSpace of sql mapped file, judges whether it is fully-qualified name according to canonical, if not, then map according to short name prefix;
If c () NameSpace is fully-qualified name, obtains this NameSpace and be added into buffer area, if not, then read short name prefix and carry out combinatorial mapping with NameSpace become fully-qualified name and be added into buffer zone;
(d), when user's calling interface, obtain interface fully-qualified name by reflection, and search corresponding sql mapping to buffer area, finally complete calling of sql statement.
NameSpace mapping method disclosed in this invention, realizes based on canonical method.Map Names prefix NameSpace and configuration file in sqlmapper file provided is mated.When resolving NameSpace, judge whether NameSpace is complete name, if this does not need to map, if not then add that prefix maps.Like this in project migration process, only need the Map Names prefix revising configuration file.When not revising SQLMapper file name space, the mapping of the interface document of different bag prefix can be completed and call, the cost that effective reduction project localization is implemented and transplanted, improving development efficiency.
Embodiment
To be described this in detail with bright preferred embodiment below.Short name of the present invention maps and adopts java exploitation, and configuration file underlying attribute is propertie, and this attribute is used for registering short name configuration information, mainly realizes following content:
Configuration information title, this title keeps unique in the frame
The value of configuration information can be concrete value, also can be the value of regular expression
In order to use log-on message more specification, mybatis NameSpace short name of the present invention maps and adopts key-value pair log-on message (being certainly technically not limited to use key-value pair), thus propertie attribute general description as:
The present invention will disclose the method for a mybatis NameSpace mapping, when not revising SQLMapper file name space, the mapping of the interface document of different bag prefix can be completed and call, the cost that effective reduction project localization is implemented and transplanted, improving development efficiency.
NameSpace mapping method disclosed in this invention, realizes based on canonical method.Map Names prefix NameSpace and configuration file in sqlmapper file provided is mated.When resolving NameSpace, judge whether NameSpace is complete name, if this does not need to map, if not then add that prefix maps.Like this in project migration process, only need the Map Names prefix revising configuration file.

Claims (1)

1. a method for mybatis NameSpace mapping, is characterized in that, comprise the following steps:
(a), first in chassis configuration file, registration provides the prefix of NameSpace, uses configuration attribute propertie to register, and comprises type and value that registration maps in attribute propertie;
Can according to the relevant information of registered propertie information analysis to short name prefix when (b), framework start-up loading, and the mapping of all NameSpace values completing short name and be resolved to; First framework resolves the NameSpace of sql mapped file, judges whether it is fully-qualified name according to canonical, if not, then map according to short name prefix;
If c () NameSpace is fully-qualified name, obtains this NameSpace and be added into buffer area, if not, then read short name prefix and carry out combinatorial mapping with NameSpace become fully-qualified name and be added into buffer zone;
(d), when user's calling interface, obtain interface fully-qualified name by reflection, and search corresponding sql mapping to buffer area, finally complete calling of sql statement.
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 true CN104484177A (en) 2015-04-01
CN104484177B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046170A (en) * 2019-04-22 2019-07-23 深圳乐信软件技术有限公司 Sentence based on multifile management executes method, apparatus, equipment and medium
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

Cited By (2)

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

Also Published As

Publication number Publication date
CN104484177B (en) 2017-12-05

Similar Documents

Publication Publication Date Title
CN103699689B (en) Method and device for establishing event repository
US8069184B2 (en) Systems and methods to implement extensibility of tenant content in a provider-tenant environment
CN103810257A (en) Method and device for upgrading software database and equipment
CN102566990B (en) Method and device for performing data manipulation in Java application
CN102541867A (en) Data dictionary generating method and system
CN102129539A (en) Data resource authority management method based on access control list
CN103678575B (en) By the method and system of the unified process of Middleware implementation several data database data
CN106649771A (en) Data model updating method and system for database
US9773028B2 (en) Manipulating non-schema attributes for objects in a schema based directory
CN105589881B (en) Data processing method and device
CN109284273B (en) Massive small file query method and system adopting suffix array index
CN106528641B (en) Data storage method and device and communication gateway machine
CN103064908B (en) A kind of method by the quick duplicate removal list of internal memory
CN111723161A (en) Data processing method, device and equipment
CN105843867A (en) Metadata model-based search method and search device based on metadata model
CN110866024A (en) Vector database increment updating method and system
TW569110B (en) Dynamic database management system and method
CN104484177A (en) Mybatis namespace mapping method
CN106649588B (en) Method, device and system for acquiring installed application program list
CN105677805A (en) Data storing and reading method and device using protobuf
CN106919607B (en) Data access method, device and system
CN100440803C (en) Gridding information model system and method for modeling processing gridding information
US10185757B2 (en) Non-uniform multi-row text file loading
CN104808995B (en) A kind of method and apparatus for across application collection application content
CN103927168A (en) Object-oriented data model persistence method and device

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