Home > Back-end >  Advice: Mybatis perform select count (*) returns the result is 0, but the data in a database table
Advice: Mybatis perform select count (*) returns the result is 0, but the data in a database table

Time:04-01

The dao:
` int selectbalanceRecordByMbIdCount (AlAccountInfo AlAccountInfo); `

Mapper:
` & lt; Select id="selectbalanceRecordByMbIdCount parameterType=" "com.sojson.com mon. Model. AlAccountInfo" resultType="Java. Lang. Integer" & gt;
SELECT COUNT (*)
The FROM admin_balance a
LEFT the JOIN al_member b ON b.i d=arjun emberId
LEFT the JOIN al_shop c ON c.i d=a.s hopId
WHERE arjun emberId=# {med} AND a.org anizationId=# {organizationId}

`
Navicate execution:
SELECT COUNT (*)
The FROM admin_balance a
LEFT the JOIN al_member b ON b.i d=arjun emberId
LEFT the JOIN al_shop c ON c.i d=a.s hopId
WHERE arjun emberId anizationId=10001045=00000887 AND a.org
The results of the count (*) 6

The console output logs:
[the DEBUG] [the 11:10:19 2018-01-27, 443] [. Org. Springframework. JDBC datasource. DataSourceTransactionManager] Acquired Connection [com. Alibaba. Druid. Proxy. JDBC. ConnectionProxyImpl @ 1 f99d6fc] for JDBC transaction
[the DEBUG] [the 11:10:19 2018-01-27, 443] [. Org. Springframework. JDBC datasource. DataSourceUtils] Setting JDBC Connection [com. Alibaba. Druid. Proxy. JDBC. ConnectionProxyImpl @ 1 f99d6fc] read - only
[the DEBUG] [the 11:10:19 2018-01-27, 451] [. Org. Springframework. JDBC datasource. DataSourceTransactionManager] Switching JDBC Connection [com. Alibaba. Druid. Proxy. JDBC. ConnectionProxyImpl @ 1 f99d6fc] to manual commit
[the DEBUG] [the 11:10:19 2018-01-27, 451] [druid. SQL. Connection]} {conn - 10003 setAutoCommit false
[the DEBUG] [the 11:10:19 2018-01-27, 461] [org. Mybatis. Spring. SqlSessionUtils] Creating a new SqlSession
[the DEBUG] [the 11:10:19 2018-01-27, 461] [org. Mybatis. Spring. SqlSessionUtils] Registering transaction synchronization for SqlSession [org. Apache. Ibatis. Session. Defaults. DefaultSqlSession @ 6 c7f4067]
[the DEBUG] [the 11:10:19 2018-01-27, 462] [org. Mybatis. Spring. Transaction. SpringManagedTransaction] JDBC Connection [com. Alibaba. Druid. Proxy. JDBC. ConnectionProxyImpl @ 1 f99d6fc] will be managed by the spring
[the DEBUG] [the 11:10:19 2018-01-27, 462] [com.sojson.com mon. Dao. MemberInfoMapper. SelectbalanceRecordByMbIdCount] ooo Using Connection [com. Alibaba. Druid. Proxy. JDBC. ConnectionProxyImpl @ 1 f99d6fc]
[the DEBUG] [the 11:10:19 2018-01-27, 462] [com.sojson.com mon. Dao. MemberInfoMapper. SelectbalanceRecordByMbIdCount]==& gt; Preparing: SELECT COUNT (*) FROM admin_balance a LEFT JOIN al_member b ON b.i d=arjun emberId LEFT JOIN al_shop c ON c.i d=a.s hopId WHERE arjun emberId=? AND a.org anizationId=?
[the DEBUG] [the 11:10:19 2018-01-27, 462] [druid, SQL Statement]} {, PSTMT conn - 10003-20059 created.
SELECT COUNT (*)
The FROM admin_balance a
LEFT the JOIN al_member b ON b.i d=arjun emberId
LEFT the JOIN al_shop c ON c.i d=a.s hopId
WHERE arjun emberId=? AND a.org anizationId=?
[the DEBUG] [the 11:10:19 2018-01-27, 462] [com.sojson.com mon. Dao. MemberInfoMapper. SelectbalanceRecordByMbIdCount]==& gt; The Parameters: 00000887 (String), 10001045 (String)
[the DEBUG] [the 11:10:19 2018-01-27, 462] [druid, SQL Statement] {conn - 10003, PSTMT - 20059} the Parameters: [00000887, 10001045]
[the DEBUG] [the 11:10:19 2018-01-27, 462] [druid, SQL Statement]} {conn - 10003, PSTMT - 20059 Types: [VARCHAR, VARCHAR]
[the DEBUG] [the 11:10:19 2018-01-27, 465] [druid, SQL Statement]} {conn - 10003, PSTMT - 20059 executed. 2.514853 millis.
SELECT COUNT (*)
The FROM admin_balance a
LEFT the JOIN al_member b ON b.i d=arjun emberId
LEFT the JOIN al_shop c ON c.i d=a.s hopId
WHERE arjun emberId=? AND a.org anizationId=?
[the DEBUG] [the 11:10:19 2018-01-27, 465] [druid. SQL. The ResultSet] {PSTMT, conn - 10003-20059, rs - 50063} open
[the DEBUG] [the 11:10:19 2018-01-27, 465] [druid. SQL. The ResultSet] {PSTMT, conn - 10003-20059, rs - 50063} Header: [COUNT (*)]
[the DEBUG] [the 11:10:19 2018-01-27, 465] [druid. SQL. The ResultSet] {PSTMT, conn - 10003-20059, rs - 50063} the Result: [0]
[the DEBUG] [the 11:10:19 2018-01-27, 465] [com.sojson.com mon. Dao. MemberInfoMapper. SelectbalanceRecordByMbIdCount] <==the Columns: COUNT (*)
[the DEBUG] [the 11:10:19 2018-01-27, 465] [com.sojson.com mon. Dao. MemberInfoMapper. SelectbalanceRecordByMbIdCount] <==Row: 0
[the DEBUG] [the 11:10:19 2018-01-27, 465] [druid. SQL. The ResultSet] {PSTMT, conn - 10003-20059, rs - 50063} closed

CodePudding user response:

Such a strange, different database connect?

CodePudding user response:

Checked, not even wrong

CodePudding user response:

The SQL database to perform the final look at what is the result

CodePudding user response:

Parameter type wrong?

CodePudding user response:

Your input is a object parameterType="com.sojson.com mon. Model. AlAccountInfo"
Use the # to obtain parameters directly in the where condition, so may not have access to the parameters, the query result is 0

Can try to enter use # (object. The property) to obtain or enter into a map parameterType="map for Java. Util."

CodePudding user response:

You navicate execution, parameters of quotes

CodePudding user response:

Because of your database is not empty fields ""

CodePudding user response:

Resulted in the abnormal so the returned result is 0

CodePudding user response:

May only pass in a parameter

CodePudding user response:

nullnullnullnullnullnullnullnull
  • Related