Finding associated mybatis query

blue-sky

To initiate a query I use :

org.apache.ibatis.session.SqlSession.seleteList("myquery");

myquery itself is defined within an XML configuration file.

With Spring JDBC as the query statements is defined with the class itself it is very easy find the query associated with a given method call. But with mybatis once I reach the query call I have to search for the argument (in this case "myquery") to discover where the actual query is defined.

Is there an easier method of finding a query associated with a method call instead of manually searching for references ? I'm thinking there isn't as since the query itself is within an XML file not a .java file and IDE maintains a "linking" of methods, constants etc between the files.

Roman Konoval

There are two ways to do that but you will need to use mapper interfaces.

The first approach is to use IDE plugin. There are several plugins for IntelliJ and some for eclipse. Plugin for IntelliJ says it has

Proxy interfaces support, "Go to Implementaion" jumps right into mapper xml

Another way is to define queries using annotations. In this case queries will be directly in java file.

Define query in mapper interface

interface MyMapper {
     @Select("Select * from myentity where id = #id")
     MyEntity selectMyEntity(@Param("id") Long id);
}

And then use mapper like usually:

MyMapper mapper = session.getMapper(MyMapper.class);
MyEntity myEntity = mapper.selectMyEntity(101);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Finding position of a found query in Lucene

From Dev

SQL Server finding maximum query

From Dev

Finding Column Headers Associated with Row Totals

From Dev

Rails Search Query Associated Model

From Dev

Efficient R code for finding indices associated with unique values in vector

From Dev

Finding all js events associated with a HTML element using Chrome

From Dev

Loading associated data in a single query

From Dev

MyBatis run native Query

From Dev

Finding neighbouring polygons - postgis query

From Dev

MyBatis query result in a HashMap?

From Dev

Finding data by inputing a name associated to the data

From Dev

spark finding max value and the associated key

From Dev

Finding the oldest person in Prolog Query

From Dev

Finding intersection of values in a column associated with unique values in another column Pandas

From Dev

Finding changesets associated with the work item or having specific comment TFS Api

From Dev

Finding optimal index for this MySQL query

From Dev

finding query that is holding lock

From Dev

Finding out the src IP and port associated with the socket used in sendto function

From Dev

Query to select by number of associated objects

From Dev

SQL query with associated column

From Dev

MyBatis run native Query

From Dev

Finding an associated job with a package

From Dev

Finding data by inputing a name associated to the data

From Dev

Finding the physical local path associated with a Share UNC folder

From Dev

vim finding all extensions associated with a filetype

From Dev

Finding the Associated Eigenvector in Matlab

From Dev

(Excel) Finding the column header associated with a cell, returning a list of names and headers

From Dev

Cakephp - Finding records with no associated records

From Dev

dynamic mybatis xml query

Related Related

  1. 1

    Finding position of a found query in Lucene

  2. 2

    SQL Server finding maximum query

  3. 3

    Finding Column Headers Associated with Row Totals

  4. 4

    Rails Search Query Associated Model

  5. 5

    Efficient R code for finding indices associated with unique values in vector

  6. 6

    Finding all js events associated with a HTML element using Chrome

  7. 7

    Loading associated data in a single query

  8. 8

    MyBatis run native Query

  9. 9

    Finding neighbouring polygons - postgis query

  10. 10

    MyBatis query result in a HashMap?

  11. 11

    Finding data by inputing a name associated to the data

  12. 12

    spark finding max value and the associated key

  13. 13

    Finding the oldest person in Prolog Query

  14. 14

    Finding intersection of values in a column associated with unique values in another column Pandas

  15. 15

    Finding changesets associated with the work item or having specific comment TFS Api

  16. 16

    Finding optimal index for this MySQL query

  17. 17

    finding query that is holding lock

  18. 18

    Finding out the src IP and port associated with the socket used in sendto function

  19. 19

    Query to select by number of associated objects

  20. 20

    SQL query with associated column

  21. 21

    MyBatis run native Query

  22. 22

    Finding an associated job with a package

  23. 23

    Finding data by inputing a name associated to the data

  24. 24

    Finding the physical local path associated with a Share UNC folder

  25. 25

    vim finding all extensions associated with a filetype

  26. 26

    Finding the Associated Eigenvector in Matlab

  27. 27

    (Excel) Finding the column header associated with a cell, returning a list of names and headers

  28. 28

    Cakephp - Finding records with no associated records

  29. 29

    dynamic mybatis xml query

HotTag

Archive