閲覧ありがとうございます。
メソッドの値にnewがついているときの値の取得方法がわかりません。
java
1@Mapper 2public interface FoodsMapper{ 3 List<Map<String, Object>> findByTypeAndPriceUsingClass(FoodsParam param); 4}
java
1public class MainTest{ 2 @Autowired 3 private FoodsMapper foodsMapper; 4 5 @Test 6 void test(){ 7 foodsMapper.findByTypeAndPriceUsingClass( 8 new FoodsParam("野菜", 500)); 9 } 10}
newをつけない場合は処理が成功しました。
つまり、インスタンスパラメータの受け渡しの方法がわからないというわけです。
error: constructor FoodsParam in class FoodsParam cannot be applied to given types; new FoodsParam("野菜", 500)); ^ required: no arguments found: String,int reason: actual and formal argument lists differ in length
java
1@Data 2@Entity 3public class FoodsParam{ 4 @Id 5 @GeneratedValue(strategy = GenerationType.IDENTITY) 6 private Integer id; 7 @Column(nullable = false) 8 private String name; 9 private String type; 10 private Integer price; 11 12 FoodsParam(){ 13 } 14 15 public FoodsParam(String type, Integer price){ 16 this.type = type; 17 this.price = price; 18 } 19}
かなりいろいろ調べてみたのですが、うまくいかなかったため質問させていただきます。
ご回答のほどよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー