WO2020232569A1 - 一种数据库操作层表示方法及装置 - Google Patents

一种数据库操作层表示方法及装置 Download PDF

Info

Publication number
WO2020232569A1
WO2020232569A1 PCT/CN2019/087386 CN2019087386W WO2020232569A1 WO 2020232569 A1 WO2020232569 A1 WO 2020232569A1 CN 2019087386 W CN2019087386 W CN 2019087386W WO 2020232569 A1 WO2020232569 A1 WO 2020232569A1
Authority
WO
WIPO (PCT)
Prior art keywords
class
entity
type
operation layer
classes
Prior art date
Application number
PCT/CN2019/087386
Other languages
English (en)
French (fr)
Inventor
张卫平
徐国庆
Original Assignee
环球雅途集团有限公司
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 环球雅途集团有限公司 filed Critical 环球雅途集团有限公司
Priority to PCT/CN2019/087386 priority Critical patent/WO2020232569A1/zh
Priority to CN201980096445.5A priority patent/CN114096956A/zh
Publication of WO2020232569A1 publication Critical patent/WO2020232569A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • the invention relates to the field of database technology, in particular to a method and device for representing database operation layers.
  • DAO data operation
  • JPA/ORM Commonly used representations of entity classes/objects are JPA/ORM.
  • ORM object-relational mapping, which associates objects with database tables, and specifies the correspondence between entity objects and tables, entity object attributes, and table columns.
  • JPA provides the specification of relational mapping, but does not provide its implementation; the entity object refers to the object that corresponds to the table in the database and represents the table in the database. It is the association bridge between the class and the table.
  • MyBatis configures the methods in ORM and DAO through SQL templates, which belong to the type of addition, deletion, modification and inspection (CUID), SQL statements, return object types, and ORM is only used for object return assembly.
  • CUID addition, deletion, modification and inspection
  • MyBatis relatively increases business flexibility and code comprehensibility, because developers can freely define DAO layer operation methods and correspond to SQL templates; the disadvantages are: 1.
  • MyBatis ORM only works when the DAO layer method returns data In ORM, the program cannot simply add, delete, modify and check tables through entity classes/objects. Each method of MyBatis needs to write SQL code in the template. 2.
  • MyBatis cannot be reused, which affects maintainability.
  • the technical problem to be solved by the present invention is that the prior art cannot have the characteristics of high reusability and strong code flexibility, and the code is a problem of poor maintainability.
  • the present invention aims to solve the above problems, and provides a database operation layer representation method and device with high code flexibility and strong reusability.
  • the technical solution adopted in this application is to provide a database operation layer representation method, which includes: configuring the mapping relationship of entity classes, specifying the mapping relationship between entity classes and tables; The method recognizes the type of the incoming parameter through configuration, extracts the SQL statement of the method from the template according to the type of the passed parameter or configuration, generates a dynamic SQL statement, or takes out the SQL statement of the method to further generate the required dynamic SQL statement; Execute the SQL statement to obtain the desired result; according to the parameters passed in or the configuration in the template, the generated result is assembled into the required class object and returned.
  • a database operating device which includes: an operating layer, including methods of operating layer classes and operating layer classes.
  • the methods of operating layer classes are specified by configuration.
  • the input parameter type including entity class and/or entity object and/or primary key and/or SQL statement and/or paging information. If there is an entity class in the parameter, the entity class will analyze the JPA mapping relationship between it and the table on behalf of it ;
  • Implementation framework including the startup and operation mechanism of the MyBatis framework itself and MyBatis plug-ins; Entity classes, used to define the ORM mapping relationship between entity classes and tables; SQL templates, used to implement data addition, deletion, modification, and flexible configuration.
  • the technical solution adopted in this application is to provide a database entity class configuration method, which includes: binding attributes when configuring the column attributes of the entity class/column null value checking when adding, deleting or modifying, If the check is null, the corresponding operation is triggered, otherwise no operation.
  • the technical solution adopted in this application is to provide a method for generating column attributes.
  • the method includes: stipulating that the column attribute generation is selected by the first candidate, and the second candidate selects until the first several candidates. Generate alternative composition, if the first generation fails, the column attribute value is obtained through the second alternative generation.
  • the device includes: declaring the caching strategy of the class in the configuration of the entity class.
  • the caching strategy of the class includes whole-table memory caching and whole-table external storage. Cache, no cache, memory cache means that the entire table is stored in memory, and external cache means that it is cached in other programs or devices according to the elimination strategy.
  • the technical solution adopted in this application is to provide a MyBatis database caching device.
  • the device includes: configuring the caching strategy in the entity class as memory caching, entire table external storage caching, and no caching.
  • the entity class is preferentially used. Cache and external cache, if the entity class is not configured with cache, the MyBatis cache mechanism is used according to the generated SQL statement.
  • the system is both easy to develop and reusable, and MyBatis's feature of flexible configuration of SQL is retained for complex business logic.
  • FIG. 1 is a schematic flowchart of a method for representing a database operation layer in an embodiment of the present invention.
  • FIG. 1 is a schematic flowchart of a method for representing a database operation layer according to an embodiment of the present invention. The process of the method is described in detail as follows:
  • Step S01 Configure the mapping relationship of the entity class, and specify the mapping relationship between the entity class and the table.
  • entity classes or entity objects can be used as the parameter types passed in by the operation layer, but the passed parameter types are not limited to the above two types.
  • Step S02 The method of the class of the operation layer recognizes the type of parameter passed in through configuration, extracts the SQL statement of the method from the template according to the type of the passed parameter or configuration, generates a dynamic SQL statement, or takes out the SQL statement of the method and then further Generate the required dynamic SQL statements;
  • the classes of the operation layer include basic classes and extended classes.
  • the basic classes implement the standard methods of JPA basic operation classes, and add, delete, modify and check data by passing in parameters such as entity classes, primary keys, entity objects, SQL, and query conditions.
  • the extension class extends the realization of the basic operation class of Mybatis to realize reuse.
  • Step S03 Execute the SQL statement to obtain the desired result.
  • the return type is directly determined by the operation layer parameter type designation, the SQL template designation or the method return type.
  • the method return value determines the return type first. If the return type cannot be determined from the method return value, the specified type takes precedence. If the type is not specified, Return by the type specified by the template, otherwise return a collection of key-value pairs.
  • Step S04 According to the input parameters or the configuration in the template, the generated result is assembled into the required class object and returned.
  • specific reserved words can be specified in the operation layer method to indicate the object type required by JPA.
  • the framework recognizes the object type represented by the reserved words from the configuration of the operation layer method, thereby realizing JPA Conversion.
  • a reserved word can be specified to specify the type of object returned by the operation, and the query result is converted to the returned object type according to the JPA mapping, thereby realizing dynamic conversion of the result.
  • the operating layer framework knows the type of the parameter passed in through reserved words.
  • the reserved words include: class reserved words, entity object reserved words, id primary key reserved words, dynamically incoming SQL reserved words, SQL additional parameter reserved words, Return type reserved words, reserved words meeting query conditions, reserved words for query or modification, reserved words for paging information.
  • a paging statement can be further generated according to the generated SQL statement.
  • the conditions of the SQL statement are written into the MyBatis environment according to the JPA specification when the SQL statement is generated.
  • the result parameter is returned according to the data access layer operation, and the ORM is modified when returning. If the data access layer returns a column, the passed parameter is used as the return value mapping.
  • the ORM mechanism is used to mark the table name of each object and the relationship between the objects to perform object association mapping, reuse operation classes, add, delete, modify, check, and add on object associations. , Batch deletion, correction, and paging method.
  • the JPA mechanism is used in the MyBatis framework to make up for the defects of MyBatis's reusability and runtime query statements.
  • the system is easy to develop and reusable, and SQL can be flexibly configured.
  • the embodiment of the present invention also provides a database operation device, which includes: an operation layer, an implementation framework, an entity class, and a SQL template.
  • the operation layer includes classes and methods of the classes of the operation layer.
  • the methods of the classes of the operation layer are configured to specify the type of parameters passed in, including entity classes and/or entity objects and/or primary keys and/or SQL statements and/or paging information. If there is an entity class in the parameter, the entity class resolves the JPA mapping relationship between it and the table on behalf of it.
  • the class of the operation layer is the operation class
  • the method of the class of the operation layer is the method of the operation layer.
  • Implementation framework including the startup and operation mechanism of the MyBatis framework itself and the MyBatis plug-in.
  • Mybatis plug-in mechanism to intercept Mybatis data access layer operations, and convert the incoming parameters to SQL according to the specific addition, deletion, and modification operations of the basic class, and return the correct results to achieve the Mybatis data access layer data operation class similar to hibernate JPA and ORM functions.
  • the entity class is used to define the ORM mapping relationship between the entity class and the table.
  • SQL template is used to add, delete, modify, check and configure data flexibly.
  • the device specifies entity classes, entity objects, primary keys, returned or modified fields or attributes, and other query conditions. If the template SQL corresponding to the basic class or method is empty, these attributes are intercepted by the MyBatis plugin , To achieve the framework generation statement.
  • the device specifies paging, total number of entries, and maximum value as parameter types. These attributes are intercepted by the MyBatis plug-in, so that the framework regenerates paging statements, total number of queries, and maximum values based on templates or generated statements. Statement.
  • the specified return type is used as the parameter type, and the attribute is intercepted by the MyBatis plug-in. After executing the query, JPA mapping is performed according to the specified data type to assemble the return value.
  • the embodiment of the present invention also provides a database entity class configuration method.
  • the null value check when the column attribute is added, deleted or modified is bound. If the check is a null value, the corresponding operation is triggered; otherwise, no operating.
  • the operations triggered by the null value include: generating column attributes, throwing errors, printing messages, and ignoring.
  • the embodiment of the present invention also provides a column attribute generation method, which stipulates that the column attribute generation consists of the first generation option, the second option generation option, and the second option generation option until the first generation option. If the first generation fails, then pass The second alternative is generated to obtain column attribute values.
  • a generation option includes a number of generation sequences, and the generation selection is formed by concatenating these generation sequences in the sequence of generation.
  • the generation order rules of the generation order include: constants and/or variables, classes and methods, objects and methods.
  • the embodiment of the present invention also provides a caching mechanism.
  • the caching strategy of the class is declared in the configuration of the entity class.
  • the caching strategy of the class includes the entire table memory cache, the entire table external storage cache, and no cache.
  • the memory cache means that the entire table exists in memory. Chinese and foreign caches are cached in other programs or devices according to the elimination strategy.
  • the embodiment of the present invention also provides a MyBatis database caching device.
  • the caching strategy is configured in the entity class as memory caching, entire table external storage caching and no caching.
  • the entity class internal caching and external caching are preferentially used. If the entity class is not configured with caching, The MyBatis caching mechanism is used according to the generated SQL statement.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据库操作层表示方法及装置,该方法包括:对实体类进行映射关系配置,指定实体类和表之间的映射关系;操作层的类的方法通过配置识别传入的参数类型,根据传入的参数类型或配置从模板中取出该方法的SQL语句、生成动态的SQL语句或取出该方法的SQL语句后进一步生成所需的动态SQL语句;执行SQL语句获得所需的结果;根据传入的参数或模板中的配置,将生成的结果组装成所需的类对象并返回。上述方法通过在MyBatis框架中使用JPA机制弥补MyBatis复用性缺陷以及运行时查询语句的缺陷,使得系统既具有易开发性和复用性,又针对复杂的业务逻辑保留了Mybatis灵活配置SQL的特性。

Description

一种数据库操作层表示方法及装置 技术领域
本发明涉及数据库技术领域,特别是一种数据库操作层表示方法及装置。
背景技术
在数据操作(DAO)层的需求是通过数据操作类DAO操作实体类/对象或SQL语句。
实体类/对象的常用表示方式有JPA/ORM方式,所谓ORM就是对象关系映射,将对象和数据库的表关联起来,指定实体对象和表之间、实体对象属性和和表列之间的对应关系,JPA提供关系映射的规范,但是不提供其实现方式;实体对象指和数据库中的表对应并且表示数据库中该表的对象,它是类和表的关联桥梁。
当前实现ORM的主流框架有很多,但不外乎有两种实现方式,较早期的框架包括hibernate、castor等都是提供基础(数据操作)类去操作数据库,该类包含有限个对实体类和对象的增删改查的方法,以及有限几个通过传入SQL语句进行增删改的方法,在程序中要操作数据库就只能通过调用该基础类的这几个方法去实现,这样的好处是代码复用性高,但是缺点在于:1、代码灵活性差,需求千变万化,有时候调用这几个方法不是很方便;2、如果碰到复杂业务场景需要复杂的SQL语句,那么语句的拼接是在代码中用硬编码完成的,这些硬编码难以看懂,可维护性差。
另一种实现方式就是MyBatis的实现,它通过SQL模板配置了ORM及DAO中的方法属于增删改查(CUID)的类型,SQL语句,返回对象类型,ORM只用于对象返回式的组装。MyBatis相对地增加了业务灵活性和代码的易理解性,因为开发人员可以随意地定义DAO层操作方法,并且对应上SQL模板;缺点是:1、MyBatis方式的ORM只在DAO层方法返回数据时做ORM,程序没法通过实体类/对象对表进行简洁的增删改查,MyBatis每个方法都需要在模板中写SQL代码,2、MyBatis没法复用,影响了维护性。
技术问题
 本发明要解决的技术问题是现有技术无法兼具复用性高和代码灵活性强的特点且代码为维护性差的问题。
技术解决方案
本发明旨在解决上述问题,而提供一种代码灵活性高、复用性强的数据库操作层表示方法及装置。
为解决上述技术问题,本申请采用的技术方案是提供一种数据库操作层表示方法,该方法包括:对实体类进行映射关系配置,指定实体类和表之间的映射关系;操作层的类的方法通过配置识别传入的参数类型,根据传入的参数类型或配置从模板中取出该方法的SQL语句、生成动态的SQL语句或取出该方法的SQL语句后进一步生成所需的动态SQL语句;执行SQL语句获得所需的结果;根据传入的参数或模板中的配置,将生成的结果组装成所需的类对象并返回。
为解决上述技术问题,本申请采用的技术方案是提供一种数据库操作装置,该装置包括:操作层,包括操作层的类和操作层的类的方法,操作层的类的方法通过配置指定传入的参数类型,包括实体类和/或实体对象和/或主键和/或SQL语句和/或分页信息,如果参数中有实体类,则实体类代表其解析其与表之间的JPA映射关系; 实现框架,包括MyBatis框架本身的启动和运转机制以及MyBatis插件; 实体类,用于定义实体类和表之间的ORM映射关系; SQL模板,用于实现对数据的增删改查及灵活配置。
为解决上述技术问题,本申请采用的技术方案是提供一种数据库实体类配置方法,该方法包括:配置实体类的列属性时绑定属性/列在增加、删除或修改时的空值检查,如果检查为空值则触发相应的操作否则不操作。
为解决上述技术问题,本申请采用的技术方案是提供一种列属性生成方法,该方法包括:规定其列属性生成由第一生成择案、第二备选生择案成直到第若干备选生成择案组成,如果第一生成失败则通过第二备选生成得到列属性值。
为解决上述技术问题,本申请采用的技术方案是提供一种缓存机制,该装置包括:在实体类的配置中声明该类的缓存策略,类的缓存策略包括整表内存缓存、整表外存缓存、不缓存,内存缓存就是全表存在内存中,外缓存就是通过按淘汰策略缓存在其他程序或设备。
为解决上述技术问题,本申请采用的技术方案是提供一种MyBatis数据库缓存装置,该装置包括:在实体类中配置缓存策略为内存缓存、整表外存缓存和不缓存,优先使用实体类内缓存和外缓存,如果实体类没有配置缓存,则根据生成的SQL语句使用MyBatis的缓存机制。
有益效果
通过在MyBatis框架中使用JPA机制弥补MyBatis复用性缺陷以及运行时查询语句的缺陷,使得系统兼具易开发性和复用性,又针对复杂的业务逻辑保留了MyBatis的灵活配置SQL的特性。
附图说明
图1为本发明实施例中一种数据库操作层表示方法的流程示意图。
本发明的实施方式
为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图对本申请的技术方案进行更加详细的说明。下列实施例是对本发明的进一步解释和补充,对本发明不构成任何限制。
图1是本发明实施例提供的一种数据库操作层表示方法的流程示意图,该方法过程详述如下:
步骤S01:对实体类进行映射关系配置,指定实体类和表之间的映射关系。
具体的,实体类或实体对象可以作为操作层传入的参数类型,但是传入的参数类型不限于以上两种。
步骤S02:操作层的类的方法通过配置识别传入的参数类型,根据传入的参数类型或配置从模板中取出该方法的SQL语句、生成动态的SQL语句或取出该方法的SQL语句后进一步生成所需的动态SQL语句;
具体的,操作层的类包含基础类和扩展类,基础类实现JPA基础操作类的标准方法,通过传入实体类、主键、实体对象、SQL、查询条件等参数实现对数据的增删改查,扩展类扩展Mybatis基础操作类的实现,实现复用。
步骤S03:执行SQL语句获得所需的结果。
具体的,返回的类型由操作层参数类型指定、SQL模板指定或方法的返回类型直接决定,方法返回值优先决定返回类型,从方法返回值不能判断返回类型则指定类型优先,如果没有指定类型则通过模板指定的类型返回,否则返回键值对的集合。
步骤S04:根据传入的参数或模板中的配置,将生成的结果组装成所需的类对象并返回。
在具体实施例中,可以在操作层方法中规定具体的保留字,用于表示JPA所需的对象类型,框架从操作层的方法的配置中识别出保留字所代表的对象类型,从而实现JPA转换。
在具体实施例中,可规定保留字指定操作返回对象类型,并根据JPA映射将查询结果转换返回的对象类型,从而实现结果动态转换。
在具体实施例中,操作层框架通过保留字获知传入的参数类型,保留字包括:类保留字、实体对象保留字、id主键保留字、动态传入SQL保留字、SQL附加参数保留字、返回类型保留字、符合查询条件保留字、查询或修改的页保留字、分页信息保留字。
在具体实施例中,如果传入分页信息保留字,则可以根据生成的SQL语句再次进一步生成分页语句。
在具体实施例中,生成SQL语句时根据JPA规范,将SQL语句的条件写入MyBatis环境。
在具体实施例中,其特征在于,执行SQL语句时根据数据访问层操作返回结果参数,修改返回时ORM,如果数据访问层返回是列,则根据传入的参数作为返回值映射。
在具体实施例中在具体实施例中中,使用ORM机制,对每个对象标明表名及对象之间的关系进行对象关联映射,复用操作类,在对象关联写上增删改查、批增、批删、批改、分页方法。
在具体实施例中,在MyBatis框架中使用JPA机制弥补MyBatis复用性缺陷以及运行时查询语句的缺陷,系统有易开发性和复用性可灵活配置SQL。
本发明实施例还提供一种数据库操作装置,该装置包括:操作层、实现框架、实体类、SQL模板。
操作层包括类和操作层的类的方法,操作层的类的方法通过配置指定传入的参数类型,包括实体类和/或实体对象和/或主键和/或SQL语句和/或分页信息,如果参数中有实体类,则实体类代表其解析其与表之间的JPA映射关系。
操作层的类就是操作类,操作层的类的方法就是操作层的方法。
实现框架,包括MyBatis框架本身的启动和运转机制以及MyBatis插件。
利用Mybatis插件机制,拦截Mybatis的数据访问层操作,并根据基础类具体的增删改查操作,将传入的参数转换为SQL,并返回正确的结果,实现Mybatis数据访问层数据操作类的类似hibernate的JPA和ORM功能。
实体类,用于定义实体类和表之间的ORM映射关系。
SQL模板,用于实现对数据的增删改查及灵活配置。
在具体实施例中,装置规定实体类、实体对象、主键、被返回或修改的字段或属性、其他查询条件,如果是基础类或方法对应的模板SQL为空,则由MyBatis插件拦截到这些属性,实现框架生成语句。
在具体实施例中,装置规定分页、查总条数、查最大值为参数类型,由MyBatis插件拦截到这些属性,实现框架根据模板或生成的语句再次生成分页语句、查询总数语句、查最大值语句。
在具体实施例中,由指定返回类型作为参数类型,由MyBatis插件拦截到该属性,则在执行完查询后按照指定的数据类型做JPA映射,以组装返回值。
本发明实施例还提供一种数据库实体类配置方法,配置实体类的列属性时绑定列属性在增加、删除或修改时的空值检查,如果检查为空值则触发相应的操作,否则不操作。
在具体实施例中,所述空值触发的操作包括:生成列属性、抛出错误、打印消息、忽略。
本发明实施例还提供一种列属性生成方法,规定其列属性生成由第一生成择案、第二备选生成择案成直到第若干备选生成择案组成,如果第一生成失败则通过第二备选生成得到列属性值。
在具体实施例中,一个生成择案包含若干生成序,生成择案由这些生成序生成后按前后顺序拼接而成。
在具体实施例中,生成序的生成序规则包括:常量和/或变量、类与方法、对象与方法。
本发明实施例还提供一种缓存机制,在实体类的配置中声明该类的缓存策略,类的缓存策略包括整表内存缓存、整表外存缓存、不缓存,内存缓存就是全表存在内存中,外缓存就是通过按淘汰策略缓存在其他程序或设备。
本发明实施例还提供一种MyBatis数据库缓存装置,在实体类中配置缓存策略为内存缓存、整表外存缓存和不缓存,优先使用实体类内缓存和外缓存,如果实体类没有配置缓存,则根据生成的SQL语句使用MyBatis的缓存机制。

Claims (21)

  1. 一种数据库操作层表示方法,其特征在于,包括:
    对实体类进行映射关系配置,指定实体类和表之间的映射关系;
    操作层的类的方法通过配置识别传入的参数类型,根据传入的参数类型或配置从模板中取出该方法的SQL语句、生成动态的SQL语句或取出该方法的SQL语句后进一步生成所需的动态SQL语句;
    执行SQL语句获得所需的结果;
    根据传入的参数或模板中的配置,将生成的结果组装成所需的类对象并返回。
  2. 根据权利要求1所述的数据库操作层表示方法,其特征在于,实体类或实体对象可以作为操作层传入的参数类型。
  3. 根据权利要求1所述的数据库操作层表示方法,其特征在于,所述返回的类型由操作层参数类型指定、SQL模板指定或方法的返回类型直接决定,方法返回值优先决定返回类型,从方法返回值不能判断返回类型则指定类型优先,如果没有指定类型则通过模板指定的类型返回,否则返回键值对的集合。
  4. 根据权利要求1所述的数据库操作层表示方法,其特征在于,在操作层方法中规定具体的保留字,用于表示JPA所需的对象类型,框架从操作层的方法的配置中识别出保留字所代表的对象类型,从而实现JPA转换。
  5. 根据权利要求4所述的数据库操作层表示方法,其特征在于,可规定保留字指定操作返回对象类型,并根据JPA映射将查询结果转换返回的对象类型,从而实现结果动态转换。
  6. 根据权利要求4所述的数据库操作层表示方法,其特征在于,操作层框架通过保留字获知传入的参数类型,保留字包括:类保留字、实体对象保留字、id主键保留字、动态传入SQL保留字、SQL附加参数保留字、返回类型保留字、符合查询条件保留字、查询或修改的页保留字、分页信息保留字。
  7. 根据权利要求4所述的数据库操作层表示方法,其特征在于,如果传入分页信息保留字,则可以根据生成的SQL语句再次进一步生成分页语句。
  8. 根据权利要求1-7中任一项所述的数据库操作层表示方法,其特征在于,所述操作层的类,包含基础类和扩展类,基础类实现JPA基础操作类的标准方法,通过传入实体类、主键、实体对象、SQL、查询条件等参数实现对数据的增删改查,扩展类扩展MyBatis基础操作类的实现,实现复用。
  9. 根据权利要求1-7中任一项所述的数据库操作层表示方法,其特征在于,生成SQL语句时根据JPA规范,将SQL语句的条件写入MyBatis环境。
  10. 根据权利要求1-7中任一项所述的数据库操作层表示方法,其特征在于,执行SQL语句时根据数据访问层操作返回结果参数,修改返回时ORM,如果数据访问层返回是列,则根据传入的参数作为返回值映射。
  11. 一种数据库操作装置,其特征在于,包括:
    操作层,包括操作层的类和操作层的类的方法,操作层的类的方法通过配置指定传入的参数类型,包括实体类和/或实体对象和/或主键和/或SQL语句和/或分页信息,如果参数中有实体类,则实体类代表其解析其与表之间的JPA映射关系;
    实现框架,包括MyBatis框架本身的启动和运转机制以及MyBatis插件;
    实体类,用于定义实体类和表之间的ORM映射关系;
    SQL模板,用于实现对数据的增删改查及灵活配置。
  12. 根据权利要求11所述的数据库操作装置,其特征在于,装置规定实体类、实体对象、主键、被返回或修改的字段或属性、其他查询条件,如果是基础类或方法对应的模板SQL为空,则由MyBatis插件拦截到这些属性,实现框架生成语句。
  13. 根据权利要求11所述的数据库操作装置,其特征在于,装置规定分页、查总条数、查最大值为参数类型,由MyBatis插件拦截到这些属性,实现框架根据模板或生成的语句再次生成分页语句、查询总数语句、查最大值语句。
  14. 根据权利要求11所述的数据库操作装置,其特征在于,由指定返回类型作为参数类型,由MyBatis插件拦截到该属性,则在执行完查询后按照指定的数据类型做JPA映射,以组装返回值。
  15. 一种数据库实体类配置方法,其特征在于,配置实体类的列属性时绑定列属性在增加、删除或修改时的空值检查,如果检查为空值则触发相应的操作,否则不操作。
  16. 根据权利要求15所述的数据库实体类配置方法,其特征在于,所述空值触发的操作包括:生成列属性、抛出错误、打印消息、忽略。
  17. 一种列属性生成方法,其特征在于,规定其列属性生成由第一生成择案、第二备选生成择案成直到第若干备选生成择案组成,如果第一生成失败则通过第二备选生成得到列属性值。
  18. 根据权利要求17所述列属性生成方法,其特征在于,所述一个生成择案包含若干生成序,生成择案由这些生成序生成后按前后顺序拼接而成。
  19. 根据权利要求18所述列属性生成方法,其特征在于,所述生成序的生成序规则包括:常量和/或变量、类与方法、对象与方法。
  20. 一种缓存机制,其特征在于,在实体类的配置中声明该类的缓存策略,类的缓存策略包括整表内存缓存、整表外存缓存、不缓存,内存缓存就是全表存在内存中,外缓存就是通过按淘汰策略缓存在其他程序或设备。
  21. 一种MyBatis数据库缓存装置,在实体类中配置缓存策略为内存缓存、整表外存缓存和不缓存,优先使用实体类内缓存和外缓存,如果实体类没有配置缓存,则根据生成的SQL语句使用MyBatis的缓存机制。
PCT/CN2019/087386 2019-05-17 2019-05-17 一种数据库操作层表示方法及装置 WO2020232569A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2019/087386 WO2020232569A1 (zh) 2019-05-17 2019-05-17 一种数据库操作层表示方法及装置
CN201980096445.5A CN114096956A (zh) 2019-05-17 2019-05-17 一种数据库操作层表示方法及装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/087386 WO2020232569A1 (zh) 2019-05-17 2019-05-17 一种数据库操作层表示方法及装置

Publications (1)

Publication Number Publication Date
WO2020232569A1 true WO2020232569A1 (zh) 2020-11-26

Family

ID=73459226

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/087386 WO2020232569A1 (zh) 2019-05-17 2019-05-17 一种数据库操作层表示方法及装置

Country Status (2)

Country Link
CN (1) CN114096956A (zh)
WO (1) WO2020232569A1 (zh)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112685435A (zh) * 2020-12-21 2021-04-20 福建新大陆软件工程有限公司 一种基于Vue和Mybatis的表格查询方法及系统
CN112905617A (zh) * 2021-03-31 2021-06-04 浙江太美医疗科技股份有限公司 数据写入方法、服务器及计算机可读存储介质
CN112905630A (zh) * 2021-03-31 2021-06-04 浙江太美医疗科技股份有限公司 数据操作方法、服务器和计算机可读介质
CN112905636A (zh) * 2021-03-31 2021-06-04 浙江太美医疗科技股份有限公司 数据操作方法、服务器和计算机可读介质
CN113190264A (zh) * 2021-04-29 2021-07-30 上海天好信息技术股份有限公司 一种基于jpa的自动化数据版本生成及应用的装置和方法
CN113239009A (zh) * 2021-04-08 2021-08-10 大唐软件技术股份有限公司 一种数据库操作方法、装置、设备及存储介质
CN113608724A (zh) * 2021-08-24 2021-11-05 上海德拓信息技术股份有限公司 一种基于模型缓存实现的离线仓库实时交互方法与系统
CN113656433A (zh) * 2021-08-16 2021-11-16 北京京东振世信息技术有限公司 实体对象扩展方法、装置、电子设备和存储介质
CN114356438A (zh) * 2021-12-14 2022-04-15 海尔优家智能科技(北京)有限公司 智能场景的启用方法及装置、电子设备、存储介质
CN114356302A (zh) * 2022-03-15 2022-04-15 江苏数兑科技有限公司 一种基于Gremlin语言的持久层优化方法
CN114519582A (zh) * 2022-02-21 2022-05-20 中国邮政储蓄银行股份有限公司 服务的预热方法、预热装置和服务系统
CN114756554A (zh) * 2022-06-13 2022-07-15 中建电子商务有限责任公司 一种基于MyBatis框架的数据查询处理方法
CN116107585A (zh) * 2023-02-17 2023-05-12 广州市保伦电子有限公司 一种服务器端编译时期xml生成方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103116622A (zh) * 2013-01-30 2013-05-22 深圳联友科技有限公司 一种用于Ibatis方案的序列值生成方法及装置
US20160179589A1 (en) * 2014-12-18 2016-06-23 Jenny (Wenli) Zhang Centralized and distributed notification handling system for software applications
CN106682042A (zh) * 2015-11-11 2017-05-17 杭州海康威视数字技术股份有限公司 一种关系数据缓存及查询方法及装置
CN107392053A (zh) * 2017-08-11 2017-11-24 四川长虹电器股份有限公司 一种企业员工信息数据库中的数据权限控制方法
CN108090063A (zh) * 2016-11-21 2018-05-29 深圳联友科技有限公司 一种可配置的组件数据访问方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103116622A (zh) * 2013-01-30 2013-05-22 深圳联友科技有限公司 一种用于Ibatis方案的序列值生成方法及装置
US20160179589A1 (en) * 2014-12-18 2016-06-23 Jenny (Wenli) Zhang Centralized and distributed notification handling system for software applications
CN106682042A (zh) * 2015-11-11 2017-05-17 杭州海康威视数字技术股份有限公司 一种关系数据缓存及查询方法及装置
CN108090063A (zh) * 2016-11-21 2018-05-29 深圳联友科技有限公司 一种可配置的组件数据访问方法及装置
CN107392053A (zh) * 2017-08-11 2017-11-24 四川长虹电器股份有限公司 一种企业员工信息数据库中的数据权限控制方法

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112685435A (zh) * 2020-12-21 2021-04-20 福建新大陆软件工程有限公司 一种基于Vue和Mybatis的表格查询方法及系统
CN112905617B (zh) * 2021-03-31 2023-01-24 浙江太美医疗科技股份有限公司 数据写入方法、服务器及计算机可读存储介质
CN112905617A (zh) * 2021-03-31 2021-06-04 浙江太美医疗科技股份有限公司 数据写入方法、服务器及计算机可读存储介质
CN112905630A (zh) * 2021-03-31 2021-06-04 浙江太美医疗科技股份有限公司 数据操作方法、服务器和计算机可读介质
CN112905636A (zh) * 2021-03-31 2021-06-04 浙江太美医疗科技股份有限公司 数据操作方法、服务器和计算机可读介质
CN113239009A (zh) * 2021-04-08 2021-08-10 大唐软件技术股份有限公司 一种数据库操作方法、装置、设备及存储介质
CN113190264A (zh) * 2021-04-29 2021-07-30 上海天好信息技术股份有限公司 一种基于jpa的自动化数据版本生成及应用的装置和方法
CN113190264B (zh) * 2021-04-29 2024-02-23 上海天好信息技术股份有限公司 一种基于jpa的自动化数据版本生成及应用的装置和方法
CN113656433A (zh) * 2021-08-16 2021-11-16 北京京东振世信息技术有限公司 实体对象扩展方法、装置、电子设备和存储介质
CN113656433B (zh) * 2021-08-16 2023-09-05 北京京东振世信息技术有限公司 实体对象扩展方法、装置、电子设备和存储介质
CN113608724A (zh) * 2021-08-24 2021-11-05 上海德拓信息技术股份有限公司 一种基于模型缓存实现的离线仓库实时交互方法与系统
CN113608724B (zh) * 2021-08-24 2023-12-15 上海德拓信息技术股份有限公司 一种基于模型缓存实现的离线仓库实时交互方法与系统
CN114356438A (zh) * 2021-12-14 2022-04-15 海尔优家智能科技(北京)有限公司 智能场景的启用方法及装置、电子设备、存储介质
CN114356438B (zh) * 2021-12-14 2023-08-18 海尔优家智能科技(北京)有限公司 智能场景的启用方法及装置、电子设备、存储介质
CN114519582A (zh) * 2022-02-21 2022-05-20 中国邮政储蓄银行股份有限公司 服务的预热方法、预热装置和服务系统
CN114356302A (zh) * 2022-03-15 2022-04-15 江苏数兑科技有限公司 一种基于Gremlin语言的持久层优化方法
CN114756554A (zh) * 2022-06-13 2022-07-15 中建电子商务有限责任公司 一种基于MyBatis框架的数据查询处理方法
CN116107585A (zh) * 2023-02-17 2023-05-12 广州市保伦电子有限公司 一种服务器端编译时期xml生成方法及装置
CN116107585B (zh) * 2023-02-17 2024-03-08 广东保伦电子股份有限公司 一种服务器端编译时期xml生成方法及装置

Also Published As

Publication number Publication date
CN114096956A (zh) 2022-02-25

Similar Documents

Publication Publication Date Title
WO2020232569A1 (zh) 一种数据库操作层表示方法及装置
US8738663B2 (en) Rule-based transformation of metadata
US5832498A (en) Device for generating object-oriented interfaces for relational data bases and a process implemented by this device
US7207002B2 (en) Serialization and preservation of objects
US7769789B2 (en) High performant row-level data manipulation using a data layer interface
JP4855656B2 (ja) 複数のオブジェクトをシリアライズする方法
US7490098B2 (en) Apparatus, system, and method for processing hierarchical data in disparate data repositories
US10437564B1 (en) Object mapping and conversion system
US8527532B2 (en) Transforming function calls for interaction with hierarchical data structures
JPH04320533A (ja) プログラム処理装置及びプログラム処理方法
CN109840256A (zh) 一种基于业务实体的查询实现方法
CN107665216A (zh) 一种数据库访问方法及中间件
US6658426B1 (en) Object-oriented database abstraction and statement generation
CN110727482B (zh) 一种界面的更新方法和装置
CN111125440B (zh) 一种基于Monad的持久层复合条件查询方法与存储介质
WO2019015364A1 (zh) 执行结构化查询语言sql指令的方法和装置
US8615729B2 (en) Extending existing model-to-model transformations
US7958154B2 (en) Apparatus, system, and method for command manager support for pluggable data formats
CN104166705A (zh) 数据库的访问方法及装置
US6763361B1 (en) Object-oriented database abstraction and statement generation
US9760658B2 (en) Memory-mapped objects
US20130297755A1 (en) Network element configuration management
JP7250009B2 (ja) クライアントエンドのプログラミングツールにより実行される方法
US9009731B2 (en) Conversion of lightweight object to a heavyweight object
CN112035572A (zh) 创建表格实例的静态方法、装置、计算机设备、存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19929636

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19929636

Country of ref document: EP

Kind code of ref document: A1