forms - Design: What is the best approach to updating part of a database record? -


this question concerns best design approach rather particular technical technique. have database table contains system user's details i.e: username, password, firstname, lastname (these attributes can changed administrator). rest of user record contains address, phone number, mobile number, etc (these attributes can changed user).

i therefore need 2 forms, 'admin' form , 'user' form, different set of editable fields on each, , appropriate role-based security control usage.

here 2 approaches take:

approach 1. each form has it's own backing bean representing editable fields on form. on 'save', backing bean calls specific dao method (e.g. updateuser_admin or updateuser_user) perform partial update of user record. approach therefore involves 2 forms, backing bean each form, , 2 methods in dao class.

approach 2. there 2 forms before, each form re-creates entire user object through use of input fields editable fields , hidden fields non-editable fields. both forms use same backing bean representing of user attributes. there need 1 method in dao - update fields in user record.

the second approach seems make sense me, i'm new development , i'd grateful if readers advise if i'm missing something. i've considered splitting user table 2 separate tables not practical in case. thank advice.

  • as rule: don't create dao methods updating single field / attribute.
  • don't split user entity 2 tables.
  • dao created manage entities, use 1 dao each class , code single update method each dao.
  • if not sure of having complete entity follow steps in service layer

    • get data form (at least id , field want update)
    • retrieve object representing entity database (with dao::readbyid(id) example)
    • update field need in java object
    • call dao::update

      note: ommited populating dto dbo objects


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -