게시글
질문&답변
2022.06.30
findOne
어째건 감사합니다.
- 0
- 4
- 293
질문&답변
2022.06.30
findOne
어찌하다보니까. 아래처럼 하니까 되네요. 어렵다. 소뒷발로 쥐잡음 @PostMapping(value = "/books/Search_id1")public String searchIdFormList(BookMemberForm form,Model model) { BookMember bookMemberUi = new BookMember(); Optional bookMember = bookMagService.findOne(form.getBookId()); bookMemberUi = bookMember.get(); model.addAttribute("member", bookMemberUi); return "bookMember/bookMemberSingle";}
- 0
- 4
- 293
질문&답변
2022.06.30
findOne
친절한 답변 감사합니다. 근데 계속해서 질문하게되네요. 미천한 공부라...ㅠ.ㅠ [[[[[ BookMagController ]]]]] @PostMapping(value = "/books/Search_id1") public String searchIdFormList(BookMemberForm form,Model model) { System.out.println("#### BookMagController @PostMapping ===> bookId: " + form.getBookId()); model.addAttribute("members", bookMagService.findOne(form.getBookId())); System.out.println("]]]]]] #### BookMagController bookMagService model : " + model); return "bookMember/bookMemberSingle"; } [[[[ BookMagService.java ]]]]]] public Optional findOne(Long memberId) { System.out.println("#### BookMagService ===> bookId: " + memberId); return bookMemberRepository.findByBookId(memberId); } [[[[[ bookMemberSingle.html ]]]]]] 도서ID 도서명 도서십진분류 사업자등록번호 출판사 저자id 저자명 출판일 가격 상기처럼했는데 아래와같은 오류가 나네요? 어떻게 해야할지 감이 안옵니다. #### BookMagController @PostMapping ===> bookId: 1001 #### BookMagService ===> bookId: 1001 Hibernate: select bookmember0_.book_id as book_id1_0_, bookmember0_.book_name as book_nam2_0_, bookmember0_.book_author as book_aut3_0_, bookmember0_.book_author_id as book_aut4_0_, bookmember0_.book_kdc as book_kdc5_0_, bookmember0_.book_make_date as book_mak6_0_, bookmember0_.book_price as book_pri7_0_, bookmember0_.book_publisher as book_pub8_0_, bookmember0_.book_publisher_business_no as book_pub9_0_ from book_mag bookmember0_ where bookmember0_.book_id=? ]]]]]] #### BookMagController bookMagService model : {bookMemberForm=book.booksmag.controller.BookMemberForm@52983985, org.springframework.validation.BindingResult.bookMemberForm= org.springframework.validation.BeanPropertyBindingResult: 0 errors, members=Optional[book.booksmag.domain.BookMember@3b5ecc69]} 2022-06-30 10:57:56.885 ERROR 32896 --- [nio-8080-exec-4] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8080-exec-4] Exception processing template "bookMember/bookMemberSingle": Exception evaluating SpringEL expression: "member.bookId" (template: "bookMember/bookMemberSingle" - line 22, col 21) org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "member.bookId" (template: "bookMember/bookMemberSingle" - line 22, col 21) rg.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'bookId' cannot be found on object of type 'java.util.Optional' - maybe not public or not valid? 타입이 안맞다는것 같은데요? cannot be found on object of type 'java.util.Optional'
- 0
- 4
- 293
질문&답변
2022.06.29
에러 문의
public class BookMember { private String bookName; Optional findByBookName(String bookName); 상기처럼 했더니 에러는 안나네요. 감사합니다. 코볼세데라 어렵네요 ㅋㅋ 개념이 안잡힘
- 0
- 10
- 408
질문&답변
2022.06.29
에러 문의
"findBy" 이후에 엔티티의 속성 이름을 붙이다. 이 속성 이름은 첫 글자는 대문자로 한다. 상기처럼 Optional findByBook_name(String book_name); 으로 바꾸고 BookMember에도 book_name인데 private String book_name; Failed to create query for method public abstract java.util.Optional book.booksmag.repository.SpringDataJpaBookMemberRepository.findByBook_name(java.lang.String)! No property 'book' found for type 'BookMember'! 왜 Book_name이 아니고 'book' 으로 인식되나요? "_"를 쓰면 안되나요? 귀찬게 해서 죄송합니다.
- 0
- 10
- 408
질문&답변
2022.06.29
에러 문의
name이라는 필드는 필수로 있어야하나요? 테이블 구성이 CREATE TABLE BOOK_MAG (BOOK_ID NUMBER(13) PRIMARY KEY, BOOK_NAME VARCHAR(255), BOOK_KDC NUMBER(3), BOOK_PUBLISHER_BUSINESS_NO NUMBER(10), BOOK_PUBLISHER VARCHAR(255), BOOK_AUTHOR_ID NUMBER(9), BOOK_AUTHOR VARCHAR(255), BOOK_MAKE_DATE DATE, BOOK_PRICE NUMBER(13) ); 이런데요?
- 0
- 10
- 408
질문&답변
2022.06.29
에러 문의
빠른 답변 감사합니다. BookMember에 @Entity@Table(name="book_mag")public class BookMember { // @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Id private Long book_id; //BOOK_ID NUMBER(13) PRIMARY KEY private String book_name; //BOOK_NAME VARCHAR(255), private Long book_kdc; //BOOK_KDC NUMBER(3), 상기 처럼 되있고 SpringDataJpaBookMemberRepository에 public interface SpringDataJpaBookMemberRepository extends JpaRepository,Long>, BookMemberRepository { @Override Optional findByName(String book_name);} 상기처럼 했는데도 동일 에러 나오는데요? 어떻게해야할지 모르겠어요? Failed to create query for method public abstract java.util.Optional book.booksmag.repository.SpringDataJpaBookMemberRepository.findByName(java.lang.String)! No property 'name' found for type 'BookMember'!
- 0
- 10
- 408
질문&답변
2022.06.28
BOOK_MAG is not mapped 오류 문의
@Entity@Table(name="book_mag")public class BookMember { @Table을 추가해주니 되네요
- 0
- 1
- 334
질문&답변
2022.06.20
Wrong user name or password ?
spring.datasource.url=jdbc:h2:tcp://localhost/~/testspring.datasource.driver-class-name=org.h2.Driverspring.datasource.username=sa 상기처럼 추가했는데 동일에러 납니다.
- 16
- 5
- 5.1K
질문&답변
2022.06.10
Preferences 어떻게 들어가야 하나요?
윈도우 사용자* File -> Setting 에 들어같는데 Preferences를 못 찿겠어요?
- 0
- 3
- 244