Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1102327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:10:08+00:00 2026-05-17T01:10:08+00:00

The Spring MVC binding mechanism is powerful, but I’m now confronted with a trivial

  • 0

The Spring MVC binding mechanism is powerful, but I’m now confronted with a trivial issue that I wonder how to resolve:

  • User JPA entity, that is used for the binding and validation as well (i.e. throughout all layers)
  • “Edit profile” page, that is not supposed to change the password or some other entity properties

Two ways that I can think of:

  1. Using the same object

    • use @InitBinder to configure a list of disallowed properties
    • obtain the target user (by id)
    • then use a reflection utility (BeanUtils) to copy the submitted object to the target object, but ignore null values – i.e. fields that are not submitted
  2. Introduce a new object that has the needed subset of fields, and use BeanUtils.copyProperties(..) to merge it to the entity.

Alternatives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:10:09+00:00Added an answer on May 17, 2026 at 1:10 am

    I’ve found that as soon as your web model starts to diverge from your business layer in function, it’s best to use a view layer object (a model object) to collect, or display the data

    the entity:

    public class com.myapp.domain.UserEntity {
    
    }
    

    the model object:

    public class com.myapp.somesite.web.SomeSiteUserModel {
    
       public static SomeSiteUserModel from(UserEntity userEntity) {
          ... initialize model ...
       }
    
       public UserEntity getModelObject() {
          ... get entity back ... 
       }
    
    }
    

    now all view based operations can hand off processing to the internal model object if that makes sense, otherwise it can customize them itself. Of course the problem with this is you have to re-write all the getters and setters you want for the entity (an issue that I’ve had to deal with, that is annoying) unfortunately that is a bit of a Java language issue

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found that, by default when I using Spring MVC, 2010/01/02 binds correctly, but
Spring MVC uses a DispatcherServlet to route control to an appropriate Controller. But where
With Spring MVC, you can specify that a particular URL will handled by a
I am using spring mvc in my application,when i created user i have to
I'm building a Spring MVC app with Spring 3.0.3. I have data binding of
Is it possible to give Spring MVC's form binding some kind of type hint
In my Spring MVC project I have an update page for Class1 that must
I've been using Spring MVC for three months now. I was considering a good
I have an MVC spring application where the user logs on, this stores a
JSON.NET deserializes it fine, but whatever mvc uses for controller parameter binding barfs hard.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.