user3056052
user3056052

Reputation: 1467

Using same class for spring mvc model attribute and persistent entity?

Is this possible? If so, how(annotations preferred)?

Is this recommended, if not why not?

Are there any advantages in doing so?

Upvotes: 1

Views: 544

Answers (1)

RMachnik
RMachnik

Reputation: 3684

This is very wide question. Mostly it depentds of your project complication. If you have small one you can use your entities as a data layer int mvc controllers but if your project might be developed more it is good way to have different models for 'entity' or 'data' layers and 'view' layer because between them you can have an service that might combine more entities to one webModel and it might be much better in that case. When you will have different models there are also a place for abstraction and some DesignPatterns between Entities and MVC.

As I said it depends on the scale of your project.

Upvotes: 1

Related Questions