CN102521274A - Ibatis-based SQL script dynamic loading method - Google Patents

Ibatis-based SQL script dynamic loading method Download PDF

Info

Publication number
CN102521274A
CN102521274A CN2011103774123A CN201110377412A CN102521274A CN 102521274 A CN102521274 A CN 102521274A CN 2011103774123 A CN2011103774123 A CN 2011103774123A CN 201110377412 A CN201110377412 A CN 201110377412A CN 102521274 A CN102521274 A CN 102521274A
Authority
CN
China
Prior art keywords
sql
ibatis
configuration
script
information
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.)
Pending
Application number
CN2011103774123A
Other languages
Chinese (zh)
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.)
SHANGHAI MINGXIANG ELECTRONIC TECHNOLOGY Co Ltd
Original Assignee
SHANGHAI MINGXIANG ELECTRONIC 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 SHANGHAI MINGXIANG ELECTRONIC TECHNOLOGY Co Ltd filed Critical SHANGHAI MINGXIANG ELECTRONIC TECHNOLOGY Co Ltd
Priority to CN2011103774123A priority Critical patent/CN102521274A/en
Publication of CN102521274A publication Critical patent/CN102521274A/en
Pending legal-status Critical Current

Links

Images

Landscapes

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

Abstract

The invention discloses an ibatis-based SQL script dynamic loading method. The method comprises the following steps of: a) configuring multiple independent SQL configuration files, and uniformly setting the cache regions of all the SQL configuration files; b) when a script calling party searches the SQL information, firstly, reading the SQL configuration information from the cache region, if the SQL script configuration information exists, starting a program to automatically load the corresponding SQL configuration file to the cache region, otherwise, searching the SQL configuration and updating the cache region; c) removing the file information from the SQL configuration file after loading; d) finally, reading corresponding SQL script information from the cache region, and returning the read SQL script information to the calling party. In the ibatis-based SQL script dynamic loading method provided by the invention, multiple independent SQL configuration files are configured and corresponding configuration files are loaded as needed, thus, a master control SQL configuration file is saved, which is easy for management and realizing modularized development, and improves system performance.

Description

A kind of SQL script dynamic loading method based on ibatis
Technical field
The present invention relates to a kind of SQL script dynamic loading method, relate in particular to a kind of SQL script dynamic loading method based on ibatis.
Background technology
The database access mode in present Java field, using mainly has been hibernate and iBATIS, the both belongs to open source software.IBATIS one speech derives from the combination of " internet " and " abatis ", is an open source code project of being initiated in calendar year 2001 by Clinton Begin.Laying particular emphasis on the exploitation of cipher software at first, is a persistent layer framework based on Java now.The persistent layer framework that iBATIS provides comprises SQL Maps and Data Access Objects (DAO), and a JPetStore instance that utilizes this framework exploitation also is provided simultaneously." one-stop " ORM solutions such as relative Hibernate and Apache OJB, ibatis is that the ORM of a kind of " semi-automation " realizes.So-called " semi-automation "; Be that relative Hibernate etc. provides " full-automation " ORM of comprehensive database encapsulation mechanism to realize; " automatically ", ORM realized the mapping between POJO and the database table, and automatic generation and the execution of SQL.And the center of effort of ibatis then is the mapping relations between POJO and the SQL.That is to say that ibatis can't carry out for the programmer generates SQL automatically in the runtime.Concrete SQL needs the programmer to write, then through Map Profile, and the parameter that SQL is required, and the result field that returns is mapped to appointment POJO.
But the use-pattern of iBATIS relatively is fit to the waterfall type exploitation at present, not too meets present modularization developing thought.Fig. 1 is existing SQL script dynamic load process synoptic diagram based on ibatis; See also Fig. 1; The sql script file of all these required visits of system in the configuration just is loaded into these scripts in the buffer memory in the application start process in a unified sqlConfig file.When the user needs accessing database, directly from buffer memory, obtain corresponding script, do not report an error if do not exist directly.IBATIS has following shortcoming:
(1) a unique sqlmapConfig configuration file must be arranged, the inside configuration is gone up all needs the sqlmap file of accessing database, and centralized management and modularization exploitation have conflict;
(2) in the project exploitation, many people remove to safeguard this a sqlmapConfig file jointly, and code is submitted to and caused conflict easily;
(3) if dispose a plurality of databases, that just means many parts of sqlmapConfig of needs configuration, and other configuration items need many parts too, and configuration file is redundant;
(4) can not discern disparate databases automatically, load the sqlmap file of correspondence database type.
Therefore be necessary existing SQL script dynamic loading method based on ibatis is improved, can discern disparate databases automatically and load the script configuration file of correspondence database, thereby realize the modularization exploitation.
Summary of the invention
Technical matters to be solved by this invention provides a kind of SQL script dynamic loading method based on ibatis, can discern different sql configuration files and load corresponding script configuration file automatically, thereby realize the modularization exploitation.
The present invention solves the problems of the technologies described above the technical scheme that adopts to provide a kind of SQL script dynamic loading method based on ibatis, comprises the steps: a) a plurality of independently sql configuration files of configuration, the unified buffer area that all sql configuration files are set; B) script calls side goes to earlier the buffer area the inside to read sql script configuration information, if exist when searching sql information; Start-up routine loads corresponding sql configuration file automatically to buffer area; Otherwise it is unusual to dish out, and prompting makes mistakes, and searches the sql configuration file renewal buffer area of coupling; C) after the loading this document information is removed from the sql configuration file; D) from buffer area, read corresponding sql script information at last and return to called side.
The above-mentioned SQL script dynamic loading method based on ibatis, wherein, said step b) adopts the method for traversal to carry out search matched and load corresponding sql configuration file to buffer area.
The above-mentioned SQL script dynamic loading method based on ibatis, wherein, said a plurality of different sql configuration files disperse to be arranged in the functional module separately.
The above-mentioned SQL script dynamic loading method based on ibatis, wherein, different sql configuration files is adopted in the data of different types storehouse.
The above-mentioned SQL script dynamic loading method based on ibatis, wherein, said data of different types storehouse comprises Oracle, Mysql and Sql Server database.
The present invention contrasts prior art has following beneficial effect: the SQL script dynamic loading method based on ibatis provided by the invention, through disposing a plurality of independently sql configuration files, saved total control sql configuration file, and be easy to management and realize the modularization exploitation; In addition, SQL script dynamic loading method of the present invention loads corresponding configuration file as required, thereby has promoted system performance.
Description of drawings
Fig. 1 is existing SQL script dynamic load process synoptic diagram based on ibatis;
Fig. 2 is the SQL script dynamic load process synoptic diagram that the present invention is based on ibatis.
Embodiment
Below in conjunction with accompanying drawing and embodiment the present invention is done further description.
Fig. 2 is the SQL script dynamic load process synoptic diagram that the present invention is based on ibatis.
See also Fig. 2, the SQL script dynamic loading method based on ibatis provided by the invention comprises the steps: a) a plurality of independently sql configuration files of configuration, the unified buffer area that all sql configuration files are set; B) script calls side goes to earlier the buffer area the inside to read sql script configuration information, if exist when searching sql information; Start-up routine loads corresponding sql configuration file automatically to buffer area; Otherwise it is unusual to dish out, and prompting makes mistakes, and searches the sql configuration file renewal buffer area of coupling; C) after the loading this document information is removed from the sql configuration file; D) from buffer area, read corresponding sql script information at last and return to called side.
SQL script dynamic loading method based on ibatis provided by the invention; Can be in the system starting process according to certain regular reading configuration file information; The namespace of sqlmap and the corresponding relation of sql script file have been write down in the information the inside of this configuration file; In case can avoid repeating loading and cause system exception with this corresponding record deletion from internal memory after loading, the content in the physical file can not deleted.After the system of treating restarts, can the file configuration information completely be loaded in the internal memory again.
SQL script dynamic loading method based on ibatis provided by the invention; Has following advantage: 1) owing to can be put in each functional module by different sql configuration files, and do not need a total control configuration file, can accomplish the modularization exploitation; Total system can be combined disparate modules; Also can be at any time with module removal, and do not influence other functions, need not make line code to change; 2) load the sql configuration file automatically; All right elevator system performance only just can go to load in certain sql configuration file of needs, uses if some functions are out-of-date unmanned; So corresponding sql configuration file can not be loaded in the buffer memory yet and go, and promotes performance.
SQL script dynamic loading method based on ibatis provided by the invention, the preferred method of traversal that adopts is carried out search matched and is loaded corresponding sql configuration file to buffer area; A plurality of different sql configuration files can disperse to be arranged in the functional module separately; Different sql configuration files like Oracle, Mysql and Sql Server database, can be adopted in the data of different types storehouse.Remove to visit different sql configuration files according to the data of different types storehouse, resolve to be loaded in the sql buffer memory and go.After the loading this document information is removed from the sql configuration file.Because buffer area is not once to create completion, but in system's implementation, progressively upgrade, and can guarantee that the content in the buffer memory all was used, and obsolete content can not occur and also continue to be retained in the buffer memory, improve cache hit rate.
SQL script dynamic loading method based on ibatis provided by the invention; Support to multi-data source is relatively more friendly; Only need identical a configuration file just can support the visit of multi-data source, and can load corresponding sql file according to current type of database.As: user_MySQL.xml and user_Oracle.xml when the data designated source is MySQL, just load this database file of user_MySQL.xml automatically.When system needs the switch data storehouse, only need to increase the corresponding sql file of other databases and get final product, other database accesss all need not to do change.
Though the present invention discloses as above with preferred embodiment; Right its is not that any those skilled in the art are not breaking away from the spirit and scope of the present invention in order to qualification the present invention; When can doing a little modification and perfect, so protection scope of the present invention is when being as the criterion with what claims defined.

