The variable in the request in the mybatis mapper is not replaced. In the case of "select" queries, everything is fine, but I need to be able to create a table by name.
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface TableMapper {
@Update("""
create table if not exists #{name}
(table_name varchar(50) NOT NULL,
update_date varchar(20) NOT NULL)
""")
void createTableByName(@Param("name") String name);
}
What am I doing wrong? Or is this approach not possible when using mybatis?
In logs:
The error occurred while setting parameters
SQL: create table if not exists ? (table_name varchar(50) NOT NULL, update_date varchar(20) NOT NULL)
The variable passed to the method is neither empty nor null.
The list of fields in the table itself is not important, only the possibility of creating a table by a given name.