実現したいこと
- xml内のSQL文がうまく実行できるようにすること
前提
掲示板アプリを作っています。
投稿する機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: column "details" does not exist ヒント: There is a column named "details" in table "bbs_app", but it cannot be referenced from this part of the query. 位置: 65 ### The error may exist in com/example/BBS/mapper/BbsMapper.xml ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: insert into bbs_app (name, details) values (?,name(?, details)) ### Cause: org.postgresql.util.PSQLException: ERROR: column "details" does not exist ヒント: There is a column named "details" in table "bbs_app", but it cannot be referenced from this part of the query. 位置: 65 ; bad SQL grammar []] with root cause org.postgresql.util.PSQLException: ERROR: column "details" does not exist ヒント: There is a column named "details" in table "bbs_app", but it cannot be referenced from this part of the query. 位置: 65
該当のソースコード
xml
1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE mapper 3 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 5<mapper namespace="com.example.BBS.mapper.BbsMapper"> 6 7 <select id="add" resultType="com.example.BBS.entity.Entity"> 8 insert into bbs_app (name, details) 9 values (#{name},name(#{details}, details)) //ここがわかりません 10 </select> 11</mapper>
html
1<h1>掲示板へようこそ!</h1> 2<table> 3 <form method="post" action="/" th:action="@{/add}"> 4 <tr> 5 <td><label for="name">名前</label></td> 6 <td><input type="text" name="name" id="name"/></td> 7 </tr> 8 <tr> 9 <td><label for="details">投稿内容</label></td> 10 <td><input type="text" name="details" id="details"/></td> 11 </tr> 12 <tr> 13 <td><input type="submit"/></td> 14 </tr> 15 </form> 16</table> 17<br/> 18<table>
java
1package com.example.BBS.controller; 2 3import com.example.BBS.entity.Entity; 4import com.example.BBS.mapper.BbsMapper; 5import org.springframework.beans.factory.annotation.Autowired; 6import org.springframework.stereotype.Controller; 7import org.springframework.ui.Model; 8import org.springframework.web.bind.annotation.GetMapping; 9import org.springframework.web.bind.annotation.ModelAttribute; 10import org.springframework.web.bind.annotation.RequestMapping; 11import org.springframework.web.bind.annotation.RequestParam; 12 13import java.util.List; 14 15@Controller 16public class BbsController { 17 18 @Autowired 19 BbsMapper bbsMapper; 20 21 @RequestMapping(value = "/") 22 public String index(Model model){ 23 List<Entity> list = bbsMapper.selectAll(); 24 model.addAttribute("submissionDetails", list); 25 return "index"; 26 } 27 28 @RequestMapping(value = "/add") 29 public String add(Entity entity){ 30 bbsMapper.add(entity); 31 return "redirect:/"; 32 } 33} 34
試したこと
SQL文の見直し
補足情報(FW/ツールのバージョンなど)
postgresql
springframework.boot' version '3.1.1

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。