Claims (5)

1. the SQL script dynamic loading method based on ibatis is characterized in that, comprises the steps:
A) a plurality of independently sql configuration files of configuration, the unified buffer area that all sql configuration files are set;
B) script calls side goes to earlier the buffer area the inside to read sql script configuration information, if exist when searching sql information; Start-up routine loads corresponding sql configuration file automatically to buffer area; Otherwise it is unusual to dish out, and prompting makes mistakes, and searches the sql configuration file renewal buffer area of coupling;
C) after the loading this document information is removed from the sql configuration file;
D) from buffer area, read corresponding sql script information at last and return to called side.
2. the SQL script dynamic loading method based on ibatis as claimed in claim 1 is characterized in that, said step b) adopts the method for traversal to carry out search matched and load corresponding sql configuration file to buffer area.
3. according to claim 1 or claim 2 the SQL script dynamic loading method based on ibatis is characterized in that, said a plurality of different sql configuration files disperse to be arranged in the functional module separately.
4. according to claim 1 or claim 2 the SQL script dynamic loading method based on ibatis is characterized in that, different sql configuration files is adopted in the data of different types storehouse.
5. the SQL script dynamic loading method based on ibatis as claimed in claim 4 is characterized in that said data of different types storehouse comprises Oracle, Mysql and Sql Server database.
CN2011103774123A 2011-11-24 2011-11-24 Ibatis-based SQL script dynamic loading method Pending CN102521274A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011103774123A CN102521274A (en) 2011-11-24 2011-11-24 Ibatis-based SQL script dynamic loading method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011103774123A CN102521274A (en) 2011-11-24 2011-11-24 Ibatis-based SQL script dynamic loading method

Publications (1)

Publication Number Publication Date
CN102521274A true CN102521274A (en) 2012-06-27

Family

ID=46292195

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011103774123A Pending CN102521274A (en) 2011-11-24 2011-11-24 Ibatis-based SQL script dynamic loading method

Country Status (1)

Country Link
CN (1) CN102521274A (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102968306A (en) * 2012-11-29 2013-03-13 广东全通教育股份有限公司 Method and system for automatically generating code based on data model drive
CN103559063A (en) * 2013-11-14 2014-02-05 金蝶软件(中国)有限公司 Update method and update system of application, application system and parameter configuration system
CN103927338A (en) * 2014-03-26 2014-07-16 网神信息技术(北京)股份有限公司 Log information storage processing method and log information storage processing device
CN104317964A (en) * 2014-11-14 2015-01-28 中国建设银行股份有限公司 Object-relational mapping method and system based on iBatis
CN104679903A (en) * 2015-03-20 2015-06-03 亚信科技(南京)有限公司 Method and device for operating data sheets
CN105138326A (en) * 2015-08-11 2015-12-09 北京思特奇信息技术股份有限公司 Method and system for achieving structured query language (sql) dynamic configuration based on ibatis
CN106020847A (en) * 2016-06-06 2016-10-12 北京京东尚科信息技术有限公司 Method and device for configuring SQL for persistent layer development framework
CN108304201A (en) * 2017-09-14 2018-07-20 腾讯科技(深圳)有限公司 Object updating method, device and equipment
CN110083650A (en) * 2019-04-25 2019-08-02 中电科嘉兴新型智慧城市科技发展有限公司 A kind of data-query interfaces automatic generation method and system based on metadata self-discovery
CN111381860A (en) * 2020-04-02 2020-07-07 众能联合数字技术有限公司 Quick maintenance framework and method for database SQL script
CN114595199A (en) * 2022-05-10 2022-06-07 太平金融科技服务(上海)有限公司 File analysis method and device, computer equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751260A (en) * 2009-12-23 2010-06-23 卡斯柯信号有限公司 Business object persistence processing method based on dynamic labels

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751260A (en) * 2009-12-23 2010-06-23 卡斯柯信号有限公司 Business object persistence processing method based on dynamic labels

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张卫争: "《Struts框架下Web应用系统的开发与研究》", 《中国优秀硕士学位论文全文数据库》, no. 10, 15 October 2008 (2008-10-15), pages 1 - 55 *

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102968306B (en) * 2012-11-29 2016-01-20 广东全通教育股份有限公司 A kind of code automatic generation method based on data model driving and system
CN102968306A (en) * 2012-11-29 2013-03-13 广东全通教育股份有限公司 Method and system for automatically generating code based on data model drive
CN103559063A (en) * 2013-11-14 2014-02-05 金蝶软件(中国)有限公司 Update method and update system of application, application system and parameter configuration system
CN103927338A (en) * 2014-03-26 2014-07-16 网神信息技术(北京)股份有限公司 Log information storage processing method and log information storage processing device
CN104317964A (en) * 2014-11-14 2015-01-28 中国建设银行股份有限公司 Object-relational mapping method and system based on iBatis
CN104679903A (en) * 2015-03-20 2015-06-03 亚信科技(南京)有限公司 Method and device for operating data sheets
CN104679903B (en) * 2015-03-20 2018-02-13 亚信科技(南京)有限公司 The operating method and device of a kind of tables of data
CN105138326A (en) * 2015-08-11 2015-12-09 北京思特奇信息技术股份有限公司 Method and system for achieving structured query language (sql) dynamic configuration based on ibatis
CN105138326B (en) * 2015-08-11 2019-03-22 北京思特奇信息技术股份有限公司 A kind of method and system for realizing sql dynamic configuration based on ibatis
CN106020847A (en) * 2016-06-06 2016-10-12 北京京东尚科信息技术有限公司 Method and device for configuring SQL for persistent layer development framework
CN108304201A (en) * 2017-09-14 2018-07-20 腾讯科技(深圳)有限公司 Object updating method, device and equipment
CN110083650A (en) * 2019-04-25 2019-08-02 中电科嘉兴新型智慧城市科技发展有限公司 A kind of data-query interfaces automatic generation method and system based on metadata self-discovery
CN111381860A (en) * 2020-04-02 2020-07-07 众能联合数字技术有限公司 Quick maintenance framework and method for database SQL script
CN114595199A (en) * 2022-05-10 2022-06-07 太平金融科技服务(上海)有限公司 File analysis method and device, computer equipment and storage medium
CN114595199B (en) * 2022-05-10 2022-09-02 太平金融科技服务(上海)有限公司 File analysis method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN102521274A (en) Ibatis-based SQL script dynamic loading method
CN107402992B (en) Distributed NewSQL database system and full-text retrieval establishing method
US9483506B2 (en) History preserving data pipeline
US9830342B2 (en) Optimizing database deduplication
CN111124474B (en) API version control method and device
CN102541757B (en) Write cache method, cache synchronization method and device
US20140297592A1 (en) Computer-readable medium storing program and version control method
CN105359099A (en) Index update pipeline
CN104021145A (en) Mixed service concurrent access method and device
US20170097970A1 (en) Task-execution in a dbms using stored procedures
US20230117105A1 (en) On-demand loading of dynamic scripting language code for reduced memory usage
CN111324610A (en) Data synchronization method and device
CN102314375A (en) Heterogeneous database storage unified interface and database access method
US9384202B1 (en) Gateway module to access different types of databases
CN101765831A (en) Database contradiction solution method
CN102043653A (en) Cache system and methods for modifying cache configuration and operating and querying cache data
CN101042703A (en) Method for managing metadata of file system using dbms
US20120323851A1 (en) Distributed, asynchronous and fault-tolerant storage system
CN103106286A (en) Method and device for managing metadata
US20130198218A1 (en) Database Table Partitioning Allowing Overlaps Used in Full Text Query
CN109885642B (en) Hierarchical storage method and device for full-text retrieval
US10268776B1 (en) Graph store built on a distributed hash table
CN103268291B (en) The method of persistence index metadata is postponed in flash-memory storage system
CN102314506A (en) Distributed buffer management method based on dynamic index
CN101174222A (en) Data version upgrading method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20120627