ZZ 5
ZZ 5

Reputation: 1964

Spring MVC model for multiple forms

I have model called User, which is also an entity. I use it in multiple forms, however sometimes I'd like to put there some values that my model doesn't have. For example I've got model User with fields username, password, email. Now I'd like to pass value of field that my model doesn't contains, e.g. rememberMe. I don't know how to solve this, for me there are 2 options:

A) I extended the model/entity with field rememberMe annotated as @Transient so it doesn't put useless information to my DB

B) I create another model class with field rememberMe and so on - new model for every page that requires it.

Upvotes: 1

Views: 71

Answers (1)

jpprade
jpprade

Reputation: 3684

I often implement your choice A). It is easy and fast, but break a little bit the separation of concern.

For B) choice you can make a UserForm class that extends the User class with rememberMe property.

Upvotes: 2

Related Questions