[go: up one dir, main page]

CN105653277A - Method for querying appointed field data of data table under simplified JAVA program, multi-table conjunctive query method under simplified JAVA program and statistical query method under simplified JAVA program - Google Patents

Method for querying appointed field data of data table under simplified JAVA program, multi-table conjunctive query method under simplified JAVA program and statistical query method under simplified JAVA program Download PDF

Info

Publication number
CN105653277A
CN105653277A CN201511019543.9A CN201511019543A CN105653277A CN 105653277 A CN105653277 A CN 105653277A CN 201511019543 A CN201511019543 A CN 201511019543A CN 105653277 A CN105653277 A CN 105653277A
Authority
CN
China
Prior art keywords
data
java program
name
field
under simplified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201511019543.9A
Other languages
Chinese (zh)
Inventor
仲灵烨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Jiankun Information Technology Co Ltd
Original Assignee
Shanghai Jiankun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Jiankun Information Technology Co Ltd filed Critical Shanghai Jiankun Information Technology Co Ltd
Priority to CN201511019543.9A priority Critical patent/CN105653277A/en
Publication of CN105653277A publication Critical patent/CN105653277A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method for querying the appointed field data of a data table under a simplified JAVA program. The method comprises the following steps: creating a data entity class corresponding to a table field one by one; describing a field name to be queried by a character string array; creating a corresponding sql (Structured Query Language) query statement, and initiating and obtaining a result; utilizing reflection to map the result data to each attribute of a corresponding data entity object; and during data operation, directly utilizing a "get" method in the object to read a certain value.

Description

A kind of simplify under JAVA program inquire about tables of data designated field data, multilist conjunctive query, statistical query method
Technical field
The invention belongs to computer programming field, particularly to a kind of method simplifying and inquiring about tables of data designated field data, multilist conjunctive query, statistical query under JAVA program.
Background technology
Under existing JAVA program, it will usually have following several " out-of-date methods " that a query portion field data can be accomplished, but be required for writing the code of extra bulk redundancy, wherein:
1. it is likely to write the building method of multiple correspondent entity class for various inquiry fields.
Example: if " name " field in inquiry UserInfo table
PublicUserInfo (Stringname) { this.name=name; }
Or inquire about " name " " age " " address " in table
Then when writing inquiry, the actual building method writing certain needs of use
Stringhql=" selectnewUserInfo (name) fromUserInfo ";
......
The shortcoming of this mode is first to create corresponding building method for different query demands, it is impossible to the pure exploitation being absorbed in service logic.
2. it is that the inquiry field that each is possible creates mapping entity class, during inquiry, calls correspondent entity class. Its essence is consistent with method 1, only replaces building method by a new class. To be created that the entity class of correspondence when shortcoming is still that exploitation for business demand, then have and process the logic development calling these classes, the logic that different types of result data is processed, it is impossible to be absorbed in real service logic exploitation.
3. inquire about by pure SQL statement. Can accomplish relatively to be absorbed in the exploitation in service logic, however it is necessary that developer understands SQL syntax, and correctly write. The code major part of exploitation is the SQL statement with character string forms, it may occur that cacography in character string, the composition error between character string and parameter; Mistake investigation, later stage revise difficult in maintenance; Code Core is not object-oriented, couples closely with actually used type of database
4. utilize the method that third party's framework provides, it is possible to accomplishing to be absorbed in service logic exploitation, need not write SQL statement, code complies fully with the thought of object-oriented. Shortcoming be it should be understood that framework mechanism it is known that and grasp use its offer method; Needing also exist for writing more, step is various and a certain amount of redundant code. To use " Hibernate ", simplest it is accomplished by
// 1. query object DetachedCriteria being created that the table entity class with inquiry
// 2. object set ProjectionList creating inquiry field definition
// 3. create each field object Projections to inquire about and it are put into one by one in ProjectionList
ProjectionList object value is given to DetachedCriteria query object by // 4.
The result data of return is put in certain data carrier type by // 5. definition
// 6. perform, with the DetachedCriteria querying method being parameter, to obtain result
Summary of the invention
It is an object of the invention to provide a kind of method inquiring about tables of data designated field data, multilist conjunctive query, statistical query under JAVA program, to simplify existing written in code.
The technical scheme is that, a kind of simplify under JAVA program inquire about tables of data designated field data method, including step:
Create and literary name section classes of data entities one to one;
The field name to inquire about is described with character string dimension;
It is created that the sql query statement of correspondence, initiates inquiry and obtain result;
Reflection is utilized to be mapped to by result data in each attribute of data entity object of correspondence;
Then directly some value is read by " get " method in object during operation data.
A kind of simplify the method for multilist conjunctive query under JAVA program, including step:
The method pole adopting above-mentioned inquiry tables of data designated field data joins the inquiry of multiple contingency tables;
By the form of " some attribute-name in type object name the type " of association in character string dimension during definition conjunctive query;
Adopt " innerjoin " mode to associate between acquiescence multilist, time specifically used, specify " right/leftjoin ".
A kind of simplify the method for statistical query under JAVA program, adopt the method for above-mentioned inquiry tables of data designated field data and the method for multilist conjunctive query, and take following steps:
Create the object of statistics that specifically to use, including statistics field name and the pattern (utilizing the several statistical model of enumeration type definition " max, min, sum, avg, count ") of statistics;
The field name of " groupby " is described with character string dimension.
The beneficial effect comprise that
SQL statement need not be write;
Multiple entity class need not be created in advance and define multiple building methods;
It is simple method by various and redundancy the code wrap of step that originally to write, substantially reduce the number size of code;
Amendment when inquiry is changed has only to the inquiry word name section character string dimension of amendment definition;
It is consistent that basic query writes mode with conjunctive query, it is not necessary to extra size of code, and can infinitely join pole;
Type and the method for those specific functions in framework need not be paid close attention to.
Accompanying drawing explanation
Fig. 1 is that in the present invention, class and Property Name thereof and tables of data and field thereof map.
Fig. 2 is user message table in the embodiment of the present invention.
Fig. 3 is inquiry user data procedure chart in the embodiment of the present invention.
Fig. 4 is blog table in the embodiment of the present invention.
Fig. 5 is the procedure chart inquiring about blog data in the embodiment of the present invention.
Fig. 6 is the procedure chart inquiring about many sections of blog data in the embodiment of the present invention.
Detailed description of the invention
The operating principle that the method for the present invention relates to includes:
A. class is created, defined attribute, writes the get/set method of attribute, and class and Property Name thereof and tables of data and field thereof is mapped, as it is shown in figure 1, be created that this object of query object can define all of settings that can inquire about such as the wheregroupby of inquiry based on this;
B. will inquire about some field corresponding generic attribute title mode putting character string dimension into represent;
C. circulate character string dimension, each Property Name is set in query object, the field that inquire about is set;
D. the data of the data acquisition system got are put in entity class by write method, and this entity class is generally the class mapped with table, it is also possible to being other classes other, such must provide for get/set method;
E. the inquiry of multilist conjunctive query, polymerization calculating can be expanded based on method described above.
Wherein, basic methods is:
1. create and literary name section classes of data entities one to one;
2. the field name to inquire about is described with character string dimension;
3. method can be created that the sql query statement of correspondence, initiate inquiry and obtain result;
4. utilize reflection to be mapped to by result data in each attribute of data entity object of correspondence;
5. then directly read some value by " get " method in object during operation data.
It is exemplified below:
1. assuming there is a user message table " UserInfo ", as in figure 2 it is shown, wherein, " address " and " remarks " field there may be bigger data volume to list structure, does not generally directly inquire about acquisition
2. perform the process of inquiry user data, as it is shown on figure 3, wherein,
Actual queries " id, name, age, gender " field of table
Finally directly obtain the data set of " List<UserInfo>" type to operate data
Multilist conjunctive query method is:
1. infinitely can open the inquiry of contingency table by connection n in pole on basic methods principle;
2. Method And Principle is consistent with basic methods with step;
3. character string dimension is used during definition conjunctive query the form of " some attribute-name in type object name the type " of association;
4. adopt " innerjoin " mode to associate between acquiescence multilist, time specifically used, may specify " right/leftjoin ". It is exemplified below:
1. assuming there is a blog table " Blog ", associate with " UserInfo ", list structure is as shown in Figure 4. Article content is big text data type, and userId associates " id " of user's table " UserInfo ".
2. the title inquiring about blog inquires owning user name simultaneously, performs process as shown in Figure 5. " id, time, the timeFlag " field of actual queries " Blog " table and " name " field of " UserInfo " table; Finally directly obtain the data set of " List<Blog>" type to operate data.
Statistical query method is:
1. create the object of statistics specifically used, including
1) add up field name;
2) pattern (utilizing the several statistical model of enumeration type definition " max, min, sum, avg, count ") added up;
2. the field name of " groupby " is described with character string dimension;
3. other to realize principle consistent with multilist conjunctive query with basic methods principle.
It is exemplified below:
Inquire about each user and have several sections of blogs, perform process as shown in Figure 6. Wherein, owing to the result of statistical query return is generally inconsistent with the classes of data entities form being queried statistics, it is necessary to defining an object " BlogCount " for carrying result data, this object does not map with any tables of data.

Claims (3)

1. one kind simplifies the method inquiring about tables of data designated field data under JAVA program, it is characterised in that include step:
Create and literary name section classes of data entities one to one;
The field name to inquire about is described with character string dimension;
It is created that the sql query statement of correspondence, initiates inquiry and obtain result;
Reflection is utilized to be mapped to by result data in each attribute of data entity object of correspondence;
Then directly some value is read by " get " method in object during operation data.
2. one kind simplifies the method for multilist conjunctive query under JAVA program, it is characterised in that include step:
The method of claim 1 pole is adopted to join the inquiry of multiple contingency tables;
By the form of " some attribute-name in type object name the type " of association in character string dimension during definition conjunctive query;
Adopt " innerjoin " mode to associate between acquiescence multilist, time specifically used, specify " right/leftjoin ".
3. one kind simplifies the method for statistical query under JAVA program, it is characterised in that adopts the method as described in claim 1 and claim 2, and takes following steps:
Create the object of statistics that specifically to use, including statistics field name and the pattern (utilizing the several statistical model of enumeration type definition " max, min, sum, avg, count ") of statistics;
The field name of " groupby " is described with character string dimension.
CN201511019543.9A 2015-12-29 2015-12-29 Method for querying appointed field data of data table under simplified JAVA program, multi-table conjunctive query method under simplified JAVA program and statistical query method under simplified JAVA program Pending CN105653277A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201511019543.9A CN105653277A (en) 2015-12-29 2015-12-29 Method for querying appointed field data of data table under simplified JAVA program, multi-table conjunctive query method under simplified JAVA program and statistical query method under simplified JAVA program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201511019543.9A CN105653277A (en) 2015-12-29 2015-12-29 Method for querying appointed field data of data table under simplified JAVA program, multi-table conjunctive query method under simplified JAVA program and statistical query method under simplified JAVA program

Publications (1)

Publication Number Publication Date
CN105653277A true CN105653277A (en) 2016-06-08

Family

ID=56477472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201511019543.9A Pending CN105653277A (en) 2015-12-29 2015-12-29 Method for querying appointed field data of data table under simplified JAVA program, multi-table conjunctive query method under simplified JAVA program and statistical query method under simplified JAVA program

Country Status (1)

Country Link
CN (1) CN105653277A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106802926A (en) * 2016-12-21 2017-06-06 上海数据交易中心有限公司 A kind of multiparty data inquiry system and method
CN108932339A (en) * 2018-07-12 2018-12-04 浪潮软件集团有限公司 Method for obtaining parameter values necessary for checking query plan in Impala database
CN109739872A (en) * 2018-12-27 2019-05-10 苏州思必驰信息科技有限公司 An implementation method, system and operation method of SQL statement processing

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100005057A1 (en) * 2008-07-02 2010-01-07 Lexisnexis Risk & Information Analytics Group Inc. Statistical measure and calibration of internally inconsistent search criteria where one or both of the search criteria and database is incomplete
CN103093000A (en) * 2013-02-25 2013-05-08 用友软件股份有限公司 Database query modeling system and database query modeling method
CN103226478A (en) * 2013-05-22 2013-07-31 北京金和软件股份有限公司 Method for automatically generating and using code

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100005057A1 (en) * 2008-07-02 2010-01-07 Lexisnexis Risk & Information Analytics Group Inc. Statistical measure and calibration of internally inconsistent search criteria where one or both of the search criteria and database is incomplete
CN103093000A (en) * 2013-02-25 2013-05-08 用友软件股份有限公司 Database query modeling system and database query modeling method
CN103226478A (en) * 2013-05-22 2013-07-31 北京金和软件股份有限公司 Method for automatically generating and using code

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
龙觉忠: "《mysql字符串分割为字段的方法》", 《HTTP://WWW.DEWEN.NET.CN/Q/4834》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106802926A (en) * 2016-12-21 2017-06-06 上海数据交易中心有限公司 A kind of multiparty data inquiry system and method
CN106802926B (en) * 2016-12-21 2019-11-22 上海数据交易中心有限公司 A kind of multiparty data inquiry system and method
CN108932339A (en) * 2018-07-12 2018-12-04 浪潮软件集团有限公司 Method for obtaining parameter values necessary for checking query plan in Impala database
CN109739872A (en) * 2018-12-27 2019-05-10 苏州思必驰信息科技有限公司 An implementation method, system and operation method of SQL statement processing
CN109739872B (en) * 2018-12-27 2025-08-19 思必驰科技股份有限公司 Implementation method, system and operation method for SQL sentence processing

Similar Documents

Publication Publication Date Title
US11334594B2 (en) Data model transformation
US10216826B2 (en) Database query system
US8972433B2 (en) Systems and methods for programmatic generation of database statements
US8429601B2 (en) Code completion for object relational mapping query language (OQL) queries
US9619552B2 (en) Core data services extensibility for entity-relationship models
US8694557B2 (en) Extensibility of metaobjects
US9354948B2 (en) Data models containing host language embedded constraints
US7895226B2 (en) System and method for translating and executing update requests
CN103049251B (en) A kind of data base persistence layer device and database operation method
CN106934062A (en) A kind of realization method and system of inquiry elasticsearch
CN106874388A (en) A kind of heterogeneous system data cascade operation method for auto constructing based on relevant database
US10997131B1 (en) Using a member attribute to perform a database operation on a computing device
US11341142B2 (en) Framework and metadata artefacts for updating data artefacts
CN107679071B (en) A custom packaging method for general data services for relational databases
CN101122854A (en) Structured code automatic configuration method and device
US9098546B2 (en) Advanced business query language
US9053134B2 (en) View variants in database schema mapping
CN113779068A (en) Data query method, device, equipment and storage medium
CN105653277A (en) Method for querying appointed field data of data table under simplified JAVA program, multi-table conjunctive query method under simplified JAVA program and statistical query method under simplified JAVA program
US8538980B1 (en) Accessing forms using a metadata registry
CN117827880A (en) Data model query method, device and storage medium based on low-code platform
CN117851375A (en) Metadata model optimization method and computing device
Troelsen et al. Exploring Entity Framework Core
CN119690388A (en) Data processing method and device based on field drive design and electronic equipment
CN111367941A (en) Query language extension method based on business entity BE and basic implementation method thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20160608

RJ01 Rejection of invention patent application after publication