CN103116622A - Sequential value generating method and device for Ibatis scheme - Google Patents

Sequential value generating method and device for Ibatis scheme Download PDF

Info

Publication number
CN103116622A
CN103116622A CN2013100347879A CN201310034787A CN103116622A CN 103116622 A CN103116622 A CN 103116622A CN 2013100347879 A CN2013100347879 A CN 2013100347879A CN 201310034787 A CN201310034787 A CN 201310034787A CN 103116622 A CN103116622 A CN 103116622A
Authority
CN
China
Prior art keywords
classkey
node
sql
statement
root node
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
CN2013100347879A
Other languages
Chinese (zh)
Other versions
CN103116622B (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.)
SHENZHEN LAN-YOU TECHNOLOG Co Ltd
Original Assignee
SHENZHEN LAN-YOU TECHNOLOG 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 SHENZHEN LAN-YOU TECHNOLOG Co Ltd filed Critical SHENZHEN LAN-YOU TECHNOLOG Co Ltd
Priority to CN201310034787.9A priority Critical patent/CN103116622B/en
Publication of CN103116622A publication Critical patent/CN103116622A/en
Application granted granted Critical
Publication of CN103116622B publication Critical patent/CN103116622B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a sequential value generating method and a device. The method comprises that a structured query language execution object is searched corresponding to a key identifier through the key identifier which is inputted by a user; when the attributive object of classKey in the structure query language statement execution object is non-null, predefined sequence generator object is dynamically structured, wherein the attributive object of the classKey is a predefined corresponding attributive object by means of java class method classKey nodes; and a sequential value is generated according to a predefined sequence generating method corresponding to the sequence generator. The generating method for Ibatis major key sequential value can be expanded to some self-defined java class method and is not limited in a database approach.

Description

A kind of sequence value generation method and device for the Ibatis scheme
Technical field
The present invention relates to computer realm, relate in particular to a kind of sequence value generation method and device for the Ibatis scheme.
Background technology
Ibatis one word derives from the combination of " internet " and " abatis ", is an open source code project, lays particular emphasis at first the exploitation of cipher software, be now one based on the Persistence Layer Framework of Java.The center of effort of Ibatis is POJO(Plain Old Java Objects, common Java object) with SQL(Structured Query Language, Structured Query Language (SQL)) between mapping relations.That is to say, Ibatis can't carry out for the programmer generates SQL automatically in the runtime, and concrete SQL needs the programmer to write, then by Map Profile, and the parameter that SQL is required, and the result field that returns is mapped to appointment POJO.
When persistent layer uses the Ibatis save data to advance database, usually can be with some sequential values as tables of data major key or data unique identification.In the Ibatis framework, mainly complete sequential value by the selectKey child node and generate and return, use but selectKey is defined as only being confined to the database SQL action statement, and can not pass through java class formation sequence value.
Summary of the invention
Embodiment of the present invention technical matters to be solved is, a kind of sequence value generation method and device for the Ibatis scheme is provided, and can expand and utilize non-data base method to become sequential value next life.
In order to solve the problems of the technologies described above, the embodiment of the present invention provides a kind of sequence value generation method for the Ibatis scheme, comprising:
Search the structured query sentence execution object corresponding with described key name sign by the key name sign that the user inputs;
When the classKey attributes object in described Structured Query Language (SQL) statement execution object is non-NULL, the predefined sequence generator object of dynamic construction, wherein said classKey attributes object are predefined attributes object corresponding to classKey node of utilizing the java class methods;
According to the predefined sequence generating method formation sequence value corresponding with described sequence generator.
Wherein, described method is further comprising the steps of:
The described key name sign of inputting by the user detects and loads total configuration file before searching the step of the Structured Query Language (SQL) statement execution object corresponding with described key name sign;
Read and resolve predefined tables of data operation file from described total configuration file, described tables of data operation file comprises the configuration of classKey node;
Resolve the root node in described tables of data operation file, when described root node is the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carry out object;
Utilization<key name sign, object carried out in the Structured Query Language (SQL) statement〉list structure of combination is stored described tables of data operation file.
Wherein, described method also comprises:
When described root node is not the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carry out object, and judge that whether child node is arranged in described root node is the classKey node;
If it is the classKey node that child node is arranged in described root node, resolves respectively described classKey node and the classKey execution object that described classKey node is corresponding and be injected in the Structured Query Language (SQL) statement execution object of described root node;
Utilization<key name sign, object carried out in the Structured Query Language (SQL) statement〉list structure of combination is stored described tables of data operation file.
Wherein, the described classKey node of described parsing and classKey that described classKey node is corresponding carry out the step that Structured Query Language (SQL) statement that object is injected into described root node carries out in object and specifically comprise:
Resolve described classKey node, obtain the analysis result object;
Described analysis result object is built be converted into the execution object;
The Structured Query Language (SQL) statement that described execution object is injected into described root node is carried out in object.
Wherein, the attribute of described ClassKey child node comprises rreturn value type resultClass, Property Name keyProperty, type type, sequence generator java class full name className and sequence generating method methodName.
Correspondingly, the present invention also provides a kind of sequential value generating apparatus for the Ibatis scheme, comprising:
Search module, the key name sign that is used for inputting by the user is searched the structured query sentence corresponding with described key name sign and is carried out object;
Sequence generator builds module, be used for when the classKey attributes object of described Structured Query Language (SQL) statement execution object is non-NULL, the predefined sequence generator object of dynamic construction, wherein said classKey attributes object are predefined attributes object corresponding to classKey node of utilizing the java class methods;
The sequential value generation module is used for according to the predefined sequence generating method formation sequence value corresponding with described sequence generator.
Wherein, described sequential value generating apparatus also comprises:
The configuration file load-on module, for detection of and load total configuration file;
The configuration file parsing module is used for reading and resolve predefined tables of data operation file from described total configuration file, and described tables of data operation file comprises the configuration of classKey node;
The root node parsing module for the root node of resolving described tables of data operation file, when described root node is the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carries out object;
Memory module is used for utilization<key name sign, and object carried out in the Structured Query Language (SQL) statement〉list structure of combination is stored described tables of data operation file.
Wherein, described root node parsing module also is used for when described root node is not the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carries out object, and judge that whether child node is arranged in described root node is the classKey node;
Described sequential value generating apparatus also comprises:
Injection module, be used for when described root node has child node to be the classKey node, resolve respectively described classKey node and the classKey that described classKey node is corresponding and carry out in the Structured Query Language (SQL) statement execution object that object is injected into described root node.
Wherein, described injection module comprises:
The classKey parsing module is used for resolving described classKey node, obtains the analysis result object;
ClassKey carries out object and builds module, is used for described analysis result object is built being converted into the execution object;
ClassKey carries out the object injection module, is used for described execution object is injected into the Structured Query Language (SQL) statement execution object of described insert node.
Wherein, the attribute of described ClassKey child node comprises rreturn value type resultClass, Property Name keyProperty, type type, sequence generator java class full name className and sequence generating method methodName.
Implement the embodiment of the present invention, has following beneficial effect: by the dynamic construction sequence generator, utilize predefined sequence generating method to obtain sequential value, Ibatis major key sequence value generation method can be expanded to self-defining certain java class method (being self-defining sequence generator), and no longer only limit to database mode.
Description of drawings
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, the below will do to introduce simply to the accompanying drawing of required use in embodiment or description of the Prior Art, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the first embodiment process flow diagram of the sequence value generation method for the Ibatis scheme provided by the invention;
Fig. 2 uses sequence value generation method shown in Figure 1 to be configured the operation steps process flow diagram of document analysis process;
Fig. 3 is the second embodiment process flow diagram of the sequence value generation method for the Ibatis scheme provided by the invention;
Fig. 4 uses sequence value generation method shown in Figure 3 to be configured the operation steps process flow diagram of document analysis process;
Fig. 5 is the first example structure schematic diagram of the sequential value generating apparatus for the Ibatis scheme provided by the invention;
Fig. 6 is the second example structure schematic diagram of the sequential value generating apparatus for the Ibatis scheme provided by the invention;
Fig. 7 is the 3rd example structure schematic diagram of the sequential value generating apparatus for the Ibatis scheme provided by the invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Based on the embodiment in the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that obtains under the creative work prerequisite.
Seeing also Fig. 1, is the first embodiment process flow diagram of the sequence value generation method for the Ibatis scheme provided by the invention, comprising:
Step S100, the key name sign of inputting by the user are searched the SQL statement execution object corresponding with described key name sign.Wherein, the key name sign can include but not limited to insert, update, delete, procedure, statement, classKey and selectKey.Particularly, when software program or system in operational process, thereby in the time of need to calling certain tables of data operation file and carry out associative operation, can search the SQL statement execution object corresponding with this key name sign by the key name sign that the user input.
Step S101, when described Structured Query Language (SQL) statement is carried out classKey attributes object in object and is non-NULL, the predefined sequence generator object of dynamic construction, wherein said classKey attributes object are predefined attributes object corresponding to classKey node of utilizing the java class methods.Particularly, can sequence generator object predefined according to Java reflex mechanism dynamic construction, also can utilize the predefined sequence generator object of IOC container (for example spring bean) agent object injection mode dynamic construction.
Step S102, the basis predefined sequence generating method corresponding with described sequence generator obtain sequential value.
Sequence value generation method provided by the invention, by the dynamic construction sequence generator, utilize predefined sequence generating method to obtain sequential value, Ibatis major key sequence value generation method can be expanded to self-defining certain java class method (being self-defining sequence generator), and no longer only limit to database mode.
Particularly, in embodiment shown in Figure 1, if classKey is the key name sign of input, so after the formation sequence value, can be directly this sequential value be returned to SQL statement as rreturn value and carry out classKey attributes object in object, then carry out this SQL statement, thereby complete operation corresponding to key name sign.If classKey is not the key name sign of input, so after the formation sequence value, first this sequential value is returned to SQL statement as rreturn value and carry out classKey attributes object in object, then statement (for example insert statement) corresponding to key name sign of carrying out in object according to SQL statement builds JDBC(Java Data Base Connectivity, the java database connects) the execution object, carry out the parameter assignment according to the parameter of user's input, then carry out corresponding SQL statement (for example insert statement), thereby can complete operation corresponding to key name sign.
In addition, if the classKey attributes object that SQL statement is carried out in object is empty, the respective statement structure JDBC that directly carries out in object according to SQL statement carries out object, carries out the parameter assignment according to the parameter of user's input, then carries out this statement.
Before the process of completing formation sequence value shown in Figure 1, when software program or system's startup, often need first to load total configuration file, parse the execution object, and store, wherein total configuration file is generally XML(Extensible Markup Language, extend markup language) form.Seeing also Fig. 2, is to use sequence value generation method shown in Figure 1 to be configured the operation steps process flow diagram of document analysis process, comprising:
Step S200, detection also load total configuration file.Particularly, when software program or system's startup, detect and load Ibatis and always configure the XML formatted file.
Step S201, read and resolve predefined tables of data operation file from total configuration file, this tables of data operation file comprises the configuration of classKey node.Particularly, the total configuration file of traversal Ibatis, circulation is read predefined tables of data operation file SQLmap and is resolved, and has wherein increased the configuration of classKey node in tables of data operation file SQLmap newly.More specifically, except newly-increased classKey node configuration, also pre-defined class ClassKeySource and class ClassKeyStatement in tables of data operation file SQLmap.Wherein, ClassKeySource is used for creating ClassKey analysis result object, and ClassKeyStatement is used for carrying out object by classKey analysis result Object Creation ClassKey.For example, the attribute of ClassKey node comprises rreturn value type resultClass, Property Name keyProperty, type type, sequence generator java class full name className and sequence generating method methodName.Alternatively, the attribute of classKey node can also comprise sequence generating method input parameter type paramTypes and sequence generating method input parameter value args, wherein paramTypes is corresponding with the args coupling, and paramTypes can comprise any basic data type and the character string of supporting Java.In addition, the attribute of ClassKeySource can comprise sequence generator java class full name className and sequence generating method methodName, alternatively, can also comprise sequence generating method input parameter type paramTypes and sequence generating method input parameter value args.The attribute of ClasssKeystatement can comprise ClassKeySource.
Step S202, resolve the root node in this tables of data operation file, judge whether root node is the classKey node.
If judgment result is that of step S202 be, execution in step S203.Object carried out in step S203, the Structured Query Language (SQL) statement that obtains described root node.
Step S204, utilization<key name sign, object carried out in the Structured Query Language (SQL) statement〉list structure of combination is stored described tables of data operation file.Like this, when execution graph 1 described method, just can search according to key name sign and resolve the SQL statement that obtains and carried out object.
If the determination result is NO for step S202, execution in step S205.Step S205, the Structured Query Language (SQL) statement that obtains described root node are carried out object, and are judged that whether child node is arranged in described root node is the classKey node.For example, if root node is the insert node, can resolve the insert node in individual data table handling file, carry out object with the SQL statement that obtains the insert node, the SQL statement under this node is mainly used in data and preserves operation.
If judgment result is that of step S205 be, execution in step S206.Step S206, resolve described classKey node and classKey that described classKey node is corresponding respectively and carry out the Structured Query Language (SQL) statement that object is injected into described root node and carry out in object.Particularly, in the Ibatis framework, SQLmap configuration class MappedStatementConfig definition comprises the newly-increased injection processing to ClassKeyStatement, therefore, step S202 can comprise: when having the configuration of classKey node in this root node, resolve this classKey node, obtain the analysis result object; The analysis result object is built be converted into the execution object; The SQL statement that this execution object is injected into this root node is carried out in object.Next execution in step S204.
If the determination result is NO for step S205, execution in step S204.
Seeing also Fig. 3, is the second embodiment process flow diagram of the sequence value generation method for the Ibatis scheme provided by the invention, comprising:
Step S300, the key name sign of inputting by the user are searched the SQL statement execution object corresponding with described key name sign.
Step S301, judge that this SQL statement carries out the selectKey attributes object non-NULL whether in object.
If judgment result is that of step S301 be, execution in step S302.SQL statement built-in in step S302, execution selectKey attributes object is to obtain sequential value.
If the determination result is NO for step S301, execution in step S303.Step S303, judge that this SQL statement carries out the classKey attributes object non-NULL whether in object.
If judgment result is that of step S303 be, execution in step S304.Step S304, the predefined sequence generator object of dynamic construction.
Step S305, the basis predefined sequence generating method corresponding with described sequence generator obtain sequential value.
If the determination result is NO for step S303, this method flow process finishes.
Generally, same attribute-name keyProperty only corresponding to selectKey attributes object and classKey attributes object one of them.When selectKey attributes object and classKey attributes object had identical attribute-name keyProperty, ordinary priority was processed the selectKey attributes object.When the attribute-name keyProperty of selectKey attributes object and classKey attributes object not simultaneously, both process simultaneously.In this way, can expand Ibatis framework use scenes, compatible supporting database and non-database mode are produced the method for sequential value.
In resolving, same attribute-name keyProperty only corresponding to selectKey node and classKey node one of them.When selectKey node and classKey node had identical attribute-name keyProperty, ordinary priority was processed the selectKey node.When the attribute-name keyProperty of selectKey node and classKey node not simultaneously, both process simultaneously.。
Seeing also Fig. 4, is to use sequence value generation method shown in Figure 3 to be configured the operation steps process flow diagram of document analysis process, and take root node as the insert node as example, the method comprises:
Step S400, detection also load total configuration file.Particularly, when software program or system's startup, detect and load Ibatis and always configure the XML formatted file.
Step S401, read and resolve predefined tables of data operation file from total configuration file, this tables of data operation file comprises the configuration of classKey node.
Step S402, resolve the insert node in this tables of data operation file, obtain the SQL statement of this insert node and carry out object.
Step S403, judge whether there is selectKey child node configuration in this insert node.
If judgment result is that of step S403 be, execution in step S404.Step S404, resolve this selectKey child node and selectKey carried out the SQL statement that object is injected into this insert node carry out in object.
If the determination result is NO for step S403, execution in step S405.Step S405, judge whether there is classKey child node configuration in this insert node.
If judgment result is that of step S405 be, execution in step S406.Step S406, resolve this classKey child node and classKey carried out the SQL statement that object is injected into this insert node carry out in object.
Step S407, utilization<key name sign, SQL statement is carried out object〉list structure of combination is stored described tables of data operation file.
If the determination result is NO for step S405, jump to step S407.
Seeing also Fig. 5, is the first example structure schematic diagram of the sequential value generating apparatus 500 for the Ibatis scheme provided by the invention, comprising:
Search module 510, the key name sign that is used for inputting by the user is searched the SQL statement corresponding with described key name sign and is carried out object.Wherein, the key name sign can include but not limited to insert, update, delete, procedure, statement, classKey and selectKey.Particularly, when software program or system in operational process, thereby in the time of need to calling certain tables of data operation file and carry out associative operation, can search the SQL statement execution object corresponding with this key name sign by the key name sign that the user input.
Sequence generator builds module 520, be used for when the classKey attributes object of described Structured Query Language (SQL) statement execution object is non-NULL, the predefined sequence generator object of dynamic construction, wherein said classKey attributes object are predefined attributes object corresponding to classKey node of utilizing the java class methods.Particularly, can sequence generator object predefined according to Java reflex mechanism dynamic construction, also can utilize the predefined sequence generator object of IOC container (for example spring bean) agent object injection mode dynamic construction.
Sequential value generation module 530 is used for obtaining sequential value according to the predefined sequence generating method corresponding with described sequence generator.
Sequential value generating apparatus provided by the invention, by the dynamic construction sequence generator, utilize predefined sequence generating method to obtain sequential value, Ibatis major key sequence value generation method can be expanded to self-defining certain java class method (being self-defining sequence generator), and no longer only limit to database mode.
Particularly, in embodiment shown in Figure 5, if classKey is the key name sign of input, after sequential value generation module 530 formation sequence values, can be directly this sequential value be returned to SQL statement as rreturn value and carry out classKey attributes object in object, so that external program is carried out this SQL statement, complete operation corresponding to key name sign.if classKey is not the key name sign of input, after sequential value generation module 530 formation sequence values, first this sequential value is returned to SQL statement as rreturn value and carry out classKey attributes object in object, then statement (for example insert statement) corresponding to key name sign of carrying out in object according to SQL statement builds JDBC(Java Data Base Connectivity, the java database connects) the execution object, carry out the parameter assignment according to the parameter of user's input, then carry out corresponding SQL statement (for example insert statement), thereby can complete operation corresponding to key name sign.
In addition, if the classKey attributes object that SQL statement is carried out in object is empty, the respective statement structure JDBC that directly carries out in object according to SQL statement carries out object, carries out the parameter assignment according to the parameter of user's input, then carries out this statement.
Before the process of completing the formation sequence value, when software program or system's startup, often need first to load total configuration file, parse the execution object, and store, wherein total configuration file is generally the XML form.Seeing also Fig. 6, is the structural representation of the sequential value generating apparatus 600 for the Ibatis scheme provided by the invention.Sequential value generating apparatus 600 comprises searches module 610, sequence generator structure module 620, sequential value generation module 630, configuration file load-on module 640, configuration file parsing module 650, insert execution object acquisition module 660, classKey injection module 670 and memory module 680.Wherein, search module 610, sequence generator build module 620, sequential value generation module 630 respectively with search that module 510, sequence generator build module 520, sequential value generation module 530 is similar.
Configuration file load-on module 640, for detection of and load total configuration file.Particularly, when software program or system's startup, configuration file load-on module 640 detects and loads Ibatis and always configures the XML formatted file.
Configuration file parsing module 650 is used for reading and resolve predefined tables of data operation file from total configuration file, and this tables of data operation file comprises the configuration of classKey node.Particularly, the configuration file parsing module 650 total configuration files of traversal Ibatis, circulation is read predefined tables of data operation file SQLmap and is resolved, and has wherein increased the configuration of classKey node in tables of data operation file SQLmap newly.More specifically, except newly-increased classKey node configuration, also pre-defined class ClassKeySource and class ClassKeyStatement in tables of data operation file SQLmap.Wherein, ClassKeySource is used for creating ClassKey analysis result object, and ClassKeyStatement is used for carrying out object by classKey analysis result Object Creation ClassKey.For example, the attribute of ClassKey node comprises rreturn value type resultClass, Property Name keyProperty, type type, sequence generator java class full name className and sequence generating method methodName.Alternatively, the attribute of classKey node can also comprise sequence generating method input parameter type paramTypes and sequence generating method input parameter value args, wherein paramTypes is corresponding with the args coupling, and paramTypes can comprise any basic data type and the character string of supporting Java.In addition, the attribute of ClassKeySource can comprise sequence generator java class full name className and sequence generating method methodName, alternatively, can also comprise sequence generating method input parameter type paramTypes and sequence generating method input parameter value args.The attribute of ClasssKeystatement can comprise ClassKeySource.
Root node parsing module 660 is used for resolving the root node of this tables of data operation file, and judges whether root node is the classKey node; If root node is the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carry out object; If root node is not the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carry out object, and judge that whether child node is arranged in described root node is the classKey node.
Injection module 670 is used for resolving respectively described classKey node and the classKey that described classKey node is corresponding carries out the Structured Query Language (SQL) statement execution object that object is injected into described root node.Particularly, in the Ibatis framework, SQLmap configuration class MappedStatementConfig definition comprises the newly-increased injection processing to ClassKeyStatement, therefore, injection module 670 can comprise: the classKey parsing module, be used for when there is the configuration of classKey child node in this root node, resolve this classKey child node, obtain the analysis result object; ClassKey carries out object and builds module, is used for the analysis result object is built being converted into the execution object; ClassKey carries out the object injection module, is used for carrying out the SQL statement execution object that object is injected into this root node.
Memory module 680 is used for utilization<key name sign, and SQL statement is carried out object〉list structure of combination is stored described tables of data operation file.Like this, searching module 610 just can search according to key name sign and resolve the SQL statement that obtains and carried out object.
Seeing also Fig. 7, is the structural representation of the sequential value generating apparatus 700 for the Ibatis scheme provided by the invention, take root node as the insert node as example.Sequential value generating apparatus 700 comprises searches module 710, sequence generator structure module 720, sequential value generation module 730, configuration file load-on module 740, configuration file parsing module 750, root node parsing module 760, injection module 770, memory module 780 and selectKey processing module 790, selectKey injection module 795.Wherein, searching module 710, sequence generator builds module 720, sequential value generation module 730, configuration file load-on module 740, configuration file parsing module 750, root node parsing module 760, injection module 770, memory module 780 to build module 620, sequential value generation module 630, configuration file load-on module 640, configuration file parsing module 650, root node parsing module 660, injection module 670, memory module 680 similar with searching module 610, sequence generator respectively.
SelectKey processing module 790 is used for searching the SQL statement that obtains when carrying out the selectKey attributes object of object and being non-NULL when searching module 710, carries out SQL statement built-in in the selectKey attributes object with the acquisition sequential value.
SelectKey injection module 795, be used for when there is the configuration of selectKey child node in insert node that the root node parsing module parses, resolve this selectKey child node and selectKey is carried out in the SQL statement execution object that object is injected into this insert node.
Generally, same attribute-name keyProperty only corresponding to selectKey attributes object (or selectKey node) and classKey attributes object (or classKey node) one of them.When having identical attribute-name keyProperty, ordinary priority is processed selectKey attributes object (or selectKey node) when selectKey attributes object (or selectKey node) and classKey attributes object (or classKey node).When the attribute-name keyProperty of selectKey attributes object (or selectKey node) and classKey attributes object (or classKey node) not simultaneously, both process simultaneously.In this way, can expand Ibatis framework use scenes, compatible supporting database and non-database mode are produced the method for sequential value.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in above-described embodiment method, to come the relevant hardware of instruction to complete by computer program, described program can be stored in a computer read/write memory medium, this program can comprise the flow process as the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (RandomAccess Memory, RAM) etc.
Above disclosed is only a kind of preferred embodiment of the present invention, certainly can not limit with this interest field of the present invention, one of ordinary skill in the art will appreciate that all or part of flow process that realizes above-described embodiment, and according to the equivalent variations that claim of the present invention is done, still belong to the scope that invention is contained.

Claims (10)

1. a sequence value generation method that is used for the Ibatis scheme, is characterized in that, comprising:
Search the structured query sentence execution object corresponding with described key name sign by the key name sign that the user inputs;
When the classKey attributes object in described Structured Query Language (SQL) statement execution object is non-NULL, the predefined sequence generator object of dynamic construction, wherein said classKey attributes object are predefined attributes object corresponding to classKey node of utilizing the java class methods;
According to the predefined sequence generating method formation sequence value corresponding with described sequence generator.
2. the sequence value generation method for the Ibatis scheme as claimed in claim 1, is characterized in that, described method is further comprising the steps of:
Search the step of the Structured Query Language (SQL) statement execution object corresponding with described key name sign in the described key name sign of inputting by the user before, detect and load total configuration file;
Read and resolve predefined tables of data operation file from described total configuration file, described tables of data operation file comprises the configuration of classKey node;
Resolve the root node in described tables of data operation file, when described root node is the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carry out object;
Utilization<key name sign, object carried out in the Structured Query Language (SQL) statement〉list structure of combination is stored described tables of data operation file.
3. the sequence value generation method for the Ibatis scheme as claimed in claim 2, is characterized in that, described method also comprises:
When described root node is not the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carry out object, and judge that whether child node is arranged in described root node is the classKey node;
If it is the classKey node that child node is arranged in described root node, resolves respectively described classKey node and the classKey execution object that described classKey node is corresponding and be injected in the Structured Query Language (SQL) statement execution object of described root node;
Utilization<key name sign, object carried out in the Structured Query Language (SQL) statement〉list structure of combination is stored described tables of data operation file.
4. the sequence value generation method for the Ibatis scheme as claimed in claim 3, it is characterized in that, the described classKey node of described parsing and classKey that described classKey node is corresponding carry out the step that Structured Query Language (SQL) statement that object is injected into described root node carries out in object and specifically comprise:
Resolve described classKey node, obtain the analysis result object;
Described analysis result object is built be converted into the execution object;
The Structured Query Language (SQL) statement that described execution object is injected into described root node is carried out in object.
5. the sequence value generation method for the Ibatis scheme as described in any one in claim 1-4, it is characterized in that, the attribute of described ClassKey child node comprises rreturn value type resultClass, Property Name keyProperty, type type, sequence generator java class full name className and sequence generating method methodName.
6. a sequential value generating apparatus that is used for the Ibatis scheme, is characterized in that, comprising:
Search module, the key name sign that is used for inputting by the user is searched the structured query sentence corresponding with described key name sign and is carried out object;
Sequence generator builds module, be used for when the classKey attributes object of described Structured Query Language (SQL) statement execution object is non-NULL, the predefined sequence generator object of dynamic construction, wherein said classKey attributes object are predefined attributes object corresponding to classKey node of utilizing the java class methods;
The sequential value generation module is used for according to the predefined sequence generating method formation sequence value corresponding with described sequence generator.
7. the sequential value generating apparatus for the Ibatis scheme as claimed in claim 6, is characterized in that, described sequential value generating apparatus also comprises:
The configuration file load-on module, for detection of and load total configuration file;
The configuration file parsing module is used for reading and resolve predefined tables of data operation file from described total configuration file, and described tables of data operation file comprises the configuration of classKey node;
The root node parsing module for the root node of resolving described tables of data operation file, when described root node is the classKey node, obtains the Structured Query Language (SQL) statement of described root node and carries out object;
Memory module is used for utilization<key name sign, and object carried out in the Structured Query Language (SQL) statement〉list structure of combination is stored described tables of data operation file.
8. the sequential value generating apparatus for the Ibatis scheme as claimed in claim 7, it is characterized in that, described root node parsing module also is used for when described root node is not the classKey node, obtain the Structured Query Language (SQL) statement of described root node and carry out object, and judge that whether child node is arranged in described root node is the classKey node;
Described sequential value generating apparatus also comprises:
Injection module, be used for when described root node has child node to be the classKey node, resolve respectively described classKey node and the classKey that described classKey node is corresponding and carry out in the Structured Query Language (SQL) statement execution object that object is injected into described root node.
9. the sequential value generating apparatus for the Ibatis scheme as claimed in claim 8, is characterized in that, described injection module comprises:
The classKey parsing module is used for resolving described classKey node, obtains the analysis result object;
ClassKey carries out object and builds module, is used for described analysis result object is built being converted into the execution object;
ClassKey carries out the object injection module, is used for described execution object is injected into the Structured Query Language (SQL) statement execution object of described insert node.
10. the sequential value generating apparatus for the Ibatis scheme as described in any one in claim 6-9, it is characterized in that, the attribute of described ClassKey child node comprises rreturn value type resultClass, Property Name keyProperty, type type, sequence generator java class full name className and sequence generating method methodName.
CN201310034787.9A 2013-01-30 2013-01-30 A kind of sequence value generation method for Ibatis scheme and device Active CN103116622B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310034787.9A CN103116622B (en) 2013-01-30 2013-01-30 A kind of sequence value generation method for Ibatis scheme and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310034787.9A CN103116622B (en) 2013-01-30 2013-01-30 A kind of sequence value generation method for Ibatis scheme and device

Publications (2)

Publication Number Publication Date
CN103116622A true CN103116622A (en) 2013-05-22
CN103116622B CN103116622B (en) 2016-03-09

Family

ID=48414995

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310034787.9A Active CN103116622B (en) 2013-01-30 2013-01-30 A kind of sequence value generation method for Ibatis scheme and device

Country Status (1)

Country Link
CN (1) CN103116622B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766557A (en) * 2017-11-03 2018-03-06 金蝶软件(中国)有限公司 The generation method and relevant apparatus of a kind of database sequence
WO2020232569A1 (en) * 2019-05-17 2020-11-26 环球雅途集团有限公司 Database access layer representation method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030212984A1 (en) * 2000-12-08 2003-11-13 Fujitsu Limited Sequence analysis method and apparatus
CN101004683A (en) * 2007-01-31 2007-07-25 华为技术有限公司 Method and device for accessing database

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030212984A1 (en) * 2000-12-08 2003-11-13 Fujitsu Limited Sequence analysis method and apparatus
CN101004683A (en) * 2007-01-31 2007-07-25 华为技术有限公司 Method and device for accessing database

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刀光剑影: "ibatis扩展支持主键生成的方法(非数据库方式)", 《CSDN.NET-博客频道》, 29 November 2012 (2012-11-29), pages 1 - 2 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766557A (en) * 2017-11-03 2018-03-06 金蝶软件(中国)有限公司 The generation method and relevant apparatus of a kind of database sequence
WO2020232569A1 (en) * 2019-05-17 2020-11-26 环球雅途集团有限公司 Database access layer representation method and device

Also Published As

Publication number Publication date
CN103116622B (en) 2016-03-09

Similar Documents

Publication Publication Date Title
CN107402992B (en) Distributed NewSQL database system and full-text retrieval establishing method
US20170242667A1 (en) Software development tool using a workflow pattern that describes software applications
CN105022739B (en) The storage method and device of data
EP3014479A2 (en) Omega names: name generation and derivation
Barmpis et al. Comparative analysis of data persistence technologies for large-scale models
EP2513785A1 (en) Method and system of adapting a data model to a user interface component
CN103631601A (en) Code generation method and code generation device
CN107315764B (en) Method and system for updating non-relational database associated data
CN109408493A (en) A kind of moving method and system of data source
US20100192127A1 (en) System and method for a software product manager
US9483508B1 (en) Omega names: name generation and derivation
CN105653716A (en) Database construction method and system based on classification-attribute-value
CN106844369B (en) Objectification SQL sentence construction method and apparatus
CN106951254B (en) Method and device for multiplexing similar service function modules in payment system
CN108037967A (en) A kind of menu loading method and electronic equipment based on more parent-child structures
US20120159515A1 (en) Sharing object representations
US9026989B2 (en) Object extensions using attributes to decouple base classes from derived classes
CN103902565A (en) Method and device for determining data access relation
Kolovos et al. The epsilon pattern language
CN112698819A (en) Method, device and storage medium for designing tree-oriented object programming program
CN105630489B (en) Data processing method and data processing equipment
CN103116622B (en) A kind of sequence value generation method for Ibatis scheme and device
US10885453B2 (en) Calculation device, calculation method, and non-transitory computer-readable recording medium
CN111125216B (en) Method and device for importing data into Phoenix
CN113448942B (en) Database access method, device, equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant