I have create a spring template project with many controllers. In my controllers, I will have a connection to my DAO object and my DAO will save/update/get hibernate objects from my local database.
What is the best way to make this? Should it be implemented on the same project or should I have a project for my controllers and another to represent my database access?
After this, I will develop one android app to call my controllers and make operations on database.
Can you help me this architecture? Thanks
One could certainly argue for either option (having them in the same project or in separate projects). In my projects I tend to take a pragmatic approach to it. If your project is small enough, it probably isn't worth putting them into separate project modules; in this case just having them separated at a package level should suffice. However, as your project scales in size, it will be useful to separate out components based on their responsibilities and dependencies.
I will suggest, however, that you avoid using DAOs directly in your controllers. It isn't necessarily bad practice, but you will find that your controllers will quickly become flooded with business logic (type conversions, data manipulation, etc.) which is better handled somewhere else. Where is this somewhere else exactly? Well, you can build a service layer that bridges the gap between your DAOs and your Controllers. This way, your service layer can deal with data manipulation and other business logic, while your controllers can just worry about getting and serving up data from the service layer. Hope this helps.