Open kaushal-bhatt opened 2 years ago
package com.card.entities;
import javax.persistence.*;
@Entity @Table(name="CARD_NUMBER") public class CardNumber {
public CardNumber(String cardNumber,Long id) { this.cardNumber = cardNumber; this.id=id; } public String getCardNumber() { return cardNumber; } public void setCardNumber(String cardNumber) { this.cardNumber = cardNumber; } @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column(name = "card_number") private String cardNumber; public CardNumber() { }
}
try this for you entity file
and in controller do like this and check your mistakes
@RestController public class CardController {
@Autowired private CardRepo cardRepo; @GetMapping("/getForm") public String getForm() { return "card"; } @PostMapping("/savecard") public String saveDetails(@RequestBody CardNumber cardNumber) { // write your code to save details System.out.println(cardNumber.toString()); cardRepo.save(cardNumber); return "saved "+ cardNumber.getCardNumber(); }
For now promoted to next round be prepared
package com.card.entities;
import javax.persistence.*;
@Entity @Table(name="CARD_NUMBER") public class CardNumber {
}
try this for you entity file
and in controller do like this and check your mistakes
@RestController public class CardController {
}