CN105205103A - Method and device for accessing database - Google Patents

Method and device for accessing database Download PDF

Info

Publication number
CN105205103A
CN105205103A CN201510528428.8A CN201510528428A CN105205103A CN 105205103 A CN105205103 A CN 105205103A CN 201510528428 A CN201510528428 A CN 201510528428A CN 105205103 A CN105205103 A CN 105205103A
Authority
CN
China
Prior art keywords
value
class
database
mapping table
persistent
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
CN201510528428.8A
Other languages
Chinese (zh)
Other versions
CN105205103B (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 Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201510528428.8A priority Critical patent/CN105205103B/en
Publication of CN105205103A publication Critical patent/CN105205103A/en
Application granted granted Critical
Publication of CN105205103B publication Critical patent/CN105205103B/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

Abstract

The invention provides a method and a device for accessing a database. According to the method and the device, the system performance and the development efficiency are beneficially improved, and besides, the standardization problem of interfaces is beneficially solved. The method comprises the following steps: receiving a class object and a value mapping table of a public interface class of a persistent layer, wherein the class object is obtained by abstracting the persistent layer as the public interface class; acquiring a value object according to the class object, and carrying out father entity filling on the value object according to the value mapping table and the class object; converting the filled value object into a persistent object; and storing data in the persistent object into the database.

Description

The method and apparatus of accessing database
Technical field
The present invention relates to field of computer technology, particularly a kind of method and apparatus of accessing database.
Background technology
JDBC (JavaDataBaseConnectivity, java DataBase combining) is a kind of JavaAPI for performing SQL statement, can provide unified access for multiple relational database, and the class that it is write with Java language by a group and interface form.JDBC provides a kind of benchmark, can build more senior instrument and interface accordingly, enables database development personnel write database application.Rarely J2EE application directly can carry out database access in the mode of JDBC at present.After all, visit relational database with object oriented program language, the workload in performance history is very large.When major part, J2EE application all can carry out data access with ORM framework, ORM (ObjectRelationalMapping) framework adopts metadata to carry out description object one relationship map details, and metadata generally adopts XML format, and leaves in special object one mapped file.As long as provide the mapping relations of lasting classification and table, ORM framework operationally just can with reference to the information of mapped file, Object Persistence in database.Current ORM framework mainly contains three kinds: Hibernate (Nhibernate), iBATIS, EclipseLink.In all ORM frameworks, Hibernate is dexterous with it, the favor of numerous developer has been won in light encapsulation.Although Hibernate is the condition that developer provides convenience, primary framework might not meet the development requires in reality completely, can be restricted on the norm-setting of project, is unfavorable for subsequent upgrade and the maintenance of project.Therefore, how carrying out secondary encapsulation to these frameworks, are key issues with satisfied exploitation needs, this problem is mainly reflected in three aspects: one is the development specifications meeting project itself, two be to drop to a lower level between coupling, three is improve system performance and development efficiency.
In current usual way, be generally with SpringIOC container for core, form a connecting link.Following three tool-class (or interface) provided by Spring support the realization of persistent layer: HibernateDaoSupPOrt, HibernateTemplate and HibernateCallback.By SpringIOC container, SessionFactoryBean is injected DAO assembly, once DAO assembly obtains quoting of SessionFactoryBean, just can complete actual database access.
In actual development process, usually can find that service layer is substantially the same with the interface of persistent layer, difference is exactly the control of the process that service layer has some service logics, affairs; The interface of persistent layer then the physical layer interface of direct invocation framenort can carry out database access, and these interfaces are substantially all the same processing logics: increase, delete, amendment, inquiry.Often realize a business, all need to call the similar function of identical Interface realization, produce the phenomenon that code repeats, this adds the workload of developer virtually.And developer needs to transform persistent object (PO) and value object (VO) frequently, not only wastes workload, and very consumes internal memory, influential system performance.
In decoupling zero, although achieved the injection of Bean by SpringIOC, seem to achieve low coupling, but in fact do not have, because the interface that persistent layer exposes is a lot, substantially each business can have a series of interface, if really need to adjust persistent layer, still need to revise a large amount of codes, that is, still there is the problem that coupling is high.
Herein, also there is the not easily unified problem of code specification in current usual way.Specifically, although the HQL language that Hibernate provides solves the problem of integration across database, Hibernate framework itself is all supported HQL and SQL, if not from the enterprising professional etiquette model of framework, be difficult to realize interface consistance, the upgrading of database replaced and also hides some dangers for.
Summary of the invention
In view of this, the invention provides a kind of method and apparatus of accessing database, contribute to improving system performance and development efficiency, contribute in addition solving interface specification sex chromosome mosaicism.
For achieving the above object, according to an aspect of the present invention, a kind of method of accessing database is provided.
The method of accessing database of the present invention comprises: the class object and the value mapping table that receive the common interface class of persistent layer; Described class object is by abstract for the persistent layer class object being a common interface class and obtaining; According to described class object acquired value object, and according to described value mapping table and described class object, this value object is carried out to the filling of father's entity; The value object completing described filling is converted to persistent object; Data in described persistent object are saved in database.
Alternatively, the step that the described value object completing described filling is converted to persistent object is comprised: for the value object completing described filling, adopt BeanUtils instrument to be converted into persistent object.
Alternatively, the step of carrying out the filling of father's entity described in comprises: the metadata information being obtained described class object by session factory; Check the type of each field of described class object, when the type of the present field be checked through is entity type, find entity corresponding to this present field according to the mapping relations in described value mapping table and external key, then this entity is filled in described value object.
Alternatively, when needs carry out database update operation, the method also comprises: the class object and the value mapping table that receive the common interface class of persistent layer; According to described value mapping table and described class object, the filling of father's entity is carried out to value object; Search the metadata information of described class object to obtain field name; Adopt HQLBulider tool-class, according to described value mapping table assembled go out HQL statement; Generate Query object according to described HQL statement, then use query.setParameter instrument that the parameter of described HQL statement is set, then perform described HQL statement to upgrade described database.
Alternatively, when needs carry out database query operations, the method also comprises: use the data in the list method acquisition database of Query object, these data undertaken packing then exporting by value mapping table and value table.
According to a further aspect in the invention, a kind of device of accessing database is provided.
The device of accessing database of the present invention comprises: receiver module, for receiving class object and the value mapping table of the common interface class of persistent layer; Described class object is by abstract for the persistent layer class object being a common interface class and obtaining; Obtain packing module, for according to described class object acquired value object, and according to described value mapping table and described class object, this value object is carried out to the filling of father's entity; Modular converter, for being converted to persistent object by the value object completing described filling; Preserve module, for the data in described persistent object being saved in database.
Alternatively, described modular converter also for for the value object completing described filling, adopts BeanUtils instrument to be converted into persistent object.
Alternatively, also comprise: acquisition module, for being obtained the metadata information of described class object by session factory; Check packing module, for checking the type of each field of described class object, when the type of the present field be checked through is entity type, find entity corresponding to this present field according to the mapping relations in described value mapping table and external key, then this entity is filled in described value object.
Alternatively, also comprise: packing module, for the value mapping table for more new database that receives according to described receiver module and class object, value object is carried out to the filling of father's entity; Search module, for searching the metadata information of described class object to obtain field name; Assembling module, for adopting HQLBulider tool-class, according to described value mapping table assembled go out HQL statement; Renewal rewards theory module, for generating Query object according to described HQL statement, then using query.setParameter instrument to arrange the parameter of described HQL statement, then performing described HQL statement to upgrade described database.
Alternatively, also comprising inquiry output module, for using the data in the list method acquisition database of Query object, these data being undertaken packing then exporting by value mapping table and value table.
According to technical scheme of the present invention, by the encapsulation to Hibernate, hidden by persistent layer, developer only need pay close attention to service logic, need not consider that persistent layer is developed, and does not also need the code copies carrying out repetition, substantially increases development efficiency.Also remain the native interface access of framework, the expansion for system provides more possibility simultaneously.By the encapsulation to PO, VO, the conversion process of the two is realized by framework, decrease the workload of developer, decrease memory cost, improve the performance of system.Persistent layer only exposes an interface to upper strata, only have a zinc plant engineering in the application, reduce the coupling between level, substantially increases extendability and the elasticity of system.All database manipulations are all come by HQL, on the one hand can compatible multiple database, ensure that the standardization of system on the other hand, also provide the access interface of SQL statement, the expansion facilitating system follow-up and maintenance simultaneously.
Accompanying drawing explanation
Accompanying drawing is used for understanding the present invention better, does not form inappropriate limitation of the present invention.Wherein:
Fig. 1 is the core classes figure for realizing the traversal to result mapping table;
Fig. 2 is schematic diagram database being carried out to the basic step of preservation operation according to embodiment of the present invention;
Fig. 3 is schematic diagram database being carried out to the basic step of renewal rewards theory according to embodiment of the present invention;
Fig. 4 is the schematic diagram preserving a kind of idiographic flow of operation according to the performing database of embodiment of the present invention;
Fig. 5 is the schematic diagram of a kind of idiographic flow of performing database renewal rewards theory according to embodiment of the present invention;
Fig. 6 is the core classes figure for fulfillment database query manipulation according to embodiment of the present invention;
Fig. 7 is the schematic diagram realizing the idiographic flow of HQLUtil example according to embodiment of the present invention;
Fig. 8 is the particular flow sheet according to the additional character string of embodiment of the present invention and the method for parameter;
Fig. 9 is the schematic diagram of the idiographic flow based on the assembled tool-class processing costs of the HQL in embodiment of the present invention object;
Figure 10 is the class figure about service layer's interface according to embodiment of the present invention;
Figure 11 is the schematic diagram of the main modular of the device of accessing database according to embodiment of the present invention.
Embodiment
Below in conjunction with accompanying drawing, exemplary embodiment of the present invention is explained, comprising the various details of embodiment of the present invention to help understanding, they should be thought it is only exemplary.Therefore, those of ordinary skill in the art will be appreciated that, can make various change and amendment, and can not deviate from scope and spirit of the present invention to embodiment described herein.Equally, for clarity and conciseness, the description to known function and structure is eliminated in following description.
In embodiments of the present invention, encapsulate to improve system performance to PO, VO with the form of Map.Hibernate is the table be mapped to by entity class in data, defines a parent BaseObject in embodiments of the present invention, and the object inheriting such all wants the table in correspondence database, conversely, and each table correspondence entity class in database.Adopted value mapping table (ValueMap) encapsulates VO, completes the extraction of form data and is converted into VO, be i.e. ValueMap by view layer; Result mapping table (ResultMap) is adopted to encapsulate PO, persistent layer is after getting VO, first can carry out the filling of father's entity to VO according to the entity mapping relations of Hibernate, this mainly tackles the situation of one-to-many (OneToMany) and many-one (ManyToOne), and then VO is converted into PO, last performing database operation, this process is realized by Persistence Layer Framework completely, and developer does not need to pay close attention to; ResultMap needs get (Objectkey) method rewriteeing Map, is used for from returning results middle value.ResultList and ResultIterator realizes List and Iterator interface respectively, and in order to realize the traversal to ResultMap, core classes figure as shown in Figure 1.Fig. 1 is the core classes figure for realizing the traversal to result mapping table.
In order to improve development efficiency, in embodiments of the present invention, Hibernate being encapsulated, being packaged into general more new interface and query interface.More new interface comprises increase to object, deletion, amendment; Query interface can be inquired about by single object, set, paging result set.By abstract for persistent layer be an interface to serve upper layers, be injected into Service layer by SpringIOC.Specifically, persistent layer is abstracted into a common interface IRePOsitory, such is initialize session factory (SessionFactory) when system starts, this class only has a zinc plant engineering in Web application, top service completes the inquiry of persistent layer by the example of this case-based system CommonUpdate and CommonQuery and additions and deletions change, all operations have been come by HQL, CommonUpdate remains the traditional PO access interface of persistent layer, facilitate subsequent expansion, CommonNativeUpdate and CommonNativeQuery is with the formal operations database of SQL statement, these two interfaces are mainly for particular service is prepared, such as statistical study, general business can not use this two interfaces.Persistent layer interface is mainly by the Query Interface realization database manipulation of Hibernate, preservation is operated, persistent layer can adopt the flow process shown in Fig. 2 to carry out, and Fig. 2 is schematic diagram database being carried out to the basic step of preservation operation according to embodiment of the present invention.
Step S21: the class object and the value mapping table that receive the common interface class of persistent layer.Here class object is by abstract for the persistent layer class object being a common interface class and obtaining.
Step S22: according to above-mentioned class object acquired value object, and according to above-mentioned value mapping table and above-mentioned class object, this value object is carried out to the filling of father's entity.
Step S23: the value object completing above-mentioned filling is converted to persistent object.Here BeanUtils instrument can be adopted to carry out the conversion of VO/PO.
Step S24: the data in above-mentioned persistent object are saved in database.
In above-mentioned steps, value mapping table is provided by developer, imports persistent layer interface into the form of Map, and the conversion of VO and PO has then been come by persistent layer after carrying out the filling of father's entity, and developer does not need to pay close attention to, and improves development efficiency; And this approach reduces calculator memory expense, improve system performance.
When needs carry out database update operation, can come by the step shown in Fig. 3.Fig. 3 is schematic diagram database being carried out to the basic step of renewal rewards theory according to embodiment of the present invention.
Step S31: the class object and the value mapping table that receive the common interface class of persistent layer.
Step S32: the filling of father's entity is carried out to value object according to above-mentioned value mapping table and above-mentioned class object.
Step S33: search the metadata information of above-mentioned class object to obtain field name.
Step S34: adopt HQLBulider tool-class, according to above-mentioned value mapping table assembled go out HQL statement.
Step S35: generate Query object according to above-mentioned HQL statement.
Step S36: use query.setParameter instrument that the parameter of above-mentioned HQL statement is set.
Step S37: perform above-mentioned HQL statement with more new database.
Encapsulation below in conjunction with Hibernate further illustrates specific implementation of the present invention.In embodiments of the present invention, persistent layer interface is by the Query Interface realization database manipulation of Hibernate, preservation is operated, business end needs to import class object and valueMap into, first persistent layer obtains VO by class object, then by valueMap and class object, the filling of father's entity is carried out to this VO, the process of filling father's entity is the metadata information first being obtained class object by sessionFactory, then the type of each field of class object is checked, if type is entity type, this entity is found according to mapping relations and external key, and be filled in VO, then the conversion of VO and PO is realized by BeanUtils, realize preserving finally by session.save.As shown in Figure 4, Fig. 4 is the schematic diagram preserving a kind of idiographic flow of operation according to the performing database of embodiment of the present invention to above process.
For renewal rewards theory, persistent layer is also father's entity object of first filling VO, then the metadata information of class is searched to obtain field name, assembled hql statement is carried out in conjunction with valueMap by HQLBuilder tool-class, the hql statement generated generates Query object by createQuery (), and carry out parameters by query.setParameter, finally realize renewal rewards theory by executeUpdate, persistent layer also supports the renewal statement of hql, idiographic flow as shown in Figure 5, Fig. 5 is the schematic diagram of a kind of idiographic flow of performing database renewal rewards theory according to embodiment of the present invention.
For deletion action, directly can be deleted by HQL statement, bottom layer realization is also call Query interface; Also can carry out delete entity according to some fields of entity class, need by HQLBuilder and carry out assembled HQL statement in conjunction with VO.
Query manipulation is realized by the list method of Query, and the result obtained is packed by ResultMap and ResultList, returns to foreground and use; Show to realize foreground paging, can encapsulate a paging class Page, such essential record total number of records, every page of size, reference position, foreground is shown can carry out paging according to these attributes.As shown in Figure 6, Fig. 6 is the core classes figure for fulfillment database query manipulation according to embodiment of the present invention to core classes figure.
In embodiments of the present invention, in order to solve interface specification sex chromosome mosaicism, the unified mode of HQL that adopts of the interface of persistent layer encapsulation externally provides service; The tool-class that the assembled employing of HQL is general processes.Be described for realizing the assembled tool-class of HQL below.In embodiments of the present invention, realize the tool-class HQLUtil of fluent style, such main indirect activities layer and persistent layer realize the dynamically assembled of HQL statement, and are arranged parameter by VO, and core methed and the attribute of HQLUtil are as shown in table 1.
Table 1
Parameters parameter stores the parameter value of vo with the form of map, and newInstance () method is used for acquisition HQLUtil example; Append (Stringsubhql) is used for additional HQL clause.
AppendUpdateSet (Stringalias, MapupdateMap) method is used for increasing the set clause of Update statement, and operation layer false code is as follows:
……
HQLUtilhqlbuild=HQLUtil.newInstance();
Hqlbuild.append(“updateModel1m1”).appendUpdateSet(“m1”,values);
Hqlbuild.append(“where”);
Hqlbuild.appendWhere(“m1.pkId=:pkId”,“pkId”,pkid);
……
AppendUpdateSet method inside can travel through updateMap, then assembled update statement is started by HQLUtil, and by the optimum configurations in updateMap in parameters, finally return this example, as shown in Figure 7, Fig. 7 is the schematic diagram realizing the idiographic flow of HQLUtil example according to embodiment of the present invention to flow process.
AppendUpdate (Stringalias, Stringkey, Objectval) increase Update statement row upgrade clause, the method upgrades concrete row, idiographic flow and appendUpdateSet method similar.AppendWhere (Stringsubwhere, Stringkey, Objectval) adds character string and parameter, and use in dynamic queries, operation layer false code is as follows:
……
hqlbuild.append(“updateModel1m1setm1.attrkey=attrvalwhere”);
hqlbuild.appendWhere(“m1.attrey2:attrval2”,“attrval2”attrval2);
……
……
hqlbuild.append(“fromModel2m2,Model3m3where”);
hqlbuild.appendWhere(“m2.pkid=:pkid”,“pkid”,pkid);
hqlbuild.append(“andm2.foreginId=m3.pkid”);
……
First appendWhere method judges whether val is empty, it is not empty just additional sub-hql statement, and VO parameter is set in parameters, if be empty, for delete operation and update operation, need parameter corresponding for paramKey to replace with " isnull ", as shown in Figure 8, Fig. 8 is the particular flow sheet according to the additional character string of embodiment of the present invention and the method for parameter to idiographic flow.
SetParameter method and fillQuery method are private methods, and the parameter in VO is packaged into map by the former; FillQuery method creates query object according to assembled good hql statement, and replaces the parameter in hql by parameters, finally returns the operation of query object performing database.
If that operation layer imports into is VO, first persistent layer obtains HQLUtil example, and obtain field name according to class object, then traveling through VO, to carry out hql assembled, and the parameter of replacing in hql, last performing database operation, as shown in Figure 9, Fig. 9 is the schematic diagram of the idiographic flow based on the assembled tool-class processing costs of the HQL in embodiment of the present invention object to process flow diagram.
Below the abstract service layer interface in embodiment of the present invention is illustrated.In embodiments of the present invention, the top layer parent interface Service of a service layer is built; Need the parent interface of accessing persistent layer to be RepositoryService, any service class of accessing persistent layer that needs all needs to realize this interface, does not then need for the service of not accessing persistent layer.IRepository is injected by SpringIOC by this interface.As shown in Figure 10, Figure 10 is the class figure about service layer's interface according to embodiment of the present invention to class figure.
Figure 11 is the schematic diagram of the main modular of the device of accessing database according to embodiment of the present invention.As shown in figure 11, persistent layer is as a kind of device 110 of accessing database, and it mainly comprises receiver module 111, acquisition packing module 112, modular converter 113, preserves module 114.
Receiver module 111 is for receiving class object and the value mapping table of the common interface class of persistent layer; Described class object is by abstract for the persistent layer class object being a common interface class and obtaining; Obtain packing module 112 for according to described class object acquired value object, and according to described value mapping table and described class object, this value object is carried out to the filling of father's entity; Modular converter 113 is for being converted to persistent object by the value object completing described filling; Preserve module 114 for the data in described persistent object being saved in database.
The device 110 of accessing database can also comprise acquisition module and check packing module (not shown), and wherein acquisition module, for obtaining the metadata information of described class object by session factory; Check packing module, for checking the type of each field of described class object, when the type of the present field be checked through is entity type, find entity corresponding to this present field according to the mapping relations in described value mapping table and external key, then this entity is filled in described value object.
The device 110 of accessing database can also comprise packing module, searches module, assembling module and renewal rewards theory module (not shown), wherein packing module is used for the value mapping table for more new database that receives according to described receiver module and class object, value object is carried out to the filling of father's entity; Search module for searching the metadata information of described class object to obtain field name; Assembling module for adopting HQLBulider tool-class, according to described value mapping table assembled go out HQL statement; Renewal rewards theory module is used for generating Query object according to described HQL statement, then uses query.setParameter instrument to arrange the parameter of described HQL statement, then performs described HQL statement to upgrade described database.
The device 110 of accessing database also can comprise inquiry output module (not shown), for using the data in the list method acquisition database of Query object, these data is undertaken packing then exporting by value mapping table and value table.
Beneficial effect of the present invention is as follows:
By the encapsulation to Hibernate, hidden by persistent layer, developer only need pay close attention to service logic, need not consider that persistent layer is developed, and does not also need the code copies carrying out repetition, substantially increases development efficiency.Also remain the native interface access of framework, the expansion for system provides more possibility simultaneously.
By the encapsulation to PO, VO, the conversion process of the two is realized by framework, decrease the workload of developer, decrease memory cost, improve the performance of system.
Persistent layer only exposes an interface to upper strata, only have a zinc plant engineering in the application, reduce the coupling between level, substantially increases extendability and the elasticity of system.
All database manipulations are all come by HQL, on the one hand can compatible multiple database, ensure that the standardization of system on the other hand, also provide the access interface of SQL statement, the expansion facilitating system follow-up and maintenance simultaneously.
Above-mentioned embodiment, does not form limiting the scope of the invention.It is to be understood that depend on designing requirement and other factors, various amendment, combination, sub-portfolio can be there is and substitute in those skilled in the art.Any amendment done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within scope.

Claims (10)

1. a method for accessing database, is characterized in that, comprising:
Receive class object and the value mapping table of the common interface class of persistent layer; Described class object is by abstract for the persistent layer class object being a common interface class and obtaining;
According to described class object acquired value object, and according to described value mapping table and described class object, this value object is carried out to the filling of father's entity;
The value object completing described filling is converted to persistent object;
Data in described persistent object are saved in database.
2. the method for accessing database according to claim 1, is characterized in that, the step that the value object completing described filling is converted to persistent object is comprised: for the value object completing described filling, adopts BeanUtils instrument to be converted into persistent object.
3. the method for accessing database according to claim 1 and 2, is characterized in that, described in carry out the filling of father's entity step comprise:
The metadata information of described class object is obtained by session factory;
Check the type of each field of described class object, when the type of the present field be checked through is entity type, find entity corresponding to this present field according to the mapping relations in described value mapping table and external key, then this entity is filled in described value object.
4. the method for accessing database according to claim 1, is characterized in that, when needs carry out database update operation, the method also comprises:
Receive class object and the value mapping table of the common interface class of persistent layer;
According to described value mapping table and described class object, the filling of father's entity is carried out to value object;
Search the metadata information of described class object to obtain field name;
Adopt HQLBulider tool-class, according to described value mapping table assembled go out HQL statement;
Generate Query object according to described HQL statement, then use query.setParameter instrument that the parameter of described HQL statement is set, then perform described HQL statement to upgrade described database.
5. the method for accessing database according to claim 1, is characterized in that, when needs carry out database query operations, the method also comprises:
Use the data in the list method acquisition database of Query object, these data are undertaken packing then exporting by value mapping table and value table.
6. a device for accessing database, is characterized in that, comprising:
Receiver module, for receiving class object and the value mapping table of the common interface class of persistent layer; Described class object is by abstract for the persistent layer class object being a common interface class and obtaining;
Obtain packing module, for according to described class object acquired value object, and according to described value mapping table and described class object, this value object is carried out to the filling of father's entity;
Modular converter, for being converted to persistent object by the value object completing described filling;
Preserve module, for the data in described persistent object being saved in database.
7. the device of accessing database according to claim 6, is characterized in that, described modular converter also for for the value object completing described filling, adopts BeanUtils instrument to be converted into persistent object.
8. the device of the accessing database according to claim 6 or 7, is characterized in that, also comprises:
Acquisition module, for obtaining the metadata information of described class object by session factory;
Check packing module, for checking the type of each field of described class object, when the type of the present field be checked through is entity type, find entity corresponding to this present field according to the mapping relations in described value mapping table and external key, then this entity is filled in described value object.
9. the device of accessing database according to claim 6, is characterized in that, also comprises:
Packing module, for the value mapping table for more new database that receives according to described receiver module and class object, carries out the filling of father's entity to value object;
Search module, for searching the metadata information of described class object to obtain field name;
Assembling module, for adopting HQLBulider tool-class, according to described value mapping table assembled go out HQL statement;
Renewal rewards theory module, for generating Query object according to described HQL statement, then using query.setParameter instrument to arrange the parameter of described HQL statement, then performing described HQL statement to upgrade described database.
10. the device of accessing database according to claim 6, is characterized in that, also comprises inquiry output module, for using the data in the list method acquisition database of Query object, these data is undertaken packing then exporting by value mapping table and value table.
CN201510528428.8A 2015-08-25 2015-08-25 The method and apparatus for accessing database Active CN105205103B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510528428.8A CN105205103B (en) 2015-08-25 2015-08-25 The method and apparatus for accessing database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510528428.8A CN105205103B (en) 2015-08-25 2015-08-25 The method and apparatus for accessing database

Publications (2)

Publication Number Publication Date
CN105205103A true CN105205103A (en) 2015-12-30
CN105205103B CN105205103B (en) 2019-09-20

Family

ID=54952787

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510528428.8A Active CN105205103B (en) 2015-08-25 2015-08-25 The method and apparatus for accessing database

Country Status (1)

Country Link
CN (1) CN105205103B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107506189A (en) * 2017-08-15 2017-12-22 四川长虹电器股份有限公司 A kind of iOS data persistence methods realized based on factory mode
CN109213789A (en) * 2017-07-07 2019-01-15 北京京东尚科信息技术有限公司 A kind of analysis method and device about business SQL
CN110019287A (en) * 2017-07-20 2019-07-16 华为技术有限公司 The method and apparatus for executing structured query language SQL instruction
CN111506303A (en) * 2019-01-30 2020-08-07 北大方正信息产业集团有限公司 Data interaction method and device
CN115495398A (en) * 2022-09-28 2022-12-20 北京亚控科技发展有限公司 Interface resource operation method and device, electronic equipment, storage medium and product

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101290625A (en) * 2008-06-11 2008-10-22 华东师范大学 XML document storage and search method
CN101901140A (en) * 2009-05-27 2010-12-01 北京正辰科技发展有限责任公司 System global structure of enterprise-level application development platform
CN101996071A (en) * 2009-08-20 2011-03-30 上海杉达学院 Software architecture of information control system and architecting method
CN102004741A (en) * 2009-09-01 2011-04-06 上海杉达学院 Database access system
CN102004634A (en) * 2009-09-01 2011-04-06 上海杉达学院 Hierarchical business management system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101290625A (en) * 2008-06-11 2008-10-22 华东师范大学 XML document storage and search method
CN101901140A (en) * 2009-05-27 2010-12-01 北京正辰科技发展有限责任公司 System global structure of enterprise-level application development platform
CN101996071A (en) * 2009-08-20 2011-03-30 上海杉达学院 Software architecture of information control system and architecting method
CN102004741A (en) * 2009-09-01 2011-04-06 上海杉达学院 Database access system
CN102004634A (en) * 2009-09-01 2011-04-06 上海杉达学院 Hierarchical business management system

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
PURSURE211: "Hibernate三种继承关系", 《HTTP://BLOG.CSDN.NET/PURSURE211/ARTICLE/DETAILS/17318379》 *
RIGGER21: "hibernate hql 大全", 《HTTP://BLOG.CSDN.NET/RIGGER21/ARTICLE/DETAILS/1733821》 *
RIGGER21: "hibernatehql大全", 《HTTP://BLOG.CSDN.NET/RIGGER21/ARTICLE/DETAILS/1733821》 *
XW13106209: "Hibernate之Configuration,SessionFactory,Session", 《HTTP://BLOG.CSDN.NET/XW13106209/ARTICLE/DETAILS/7041483》 *
刘洋: "《精通Hibernate》", 31 May 2005 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109213789A (en) * 2017-07-07 2019-01-15 北京京东尚科信息技术有限公司 A kind of analysis method and device about business SQL
CN110019287A (en) * 2017-07-20 2019-07-16 华为技术有限公司 The method and apparatus for executing structured query language SQL instruction
CN110019287B (en) * 2017-07-20 2021-09-14 华为技术有限公司 Method and device for executing Structured Query Language (SQL) instruction
CN107506189A (en) * 2017-08-15 2017-12-22 四川长虹电器股份有限公司 A kind of iOS data persistence methods realized based on factory mode
CN111506303A (en) * 2019-01-30 2020-08-07 北大方正信息产业集团有限公司 Data interaction method and device
CN115495398A (en) * 2022-09-28 2022-12-20 北京亚控科技发展有限公司 Interface resource operation method and device, electronic equipment, storage medium and product
CN115495398B (en) * 2022-09-28 2023-06-30 北京亚控科技发展有限公司 Interface resource operation method, device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN105205103B (en) 2019-09-20

Similar Documents

Publication Publication Date Title
US10831753B2 (en) Query plan generation and execution in a relational database management system with a temporal-relational database
CN107402988B (en) Distributed NewSQL database system and semi-structured data query method
US10853351B2 (en) Logless atomic data movement
US20220179876A1 (en) Metadata hub for metadata models of database objects
Carey et al. Data-Centric Systems and Applications
CN104160394B (en) Scalable analysis platform for semi-structured data
CA2813895C (en) Unified table query processing
US6611838B1 (en) Metadata exchange
CN100565510C (en) Data access layer class generator
US8838654B1 (en) Data modeling system for runtime schema extensibility
CN110837492B (en) Method for providing data service by multi-source data unified SQL
US9507820B1 (en) Data modeling system for runtime schema extensibility
US20090144319A1 (en) External system integration into automated attribute discovery
US20140067792A1 (en) Apparatus and Method for Operating a Distributed Database with Foreign Tables
CN105205103A (en) Method and device for accessing database
US20040181538A1 (en) Model definition schema
US20110087708A1 (en) Business object based operational reporting and analysis
KR20060045622A (en) Extraction, transformation and loading designer module of a computerized financial system
CN104123374A (en) Method and device for aggregate query in distributed databases
CN104205039A (en) Interest-driven business intelligence systems and methods of data analysis using interest-driven data pipelines
US20110093487A1 (en) Data provider with transient universe
US20010037228A1 (en) System and method for using metadata to flexibly analyze data
CN103559189A (en) Power simulation training resource management system and method based on metadata integration model
CN107291471A (en) A kind of Meta model framework system for supporting customizable data acquisition
US20100088685A1 (en) System and method for mapping a domain modeling language to a relational store

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant