Home > Back-end >  How to use the static constants when mybatis annotation SQL
How to use the static constants when mybatis annotation SQL

Time:09-25

Mybatis annotations when there are some SQL query conditions are fixed, don't want to use mana, so want to use static constants, but found in the process of using, as long as is the use of the static constants of SQL can perform to the result, how to do to use static constants in the annotations of SQL

CodePudding user response:

. Annotation of SQL SQL now don't write in the XML...

CodePudding user response:

reference 1st floor Ricky_As response:
... Annotation of SQL SQL now don't write in the XML...
the author's project is not in the form of using XML

CodePudding user response:

Never write dare not make irresponsible advice;
But generally in XML is the select * from xx where XXX='1' the constant 1 in single quotation marks;

CodePudding user response:

The
reference 3 floor Ricky_As response:
never write not hazard directions;
But generally in XML is the select * from xx where XXX='1' the constant 1 in single quotation marks;
I know that you can use the quotation marks of constants, this way may be used, but it is best to avoid direct use value should be used in programming a constant receives this value, now I just want to use in mapper constants, but as long as it is constant will fail, I think it's less configuration, but I didn't find the specific how to configure

CodePudding user response:

int a=1;

Mybatis placeholder # {a}
You need to specify the parameter types
In XML is specified in the select tag parameterType attribute's value

CodePudding user response:

reference 5 floor Ricky_As reply:
int a=1;

Mybatis placeholder # {a}
You need to specify the parameter types
In XML is parameterType attribute value specified in the select tag
this method is to put the incoming constants as parameters, lost the meaning of the constants

CodePudding user response:

refer to 6th floor hasn't bald scene early reply:
Quote: refer to the fifth floor Ricky_As reply:

int a=1;

Mybatis placeholder # {a}
You need to specify the parameter types
In XML is parameterType attribute value specified in the select tag
this method is to put the incoming constants as parameters, lost the meaning of constant
I assume that no other way to write not write with placeholder don't have to...

CodePudding user response:

this kind of method is constant as the incoming parameters, lost the meaning of constant
I assume that no other way to write not write with placeholder don't have to...
thank you for your answer
  • Related