CN106844369A - Objectification SQL statement building method and device - Google Patents

Objectification SQL statement building method and device Download PDF

Info

Publication number
CN106844369A
CN106844369A CN201510882493.0A CN201510882493A CN106844369A CN 106844369 A CN106844369 A CN 106844369A CN 201510882493 A CN201510882493 A CN 201510882493A CN 106844369 A CN106844369 A CN 106844369A
Authority
CN
China
Prior art keywords
sql
object class
preset
level
objectification
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
CN201510882493.0A
Other languages
Chinese (zh)
Other versions
CN106844369B (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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201510882493.0A priority Critical patent/CN106844369B/en
Publication of CN106844369A publication Critical patent/CN106844369A/en
Application granted granted Critical
Publication of CN106844369B publication Critical patent/CN106844369B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2448Query languages for particular applications; for extensibility, e.g. user defined types
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/289Object oriented databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a kind of objectification SQL statement building method and device, solve the problems, such as that existing SQL statement misspelling rate is high.Main technical schemes of the invention are:Response construction objectification sql command, determines the object class template of the first level;Wherein, at least one first preset SQL object classes are included in the object class template of first level;Described at least one first preset SQL object classes are transferred, described at least one first preset SQL object classes are determined;When the corresponding parameter of the described first preset SQL object class is received, determine the object class template of the second level, wherein, a second preset SQL object class is comprised at least in the object class template of second level, the first preset SQL object class with the logical relation of the described second preset SQL object class is determined according to sql like language attribution rule.Present invention is mainly used for the SQL statement of construction standard.

Description

Objectification SQL statement building method and device
Technical field
The present invention relates to areas of information technology, more particularly to a kind of objectification SQL statement building method and Device.
Background technology
With the fast development of information technology, major applications are all more or less to be carried out based on database The storage and management of data.So this process necessarily refers to SQL (Structured Query Language, SQL) operation, but regardless of which type of data access framework of use, As Hibernate (the Object Relation Mapping framework of open source code), iBatis (map branch based on SQL Hold the Persistence Layer Framework of Java and .NET) etc., as long as being related to the SQL treatment of complexity and and performance Related optimization, is necessarily required to the construction of being customized SQL statement.
At present, the construction process of SQL statement is presented in the form of character string, and various language Compiler cannot all capture the misspelling of above-mentioned SQL statement, and the misspelling of SQL statement is always It is unavoidable problem in SQL construction process, there was only program operation after SQL statement makes a mistake When just it can be found that if the more complicated so position fixing process of business is very time-consuming, therefore existing The efficiency for searching sql error sentence is low.
The content of the invention
In view of the above problems, it is proposed that the present invention, above mentioned problem or at least is overcome to provide one kind The construction objectification SQL statement method and device for partly solving the above problems.
To reach above-mentioned purpose, present invention generally provides following technical scheme:
On the one hand, a kind of objectification SQL statement building method, the method be the embodiment of the invention provides Including:
Response construction objectification sql command, determines the object class template of the first level;Wherein, it is described At least one first preset SQL object classes are included in the object class template of the first level;
Described at least one first preset SQL object classes are transferred, determines that described at least one first is preset SQL object class;
When the corresponding parameter of the described first preset SQL object class is received, the right of the second level is determined As class template, wherein, a second preset SQL is comprised at least in the object class template of second level Object class, the first preset SQL object class is root with the logical relation of the described second preset SQL object class Determine according to sql like language attribution rule.
On the other hand, the embodiment of the present invention also provides a kind of objectification SQL statement constructing apparatus, the dress Put including:
Response unit, for responding construction objectification sql command, determines the object class mould of the first level Plate;Wherein, at least one first preset SQL objects are included in the object class template of first level Class;
Transfer unit, for transferring described at least one first preset SQL object classes, it is determined that it is described extremely A few first preset SQL object class;
Determining unit, for when the corresponding parameter of the described first preset SQL object class is received, really The object class template of fixed second level, wherein, comprised at least in the object class template of second level One the second preset SQL object class, the first SQL pairs preset with described second of preset SQL object class As the logical relation of class is determined according to sql like language attribution rule.
By above-mentioned technical proposal, technical scheme provided in an embodiment of the present invention at least has following advantages:
The embodiment of the present invention provides a kind of objectification SQL statement building method and device, and response construction is right As changing sql command, the object class template of the first level is determined;Wherein, the object of first level At least one first preset SQL object classes are included in class template;Transfer described at least one first preset SQL object class, determines described at least one first preset SQL object classes;When receiving described first During the corresponding parameter of preset SQL object class, the object class template of the second level is determined, wherein, it is described A second preset SQL object class is comprised at least in the object class template of the second level, first is preset SQL object class is according to sql like language attribute with the logical relation of the described second preset SQL object class What rule determined.All it is compared with being represented in the form of character string with the SQL statement of current construction, this Inventive embodiments quickly construct objectification SQL statement by based on objectification SQL frameworks, by this The SQL statement for inventing construction can evade common misspelling in speech level, and by this hair Maintainable good, the SQL based on objectification SQL frameworks construction of the objectification SQL statement of bright construction Sentence is more beneficial for safeguarding compared to large stretch of character string SQL.
Brief description of the drawings
By reading the detailed description of hereafter preferred embodiment, various other advantage and benefit for Those of ordinary skill in the art will be clear understanding.Accompanying drawing is only used for showing the mesh of preferred embodiment , and it is not considered as limitation of the present invention.And in whole accompanying drawing, with identical with reference to symbol Number represent identical part.In the accompanying drawings:
Fig. 1 is a kind of objectification SQL statement building method flow chart provided in an embodiment of the present invention;
Fig. 2 is another objectification SQL statement building method flow chart provided in an embodiment of the present invention;
Fig. 3 is a kind of structural frames of objectification SQL statement constructing apparatus provided in an embodiment of the present invention Figure.
Specific embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although showing in accompanying drawing The exemplary embodiment of the disclosure is shown, it being understood, however, that may be realized in various forms the disclosure Without that should be limited by embodiments set forth here.Conversely, there is provided these embodiments are able to more Thoroughly understand the disclosure, and can be by the complete technology for conveying to this area of the scope of the present disclosure Personnel.
To make the advantage of technical solution of the present invention clearer, with reference to the accompanying drawings and examples to this hair It is bright to elaborate.
A kind of objectification SQL statement building method is the embodiment of the invention provides, as shown in figure 1, institute The method of stating includes:
S101, response construction objectification sql command, determine the object class template of the first level.
Wherein, comprising multiple first preset SQL object classes in the object class template of first level, The first preset SQL object class is pre-configured with according to the rule of sql like language, and first is preset SQL object class specifically can be in sql like language first operational order write, the SQL In language first operational order be specifically as follows SELECT, DELETE, UPDATE, CREATE, INSERT, DROP etc., the embodiment of the present invention is not specifically limited.
In embodiments of the present invention, the construction objectification sql command specifically can be by program editing Construction objectification sql command is input into interface, it is possible to realize the object class template of the first level of output, Wherein include multiple first preset SQL classes in the object template of the first level, such as SELECT classes, DELETE classes and UPDATE classes etc., the embodiment of the present invention is not specifically limited.
It should be noted that the SQL object class in objectification SQL statement is to edit in advance, Can be classified by SQL syntax in the embodiment of the present invention, SQL statement is divided into following several shapes Formula:SQL clause (Select, Where, Joint, GroupBy etc.), operator, expression formula, Function, SQL statement, predicate, table computing and set operation etc., the embodiment of the present invention do not do specific limit It is fixed, the class of these objects is then created, so that after user input object during SQL statement, can be with These classes are directly invoked, corresponding parameter is then filled in these classes, you can complete objectification SQL The construction of sentence.
S102, described at least one first preset SQL object classes are transferred, determine described at least one One preset SQL object class.
In embodiments of the present invention, when the first preset SQL object class of client selection is received, The first preset SQL object class is transferred and determined, then shows that the first of the client selection is preset SQL object class.It should be noted that one or more SQL objects of client selection can be received Class, such as SELECT classes, DELETE classes and UPDATE classes, the embodiment of the present invention are not done specifically Limit.
For example, the first preset SQL object class for receiving client selection is SELECT classes, then show Show that SELECT classes are specific as follows shown:
SqlSession sesstion=new SqlSession (config);
ISqlExpression sqlExpression=
sesstion.Select(Metadata_Column_PERSON_AGE)
It should be noted that the PERSON_AGE in SELECT classes in this example is defeated user terminal The specific table name and field name for entering.
S103, when the corresponding parameter of the first preset SQL object class is received, determine the second level Object class template.
Wherein, a second preset SQL object is comprised at least in the object class template of second level Class, the first preset SQL object class is basis with the logical relation of the described second preset SQL object class What sql like language attribution rule determined.
Specifically, for the first preset SQL object class and the described second preset SQL object class in above-mentioned Logical relation, can based on sql like language, logical order determines in itself, for example, SQL languages Speech performs form, the setting of data object priority etc..
For the embodiment of the present invention, the parameter is mainly the information of description data attribute, specifically can be with It is field information object and table object;The parameter can also be SQL condition settings parameter, specifically set Setting value parameter etc., the embodiment of the present invention is not specifically limited.
For example, the SQL statement of conventional spell can be represented by following objectification SQL statements “SELECT age FROM Person Where age<16”:
SqlSession sesstion=new SqlSession (config);
ISqlExpression sqlExpression=
sesstion.Select(Metadata_Column_PERSON_AGE)
.From(Metadata_Table_PERSON)
.Where(new Predicate(Metadata_Column_PERSON_AGE
,Operators.LessThan,16));
As can be seen that above-mentioned objectification SQL statement can realize conventional spell SQL statement from this example “SELECT age FROM Person Where age<16 " function, i.e., search from Person tables Age field information of the age less than 16, objectification SQL statement is compiled by the class in programming language Conventional SQL statement is write, and the objectification write constructs objectification SQL statement in strict accordance with SQL Grammer is carried out, and the logic with daily spelling SQL is consistent.
In embodiments of the present invention, the mode by then passing through class realizes writing for SQL statement, therefore When SQL statement is write, conventional misspelling can be carried out using the compiler of system effectively Check, once there is SQL misspellings in compiling procedure, system will report an error automatically, therefore logical Crossing the present invention can be inherently eliminated the problem of the SQL misspellings based on character string.
The embodiment of the present invention provides a kind of construction objectification SQL statement method, response construction objectification Sql command, determines the object class template of the first level;Wherein, the object class mould of first level At least one first preset SQL object classes are included in plate;Transfer described at least one first preset SQL Object class, determines described at least one first preset SQL object classes;It is preset when receiving described first During the corresponding parameter of SQL object class, the object class template of the second level is determined, wherein, described second A second preset SQL object class, first preset SQL pairs are comprised at least in the object class template of level As class and the logical relation of the described second preset SQL object class are determined according to sql like language attribution rule 's.All it is that compared with being represented in the form of character string, the present invention is implemented with the SQL statement of current construction Example quickly constructs objectification SQL statement by based on objectification SQL frameworks, is constructed by the present invention SQL statement can evade common misspelling in speech level, and by present invention construction Maintainable good, the SQL statement phase based on objectification SQL frameworks construction of objectification SQL statement It is more beneficial for safeguarding than large stretch of character string SQL.
Another objectification SQL statement building method is the embodiment of the invention provides, as shown in Fig. 2 Methods described includes:
Each word distinguishes corresponding SQL object class in S201, configuration SQL.
Wherein, in SQL (Structured Query Language, SQL) each Word is the sentence constituted in SQL, the sentence constituted in SQL can also be specifically Select, Where, The operational orders such as Joint, GroupBy, update, or some operators in SQL statement And expression formula, some functions, predicate, table computing and set operation etc. are can also be, the present invention is real Example is applied to be not specifically limited.
For the embodiment of the present invention, each word distinguishes corresponding SQL object class in the configuration SQL Before, methods described also includes:According to the syntax rule in the SQL sequentially, in the SQL Word carry out division level, wherein, in each level at least include a word, from high to low SQL word order relations between level meet sql like language logical order in itself;The configuration Each word is distinguished corresponding SQL object class and is included in SQL:In configuration SQL in same level Word distinguishes corresponding SQL object class;For the SQL object class of same level configures corresponding object class Template.
S202, when receive client input construction objectification sql command when, export the first level Object class template.
Wherein, comprising multiple first preset SQL object classes in the object class template of first level, The first preset SQL object class is pre-configured with according to the rule of sql like language, and first is preset SQL object class specifically can be in sql like language first operational order write, the SQL In language first operational order be specifically as follows SELECT, DELETE, UPDATE, CREATE, INSERT, DROP etc., the embodiment of the present invention is not specifically limited.
In embodiments of the present invention, the construction objectification sql command specifically can be by program editing Construction objectification sql command is input into interface, it is possible to realize the object class template of the first level of output, Wherein include multiple first preset SQL classes, such as selection class in the object template of the first level SELECT, deletion class DELETE and renewal class UPDATE etc., the embodiment of the present invention is not done specifically Limit.
It should be noted that the SQL object class in objectification SQL statement is to edit in advance, Can be classified by SQL syntax in the embodiment of the present invention, SQL statement is divided into following several shapes Formula:SQL clause (Select, Where, Joint, GroupBy etc.), operator, expression formula, Function, SQL statement, predicate, table computing and set operation etc., the embodiment of the present invention do not do specific limit It is fixed, the class of these objects is then created, so that after user input object during SQL statement, can be with These classes are directly invoked, corresponding parameter is then filled in these classes, you can complete objectification SQL The input of sentence.
S203, when the first preset SQL object class of client selection is received, show the client Hold the first preset SQL object class of selection.
In embodiments of the present invention, when the first preset SQL object class of client selection is received, Show the first preset SQL object class of the client selection.It should be noted that visitor can be received One or more SQL object classes of family end selection, such as SELECT classes, DELETE classes and UPDATE Class etc., the embodiment of the present invention is not specifically limited.
In embodiments of the present invention, the mode by then passing through object class realizes writing for SQL statement, Therefore when SQL statement is write, can be effectively using the compiler of system to conventional misspelling Checked, once there is SQL misspellings in compiling procedure, system will report an error automatically, because This can be inherently eliminated the problem of the SQL misspellings based on character string by the present invention.
S204, when the parameter corresponding with the described first preset SQL object class for receiving client input When, then export the object class template of the second level.
Wherein, a second preset SQL object is comprised at least in the object class template of second level Class is, it is necessary to explanation, the SQL statement of the objectification of this law embodiment construction is in strict accordance with SQL languages Method is carried out, and consistent with the logic of daily spelling SQL, therefore SQL statement by objectification is represented The SQL statement of existing character string, effectively can detect objectification using the compiler in system SQL statement in misspelling, so as to the SQL misspellings based on character string can be inherently eliminated Problem by mistake, and then the efficiency for searching sql error sentence can be improved by the present invention.
For the embodiment of the present invention, the parameter is mainly the information of description data attribute, specifically can be with It is field information object and table object;The parameter can also be SQL condition settings parameter, specifically set Setting value parameter etc., the embodiment of the present invention is not specifically limited.
S205, judging whether can be by the described first preset SQL object class and the second preset SQL Object class is converted into SQL statement.
In embodiments of the present invention, if not can be by the described first preset SQL object class and described second Preset SQL object class is converted into SQL statement, then illustrate that the objectification SQL statement of construction does not exist Misspelling.Wherein it is possible to be converted into for the objectification SQL statement by the constructor in passing through system SQL statement is, it is necessary to explanation, the constructor in the present invention is different from intelligentized on the market in itself Analytic construction device, it is only responsible for for specified SQL object translating into mark according to the order of user group The accurate or SQL statement suitable for certain a specific database.
For example:Comparing predicate objectification SQL statement in predicate is described as follows:
sesstion.Where(
new ComparisonPredicate
(Metedata_Comlumn_PERSON_AGE,Operators.NotEqual,16))
Above-mentioned objectification SQL statement is translated, the concrete outcome of translation is Where age<>16.
It should be noted that being different from ORM, (Object Relational Mapping, object relationship is reflected Penetrate), the present invention can infer that user wants table automatically according to the objectification SQL statement relation for receiving The SQL statement for reaching, the construction of SQL statement depends entirely on the objectification SQL statement of user input, One programmer in senior SQL fields can be write out using the SQL classes of this objectification and is based on completely The SQL statement that sql like language can be described in itself;And a first programmer for dabbling SQL then may be used To write out the logical expression of mistake, what this was all allowed completely, support can operationally produce mistake. In addition, the present invention coordinates ISqlProvider by providing an ISqlBuilder interface contract for standard Standard interface, can be supported to certain database.
If S206a, can not, export SQL syntax miscue information.
In embodiments of the present invention, if can not be by the described first preset SQL object class and described second Preset SQL object class is converted into SQL statement, then export SQL syntax miscue information.This hair The bright SQL constructors by internal system, operationally carry out syntax check to SQL statement, so that Can quick Wrong localization.
If S206b, energy, perform the SQL statement.
Wherein, step S206b is the step arranged side by side of step S206a, if can be preset by described first SQL object class and the second preset SQL object class are converted into SQL statement, then perform the SQL Sentence.
S207b, record perform the SQL statement of mistake.
In embodiments of the present invention, when the SQL statement is performed, can be by mapper by system Know need how the field of correspondence inquiry is converted into the entity attributes to be inquired about, system can be right The execution of each SQL carries out the statistics of performance, and then record performs the SQL statement of mistake, in order to Follow-up optimization.Simultaneously also can the SQL implementation procedures of object mistake be tracked, be easy to the row of problem Look into.
The embodiment of the present invention provides another objectification SQL statement building method, when receiving client During the construction objectification sql command of input, the object class template of the first level, the ground floor are exported Comprising multiple first preset SQL object classes in the object class template of level;When receive client selection During the first preset SQL object class, the first preset SQL object class of the client selection is shown;When When receiving the parameter corresponding with the described first preset SQL object class of client input, then the is exported The object class template of two levels, comprised at least in the object class template of second level one it is second pre- SQL object class is put, wherein, the first preset SQL object class and the described second preset SQL object class Ordinal relation meet sql like language logical order in itself.With the SQL statement of current construction be all with What the form of character string was represented compares, and the embodiment of the present invention is by quick based on objectification SQL frameworks Construction objectification SQL statement, can be evaded often by the SQL statement of present invention construction in speech level The misspelling seen, and by maintainable good, the base of the objectification SQL statement for constructing of the invention It is more beneficial for safeguarding compared to large stretch of character string SQL in the SQL statement of objectification SQL frameworks construction.
Further, the embodiment of the present invention provides a kind of objectification SQL statement constructing apparatus, such as Fig. 3 Shown, described device includes:Response unit 31, transfer unit 32 and determining unit 33.
Response unit 31, for responding construction objectification sql command, determines the object class of the first level Template;Wherein, comprising at least one first preset SQL pairs in the object class template of first level As class.
Unit 32 is transferred, for transferring described at least one first preset SQL object classes, it is determined that described At least one first preset SQL object classes.
Determining unit 33, for when the corresponding parameter of the described first preset SQL object class is received, Determine the object class template of the second level, wherein, at least wrapped in the object class template of second level Containing a second preset SQL object class, the first preset SQL object class SQL preset with described second The logical relation of object class is determined according to sql like language attribution rule.
It should be noted that a kind of objectification SQL statement constructing apparatus institute provided in an embodiment of the present invention It is related to other corresponding descriptions of each functional unit, may be referred to the correspondence description of method shown in Fig. 1, This is repeated no more, it should be understood that the device in the present embodiment can be corresponded to and realize that preceding method is implemented Full content in example.
The embodiment of the present invention provides a kind of objectification SQL statement constructing apparatus, defeated when client is received During the construction objectification sql command for entering, the object class template of the first level, first level are exported Object class template in comprising multiple first preset SQL object classes;When receiving the of client selection During one preset SQL object class, the first preset SQL object class of the client selection is shown;When connecing When receiving the parameter corresponding with the described first preset SQL object class of client input, then second is exported The object class template of level, comprised at least in the object class template of second level one it is second preset SQL object class, wherein, the first preset SQL object class and the described second preset SQL object class Ordinal relation meets sql like language logical order in itself.SQL statement with current construction is all with word What the form of symbol string was represented compares, and the embodiment of the present invention is by based on the objectification quick structure of SQL frameworks Objectification SQL statement is made, can be evaded in speech level by the SQL statement of present invention construction common Misspelling, and pass through the present invention construction objectification SQL statement it is maintainable good, be based on The SQL statement of objectification SQL frameworks construction is more beneficial for safeguarding compared to large stretch of character string SQL.
Further, the embodiment of the present invention provides another objectification SQL statement constructing apparatus, specifically It is as follows:
Output unit, for when the construction objectification sql command of client input is received, exporting The object class template of the first level, includes at least one first in the object class template of first level Preset SQL object class.
Display unit, for when the first preset SQL object class of client selection is received, showing First preset SQL object class of the client selection.
The output unit, is additionally operable to work as SQL pairs preset with described first that receives client input During parameter corresponding as class, then the object class template of the second level is exported, wherein, second level Object class template in comprise at least a second preset SQL object class, the first preset SQL object class Ordinal relation with the described second preset SQL object class meets sql like language logical order in itself.
Further, described device also includes:
Dispensing unit, corresponding SQL object class is distinguished for configuring each word in the SQL.
Further described device also includes:Division unit.
The division unit, for according to the syntax rule in the SQL sequentially, in the SQL Word carry out division level, wherein, in each level at least include a word, from high to low SQL word order relations between level meet sql like language logical order in itself.
The dispensing unit, it is corresponding specifically for the word difference in same level in configuration SQL SQL object class.
The dispensing unit, is specifically additionally operable to configure corresponding object for the SQL object class of same level Class template.
Further, described device also includes:
The judging unit, for judge whether can be by the described first preset SQL object class and described Second preset SQL object class is converted into SQL statement.
The output unit, can not be by the described first preset SQL object class and described second if being additionally operable to Preset SQL object class is converted into SQL statement, exports SQL logic error prompt messages.
Further, described device also includes:
Execution unit, if can be by the described first preset SQL object class and described second preset SQL pairs As class is converted into SQL statement, then the SQL statement is performed.
Recording unit, the SQL statement of mistake is performed for recording.
It should be noted that a kind of objectification SQL statement constructing apparatus institute provided in an embodiment of the present invention It is related to other corresponding descriptions of each functional unit, may be referred to the correspondence description of method shown in Fig. 2, This is repeated no more, it should be understood that the device in the present embodiment can be corresponded to and realize that preceding method is implemented Full content in example.
The embodiment of the present invention provides a kind of objectification SQL statement constructing apparatus, defeated when client is received During the construction objectification sql command for entering, the object class template of the first level, first level are exported Object class template in comprising multiple first preset SQL object classes;When receiving the of client selection During one preset SQL object class, the first preset SQL object class of the client selection is shown;When connecing When receiving the parameter corresponding with the described first preset SQL object class of client input, then second is exported The object class template of level, comprised at least in the object class template of second level one it is second preset SQL object class, wherein, the first preset SQL object class and the described second preset SQL object class Ordinal relation meets sql like language logical order in itself.SQL statement with current construction is all with word What the form of symbol string was represented compares, and the embodiment of the present invention is by based on the objectification quick structure of SQL frameworks Objectification SQL statement is made, can be evaded in speech level by the SQL statement of present invention construction common Misspelling, and pass through the present invention construction objectification SQL statement it is maintainable good, be based on The SQL statement of objectification SQL frameworks construction is more beneficial for safeguarding compared to large stretch of character string SQL.
The objectification SQL statement constructing apparatus include processor and memory, above-mentioned output unit, Dispensing unit, display unit, division unit, judging unit, execution unit and recording unit etc. are made For program unit storage in memory, by computing device storage said procedure list in memory Unit realizes corresponding function.
Kernel is included in processor, is gone in memory to transfer corresponding program unit by kernel.Kernel can To set one or more, the efficiency for searching sql error sentence is improved by adjusting kernel parameter.
Memory potentially includes the volatile memory in computer-readable medium, random access memory The form such as device (RAM) and/or Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM), memory includes at least one storage chip.
Present invention also provides a kind of computer program product, when being performed on data processing equipment, It is adapted for carrying out the program code of initialization there are as below methods step:When the construction for receiving client input During objectification sql command, the object class template of the first level, the object class of first level are exported Comprising multiple first preset SQL object classes in template;When receiving the first preset of client selection During SQL object class, the first preset SQL object class of the client selection is shown;When receiving visitor During the parameter corresponding with the described first preset SQL object class of family end input, then the second level is exported Object class template, wherein, comprised at least in the object class template of second level one it is second preset SQL object class, the first preset SQL object class is closed with the order of the described second preset SQL object class System meets sql like language logical order in itself.
It should be understood by those skilled in the art that, embodiments herein can be provided as method, system, Or computer program product.Therefore, the application can be implemented using complete hardware embodiment, complete software The form of the embodiment in terms of example or combination software and hardware.And, the application can be used at one Or multiple wherein includes the computer-usable storage medium of computer usable program code (including but not Be limited to magnetic disk storage, CD-ROM, optical memory etc.) on the computer program product implemented Form.
The application is with reference to the method according to the embodiment of the present application, equipment (system) and computer program The flow chart and/or block diagram of product is described.It should be understood that can be realized flowing by computer program instructions In each flow and/or square frame and flow chart and/or block diagram in journey figure and/or block diagram Flow and/or square frame combination.Can provide these computer program instructions to all-purpose computer, specially With the processor of computer, Embedded Processor or other programmable data processing devices producing one Machine so that produced by the instruction of computer or the computing device of other programmable data processing devices It is raw to be used to realize in one flow of flow chart or multiple flow and/or block diagram one square frame or multiple side The device of the function of being specified in frame.
These computer program instructions may be alternatively stored in can guide computer or other programmable datas to process In the computer-readable memory that equipment works in a specific way so that storage is deposited in the computer-readable Instruction in reservoir is produced and includes the manufacture of command device, and command device realization is in flow chart one The function of being specified in flow or multiple one square frame of flow and/or block diagram or multiple square frames.
These computer program instructions can also be loaded into computer or other programmable data processing devices On so that series of operation steps is performed on computer or other programmable devices to produce computer The treatment of realization, so as to the instruction performed on computer or other programmable devices is provided for realizing Specified in one flow of flow chart or multiple one square frame of flow and/or block diagram or multiple square frames The step of function.
In a typical configuration, computing device include one or more processors (CPU), input/ Output interface, network interface and internal memory.
Memory potentially includes the volatile memory in computer-readable medium, random access memory The form such as device (RAM) and/or Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM).Memory is the example of computer-readable medium.
Computer-readable medium includes that permanent and non-permanent, removable and non-removable media can be with Information Store is realized by any method or technique.Information can be computer-readable instruction, data knot Structure, the module of program or other data.The example of the storage medium of computer includes, but are not limited to phase Become internal memory (PRAM), static RAM (SRAM), dynamic random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electricity can Erasable programmable read-only memory (EPROM) (EEPROM), fast flash memory bank or other memory techniques, read-only light Disk read-only storage (CD-ROM), digital versatile disc (DVD) or other optical storages, magnetic Cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus or any other non-transmission medium, Can be used to store the information that can be accessed by a computing device.Defined according to herein, computer-readable Medium does not include temporary computer readable media (transitory media), such as data-signal and load of modulation Ripple.
Embodiments herein is these are only, the application is not limited to.For this area skill For art personnel, the application can have various modifications and variations.It is all spirit herein and principle it Interior made any modification, equivalent substitution and improvements etc., should be included in claims hereof model Within enclosing.

Claims (10)

1. a kind of objectification SQL statement building method, it is characterised in that including:
Response construction objectification sql command, determines the object class template of the first level;Wherein, it is described At least one first preset SQL object classes are included in the object class template of the first level;
Described at least one first preset SQL object classes are transferred, determines that described at least one first is preset SQL object class;
When the corresponding parameter of the described first preset SQL object class is received, the right of the second level is determined As class template, wherein, a second preset SQL is comprised at least in the object class template of second level Object class, the first preset SQL object class is root with the logical relation of the described second preset SQL object class Determine according to sql like language attribution rule.
2. method according to claim 1, it is characterised in that the level of the determination first it is right Before class template, methods described also includes:
Each word distinguishes corresponding SQL object class in configuring the SQL.
3. method according to claim 2, it is characterised in that in the configuration SQL each Before word distinguishes corresponding SQL object class, methods described also includes:
According to the syntax rule in the SQL sequentially, division level is carried out to the word in the SQL, Wherein, a word is at least included in each level, the SQL words between level from high to low are suitable Order relation meets sql like language logical order in itself;
Each word distinguishes corresponding SQL object class in the configuration SQL includes:
Word in configuration SQL in same level distinguishes corresponding SQL object class;
For the SQL object class of same level configures corresponding object class template.
4. method according to claim 3, it is characterised in that methods described also includes:
Judging whether can be by the described first preset SQL object class and the second preset SQL object class It is converted into SQL statement;
If can not, export SQL logic error prompt messages.
5. method according to claim 4, it is characterised in that described judge whether can be by institute State the first preset SQL object class and the second preset SQL object class be converted into after SQL statement, Methods described also includes:
If can, perform the SQL statement;
Record performs the SQL statement of mistake.
6. a kind of objectification SQL statement constructing apparatus, it is characterised in that including:
Response unit, for responding construction objectification sql command, determines the object class mould of the first level Plate;Wherein, at least one first preset SQL objects are included in the object class template of first level Class;
Transfer unit, for transferring described at least one first preset SQL object classes, it is determined that it is described extremely A few first preset SQL object class;
Determining unit, for when the corresponding parameter of the described first preset SQL object class is received, really The object class template of fixed second level, wherein, comprised at least in the object class template of second level One the second preset SQL object class, the first SQL pairs preset with described second of preset SQL object class As the logical relation of class is determined according to sql like language attribution rule.
7. device according to claim 6, it is characterised in that described device also includes:
Dispensing unit, corresponding SQL object class is distinguished for configuring each word in the SQL.
8. device according to claim 7, it is characterised in that described device also includes:Divide Unit;
The division unit, for according to the syntax rule in the SQL sequentially, in the SQL Word carry out division level, wherein, in each level at least include a word, from high to low SQL word order relations between level meet sql like language logical order in itself;
The dispensing unit, it is corresponding specifically for the word difference in same level in configuration SQL SQL object class;
The dispensing unit, is specifically additionally operable to configure corresponding object for the SQL object class of same level Class template.
9. device according to claim 8, it is characterised in that described device also includes:
Judging unit, for judge whether can be by the described first preset SQL object class and described second Preset SQL object class is converted into SQL statement;
Output unit, if for can not be by the described first preset SQL object class and described second preset SQL object class is converted into SQL statement, then export SQL logic error prompt messages.
10. device according to claim 9, it is characterised in that described device also includes:
Execution unit, if can be by the described first preset SQL object class and described second preset SQL pairs As class is converted into SQL statement, then the SQL statement is performed;
Recording unit, the SQL statement of mistake is performed for recording.
CN201510882493.0A 2015-12-03 2015-12-03 Objectification SQL sentence construction method and apparatus Active CN106844369B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510882493.0A CN106844369B (en) 2015-12-03 2015-12-03 Objectification SQL sentence construction method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510882493.0A CN106844369B (en) 2015-12-03 2015-12-03 Objectification SQL sentence construction method and apparatus

Publications (2)

Publication Number Publication Date
CN106844369A true CN106844369A (en) 2017-06-13
CN106844369B CN106844369B (en) 2020-12-29

Family

ID=59149691

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510882493.0A Active CN106844369B (en) 2015-12-03 2015-12-03 Objectification SQL sentence construction method and apparatus

Country Status (1)

Country Link
CN (1) CN106844369B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107622080A (en) * 2017-07-28 2018-01-23 阿里巴巴集团控股有限公司 A kind of data processing method and equipment
CN109508182A (en) * 2018-09-18 2019-03-22 广州虎牙信息科技有限公司 Quickly generate method, server and the computer storage medium of instruction
CN109522324A (en) * 2018-11-02 2019-03-26 平安医疗健康管理股份有限公司 A kind of SQL scenario generation method, device and computer equipment
CN110020072A (en) * 2017-09-30 2019-07-16 北京国双科技有限公司 A kind of data processing method and terminal based on Elasticsearch
CN111737233A (en) * 2020-06-24 2020-10-02 浙江大华技术股份有限公司 Data monitoring method and device
CN117251473A (en) * 2023-11-20 2023-12-19 摩斯智联科技有限公司 Vehicle data query analysis method, system, device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5905982A (en) * 1997-04-04 1999-05-18 International Business Machines Corporation Handling null values in SQL queries over object-oriented data
CN103617273A (en) * 2013-12-05 2014-03-05 用友软件股份有限公司 SOL script objectification method and system
CN103914290A (en) * 2012-12-31 2014-07-09 杭州勒卡斯广告策划有限公司 Operating command processing method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5905982A (en) * 1997-04-04 1999-05-18 International Business Machines Corporation Handling null values in SQL queries over object-oriented data
CN103914290A (en) * 2012-12-31 2014-07-09 杭州勒卡斯广告策划有限公司 Operating command processing method and device
CN103617273A (en) * 2013-12-05 2014-03-05 用友软件股份有限公司 SOL script objectification method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
SRTILLERY1029: "MyBatis 3用户指南", 《百度文库:HTTPS://WENKU.BAIDU.COM/VIEW/37A0990A76C66137EE06195D.HTML?REC_FLAG=DEFAULT&SXTS=1566807365422》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107622080A (en) * 2017-07-28 2018-01-23 阿里巴巴集团控股有限公司 A kind of data processing method and equipment
CN107622080B (en) * 2017-07-28 2020-10-30 创新先进技术有限公司 Data processing method and equipment
CN110020072A (en) * 2017-09-30 2019-07-16 北京国双科技有限公司 A kind of data processing method and terminal based on Elasticsearch
CN109508182A (en) * 2018-09-18 2019-03-22 广州虎牙信息科技有限公司 Quickly generate method, server and the computer storage medium of instruction
CN109522324A (en) * 2018-11-02 2019-03-26 平安医疗健康管理股份有限公司 A kind of SQL scenario generation method, device and computer equipment
CN111737233A (en) * 2020-06-24 2020-10-02 浙江大华技术股份有限公司 Data monitoring method and device
CN117251473A (en) * 2023-11-20 2023-12-19 摩斯智联科技有限公司 Vehicle data query analysis method, system, device and storage medium
CN117251473B (en) * 2023-11-20 2024-03-15 摩斯智联科技有限公司 Vehicle data query analysis method, system, device and storage medium

Also Published As

Publication number Publication date
CN106844369B (en) 2020-12-29

Similar Documents

Publication Publication Date Title
CN106844369A (en) Objectification SQL statement building method and device
US11468043B1 (en) Batching database queries for migration to a different database
CN106897322B (en) A kind of access method and device of database and file system
CN104133772B (en) Automatic test data generation method
US9460173B2 (en) Method and system for metadata driven processing of federated data
CN107239479A (en) A kind of method and device of data storage and inquiry based on block chain
US9280568B2 (en) Zero downtime schema evolution
CN111078702B (en) SQL sentence classification management and unified query method and device
CN106611037A (en) Method and device for distributed diagram calculation
US9720960B2 (en) Reporting tools for object-relational databases
CN105630475B (en) A kind of data label organization system and method for organizing
CN107391384A (en) A kind of SQL statement detection method and system
US10831784B2 (en) Integration of relational calculation views into a relational engine
CN106815100A (en) Interface test method and device
CN109902101A (en) Transparent partition method and device based on SparkSQL
CN109657803A (en) The building of machine learning model
US20130346845A1 (en) Interactive multi device in memory form generation
EP3293645A1 (en) Iterative evaluation of data through simd processor registers
Lai et al. {GLogS}: Interactive graph pattern matching query at large scale
CN108780452B (en) Storage process processing method and device
CN112463814A (en) Data query method and device
CN107220265A (en) A kind of database statement compiling and execution method and device
US20220078228A1 (en) Infrastructure imports for an information technology platform
CN115794858A (en) Query statement processing method, device, equipment and storage medium
US9910616B2 (en) Dynamic data access

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100083 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Applicant after: Beijing Guoshuang Technology Co.,Ltd.

Address before: 100086 Cuigong Hotel, 76 Zhichun Road, Shuangyushu District, Haidian District, Beijing

Applicant before: Beijing Guoshuang Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant