RookieMember opened a new issue #10258:
URL: https://github.com/apache/shardingsphere/issues/10258


   ### Which version of ShardingSphere did you use?
   4.1.1
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   select * from t_address
   All results should be returned
   ### Actual behavior
   All elements in the returned collection are null
   
![image](https://user-images.githubusercontent.com/43982372/117297068-593f6e00-aea8-11eb-98d0-ab38ecf15b3b.png)
   
   ### Reason analyze (If you can)
   I read the source code, issued the following code:
   
org.apache.shardingsphere.sql.parser.binder.segment.select.projection.engine.ProjectionEngine#getUnqualifiedShorthandColumns
   ```
   private Collection<ColumnProjection> getUnqualifiedShorthandColumns(final 
Collection<SimpleTableSegment> tables) {
           Collection<ColumnProjection> result = new LinkedList<>();
           for (SimpleTableSegment each : tables) {
               result.addAll(schemaMetaData.getAllColumnNames(
                       
each.getTableName().getIdentifier().getValue()).stream().map(columnName -> new 
ColumnProjection(null, columnName, null)).collect(Collectors.toList()));
           }
           return result;
       }
   ```
   I guess schemaMetaData does not contain a broadcast table, so the column for 
the broadcast table cannot be obtained。
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   ```
   <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>2.0.1</version>
   </dependency>
   <dependency>
        <groupId>org.apache.shardingsphere</groupId>
        <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
        <version>4.1.1</version>
   </dependency>
   ```
   ```
   CREATE TABLE `t_address` (
     `address_id` bigint(20) NOT NULL,
     `address_name` varchar(100) NOT NULL,
     PRIMARY KEY (`address_id`)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
   ```
   ```
   @Mapper
   public interface AddressMapper {
       
       List<Address> selectAll() throws SQLException;
   }
   ```
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
   <mapper namespace="com.wkp.shardingjdbc.mapper.AddressMapper">
       <resultMap id="BaseResultMap" type="com.wkp.shardingjdbc.entity.Address">
           <id column="address_id" jdbcType="INTEGER" property="addressId"/>
           <result column="address_name" jdbcType="VARCHAR" 
property="addressName"/>
       </resultMap>
       <sql id="Base_Column_List">address_id, address_name</sql>
   
       <select id="selectAll" resultMap="BaseResultMap">
           select * from t_address
       </select>
   <!--
       <select id="selectAll" resultMap="BaseResultMap">
           select <include refid="Base_Column_List"/> from t_address
       </select>
   -->
   </mapper>
   ```
   `spring.shardingsphere.sharding.broadcast-tables=t_address
   `
   
   1:When I use "select * from t_address",All elements in the returned 
collection are null
   2:When I use "select address_id, address_name from t_address",Returns the 
correct result set
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to