This repository was archived by the owner on Dec 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +11
-17
lines changed
src/main/java/xyz/marontedev/springboot/datajpaapp Expand file tree Collapse file tree 4 files changed +11
-17
lines changed Original file line number Diff line number Diff line change 1313import java .util .Map ;
1414
1515@ Controller
16- @ SessionAttributes ("cliente " )
16+ @ SessionAttributes ("client " )
1717@ RequestMapping ("/client" )
1818public class ClientController {
1919 @ Autowired
Original file line number Diff line number Diff line change 11package xyz .marontedev .springboot .datajpaapp .models .dao ;
22
3- import org .springframework .stereotype .Repository ;
3+ /* import org.springframework.stereotype.Repository;
44import xyz.marontedev.springboot.datajpaapp.models.entity.Client;
55import javax.persistence.EntityManager;
66import javax.persistence.PersistenceContext;
@@ -38,4 +38,4 @@ public void delete(Long id) {
3838 em.remove(findOne(id));
3939 }
4040
41- }
41+ }*/
Original file line number Diff line number Diff line change 11package xyz .marontedev .springboot .datajpaapp .models .dao ;
22
3+ import org .springframework .data .repository .CrudRepository ;
34import xyz .marontedev .springboot .datajpaapp .models .entity .Client ;
45
56import java .util .List ;
67
7- public interface IClientDao {
8- public List <Client > findAll ();
9- public void save (Client client );
10- public Client findOne (Long id );
11- public void delete (Long id );
8+ public interface IClientDao extends CrudRepository <Client , Long > {
9+
1210}
Original file line number Diff line number Diff line change 33import org .springframework .beans .factory .annotation .Autowired ;
44import org .springframework .stereotype .Service ;
55import org .springframework .transaction .annotation .Transactional ;
6- import xyz .marontedev .springboot .datajpaapp .models .dao .ClientDaoImpl ;
6+ import xyz .marontedev .springboot .datajpaapp .models .dao .IClientDao ;
77import xyz .marontedev .springboot .datajpaapp .models .entity .Client ;
8- import xyz .marontedev .springboot .datajpaapp .models .service .IServiceClient ;
9-
10- import javax .persistence .EntityManager ;
11- import javax .persistence .PersistenceContext ;
128import java .util .List ;
139
1410@ Service
1511public class ClientServiceImp implements IServiceClient {
1612 @ Autowired
17- private ClientDaoImpl clientDao ;
13+ private IClientDao clientDao ;
1814
1915 @ Override
2016 @ Transactional (readOnly = true )
2117 public List <Client > findAll () {
22- return clientDao .findAll ();
18+ return ( List < Client >) clientDao .findAll ();
2319 }
2420
2521 @ Override
@@ -31,12 +27,12 @@ public void save(Client client) {
3127 @ Override
3228 @ Transactional (readOnly = true )
3329 public Client findOne (Long id ) {
34- return clientDao .findOne (id );
30+ return clientDao .findById (id ). orElse ( null );
3531 }
3632
3733 @ Override
3834 @ Transactional
3935 public void delete (Long id ) {
40- clientDao .delete (id );
36+ clientDao .deleteById (id );
4137 }
4238}
You can’t perform that action at this time.
0 commit comments