ORM Query Tag Injection for SQL Traceability

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Software developers using Object-Relational Mapping (ORM) tools face difficulties in tracing dynamically generated SQL queries back to their originating code, making it hard to identify and address poor performing queries in production environments.

Innovation Solution

Implementing a query tag system within the ORM tool that injects a unique identifier into the SQL command, allowing Database Administrators and Developers to easily identify the responsible application code by adding a query tag as a SQL comment, which can be viewed during query execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If an ORM tool dynamically generates SQL queries, then developers can work with databases using object-oriented code without writing SQL, but it becomes impossible to trace the generated SQL back to the originating code

Engineering Contradiction:
Improveease of database accessVSAvoidloss of source code traceability
Core Design Contradiction:
Ease of operationVSLoss of information

Solution Approach 1:

The patent introduces a query tag as an intermediary element that bridges the ORM layer and the database layer. This tag contains source code identification information and is injected into the dynamically generated SQL query, allowing traceability without requiring developers to write SQL directly. The query tag acts as a mediator that preserves source code information through the abstraction layer.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system performs preliminary action by automatically generating and injecting query tags into SQL queries before they are executed in the database. This proactive tagging ensures that source code traceability information is embedded in advance, enabling later identification of the originating code without requiring manual intervention or code modification.

Inventive Principle:
Principle #10Preliminary action

2Productivity

If the ORM abstracts the database from developers, then developers can focus on object-oriented code, but poor performing SQL queries cannot be identified or debugged in production environments

Engineering Contradiction:
Improvedevelopment efficiencyVSAvoiddifficulty of query performance analysis
Core Design Contradiction:
ProductivityVSDifficulty of detecting and measuring

Solution Approach 1:

The query tag acts as a visual identifier (analogous to color coding) that can be used to highlight and distinguish specific queries in database performance monitoring tools. By injecting unique tags into queries, administrators can easily filter, search, and identify problematic queries in production environments without needing to understand the underlying object-oriented code structure.

Inventive Principle:
Principle #32Color changes

Solution Approach 2:

The system implements feedback by enabling database administrators to trace performance issues back to the specific application code that generated them. The query tag creates a feedback loop from the database performance metrics back to the source code, allowing for targeted optimization and debugging while maintaining high development efficiency.

Inventive Principle:
Principle #23Feedback

3Ease of manufacture

If SQL queries are dynamically generated by the ORM, then developers don't need to write database access code, but it becomes hard to identify and correct poor performing queries

Engineering Contradiction:
Improveease of code generationVSAvoidease of query optimization
Core Design Contradiction:
Ease of manufactureVSEase of repair

Solution Approach 1:

The query tag segments the SQL query by embedding identification information that separates and identifies the originating source code. This segmentation allows database administrators to isolate and analyze specific queries generated by different parts of the application, making it easier to identify and optimize poor performing queries without requiring manual code generation or modification.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS10769139B2System and method for implementing query tagging
Publication Date: 2020.09.08 JPMORGAN CHASE BANK NA
  • US10769139B2 patent drawing
  • US10769139B2 patent drawing
  • US10769139B2 patent drawing

AI summary

The invention relates to applying a query tag in an object relational mapping tool. According to an embodiment of the present invention, a system comprises: a Repository API; a relational database management system (RDBMS); an object relational mapping (ORM) Tool that receives input from the Repository API and translates the input to the RDBMS; and a processor, coupled to the Repository API, the ORM Tool and the RDMBS, configured to perform the steps comprising: determine, at the Repository API, a query tag that identifies an origination source code; propagate the query tag to a database connection context within the ORM Tool; and inject the query tag into a generated SQL command.