Hello, in this post we will create Service and Repository for Expense. Let’s begin. First, create an ExpenseRepository under src/main/java/in/bushansirgur/expenseyoutube/repository
package
ExpenseRepository.java
@Repository public interface ExpenseRepository extends JpaRepository<Expense, Long> { }
Next, create ExpenseSerive and ExpenseServiceImpl under src/main/java/in/bushansirgur/expenseyoutube/service
package
ExpenseService.java
public interface ExpenseService { List<Expense> findAll(); }
ExpenseServiceImpl.java
@Service public class ExpenseServiceImpl implements ExpenseService { @Autowired ExpenseRepository expenseRepository; @Override public List<Expense> findAll() { return expenseRepository.findAll(); } }
That’s it for this post, let me know in the comment section if you have any questions on this.
Thanks
Bushan SC
HI,
While Fetch the Records from the Table .findAll() works until the Controller
when I print the list in the controller it Not Display the records
it Shows Model@56e9dc84;
Could you please copy my code and compare it with yours? It might be a simple typo error! Let me know the results…
hi sir i am getting error while extending JpaRepository interface.
*************************
APPLICATION FAILED TO START
*************************
Description:
A component required a bean named ‘entityManagerFactory’ that could not be found.
Action:
Consider defining a bean named ‘entityManagerFactory’ in your configuration.
Please Answer.
I have also make a comment on video on youtube.
Thank You.
Hi Bushan
When I tried to print values from expense table its printing com.one.expensemanage.model.Expense@6f432a49