I need to look for a “client” in db, what would be a good design here?

We are a couple of students trying to implement a design to search for customer information in a database. When a GUI class asks any client with the last name "Jensen" whether the client class will create many objects for each client with that last name, provide all these objects to the GUI class, allow the GUI class, for example, change something or add something Anything, and then use some method in the customer class to update it in the database?


Customer class:
  Surname
  Email

getSurname()
setSurname()

static List getCustomerFromDb(surname, email):
  Customer customer = new Customer()
  customer.setSurname(surname from db)
  ..
  ..
  return listOfCustomers

updateThisCustomerInDb():
  //updates all fields in db

Our implementation now is that we send the ResultSet to the GUI class from the static method in the client to search for clients. And if the GUI class wants to change the field, such as email in the client, it sends a HasMap with changes to the keys and values.

300 ?

, , , , OO-, , , ( ) , , ResultSets HasMaps.

=)

+3
5

, ORM-, Hibernate, , , , :

DAO Design. , . , , , , . :

public class Customer {

    private String surname;
    private String email;
    private long id;

    public String getSurname() {
        return surname;
    }
    public void setSurname(String surname) {
        this.surname = surname;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

}

, , .

, , , db- . , .

+4

<speculation>
.net, , ResultSet , 300 ( ?) - . 300, , , , , , ( ).
</speculation>
- - . GUI , , ( ).
. - , .

+1

, . , 50 000 000 ?

! , , , . , , , , , .

, .

+1

, , , , , , , .

, .

0

:

  • 300 Jensen, .
  • 1 Jensen 299 .

, 300 , , 300. -, .

Plus, it's also nice to separate DB code (converting ResultSets into objects) from the graphical interface. The idea with the DAO template is justified here.

Hope this helps

EDIT: enter pressed too early

0
source

Source: https://habr.com/ru/post/1718170/


All Articles