Friday, September 17, 2021

Why @Controller,@Service and @Repository are used in spring?

We already know that if we use @Component annotation we can easily identify bean in the IOC container .Then why need to use these special annotation-

@Controller: In MVC pattern @Controller annotation used to define servlet to serve for a http request. 

@Repository :   @Repository is the special annotation for encapsulation storage, retrieval and search behavior on relational database . Their may be any exception while operating certain operation in database but some of them can be handled by using @Repositoy annotation.

@Service:   @Service annotation is used to define business layer in spring .

Specifically annotations are categorized to apply logic on them . Using AOP we can provide special logic on the annotation .

No comments:

Post a Comment

Element of a good table (Ref: Database design mere mortals by Michael J. Hernandez)

  Elements of the Ideal Table: It represents a single subject, which can be an object or event that reduces the risk of potential data integ...