Home > database >  Hibernate search based on certain fields need not to need to add single quotation marks
Hibernate search based on certain fields need not to need to add single quotation marks

Time:09-23

Today met a problem when I write code: according to the department ID search project:
Department id entity class is defined as: private String orgId;//under centralized unit id
The database is: VARCHAR2 (20)
When the query select * from... Where orgId (9007900 in 5)
Select * from... Where orgId in (' 9007 ', '9005'), two kinds of query methods won't be an error

CodePudding user response:

in the database is: VARCHAR2 (20)


When the query select * from... Where orgId (9007900 in 5)
Select * from... Where orgId in (' 9007 ', '9005'), two types of queries are not error

Because your field type is varchar type, and the where orgId in (9007900) has written two Numbers, there existed an implicit conversion, namely orgId after converted to numeric, do more, be sure in less than index
If your database, saved a not pure digital orgid, then the first language will be wrong,

So, you want to use the second,
  • Related