[Java] What is the difference between form, entity and dto? [Bean]

Rookie @ Java When I was reviewing the source code during the training, I was uncertain, so I looked it up.

Difference between form, entity and dto

** ・ ・ ・ There is no difference in appearance. ** ** Really, really. The contents are (almost) unchanged, only the usage is different. All three are just beans. Rookie: beginner: If you think that form, entity and dto are "bean nicknames that indicate how to use them", I think: ok: for the time being.

What is a bean

It's a class like this. There are various properties, and they have setter / getter methods for those properties.


public class MemberBean {
    private String name;
    private int age;

    public String getName() {
        return this.name;
    public void setName(String name) {
        this.name = name;

    public int getAge() {
        return this.age;
    public void setAge(int age) {
        this.age = age;

In the above: arrow_up: example, the class name is "MemberBean",

--For form: MemberForm --For entity: Member --For dto: MemberDto

I think that it often happens.

form features

--Contains the value (= form tag content) sent by the HTTP POST method. ――So, I feel like I don't use it much except for web services. ――Because it is the contents of the form tag, you should remember that the name of the bean is also form. --The class name is often "xxxForm".

Characteristics of entity

--Enter the value to be registered / updated in the DB. --Hold the value obtained from DB. --Class names and table names are often the same.

Features of dto

--The abbreviation for Data Transfer Object is dto. --As the name suggests, a bean for exchanging data. ――It's enough not to use it at the training level for newcomers ... Or is there often no need to use it?

Data exchange means, for example, conversion from form to entity. For example, in form, the input is divided into year / month / day, but if the date of birth is of Date type on the DB, it is necessary to combine at some timing. In this case, if you edit the form or entity directly, you may not be able to restore the original data if something happens. To avoid that, put it in dto once ...


** form, entity and dto are all Bean **, and they are only named because they have different purposes. Personally, I think it is difficult to find the significance of using three beans properly in a new employee training level program. However, when trying to create a large-scale system, I feel that the beans according to the purpose take control of the entire system (at the program level).

Recommended Posts

[Java] What is the difference between form, entity and dto? [Bean]
[JAVA] What is the difference between interface and abstract? ?? ??
What is the difference between Java EE and Jakarta EE?
What is the difference between a class and a struct? ?? ??
[Rails] What is the difference between redirect and render?
What is the difference between an action and an instance method?
What is the difference between a web server and an application server?
[Java] Understand the difference between List and Set
Difference between Java and JavaScript (how to find the average)
What is the LocalDateTime class? [Java beginner] -Date and time class-
Jersey --What is Difference Between bind and bindAsContract in HK2?
[Java] Check the difference between orElse and orElseGet with IntStream
Is short-circuit evaluation really fast? Difference between && and & in Java
[Java] Difference between Hashmap and HashTable
Understand the difference between each_with_index and each.with_index
[JAVA] Difference between abstract and interface
[Java] Difference between array and ArrayList
[Java] Difference between Closeable and AutoCloseable
[Java] Difference between StringBuffer and StringBuilder
[Java] Difference between length, length () and size ()
What is the difference between the responsibilities of the domain layer and the application layer in the onion architecture [DDD]
Difference between final and Immutable in Java
[For beginners] Difference between Java and Kotlin
What is the best file reading (Java)
What is Java and Development Environment (MAC)
What is the main method in Java?
[Java] Difference between Intstream range and rangeClosed
Difference between int and Integer in Java
Java vs. JavaScript: What ’s the Difference?
Understand the difference between int and Integer and BigInteger in java and float and double
What is java
What is Java <>?
What is Java
[iOS] Understand the difference between frame and bounds
[Rails / ActiveRecord] About the difference between create and create!
What is the Java Servlet / JSP MVC model?
Difference between next () and nextLine () in Java Scanner
Understand the difference between abstract classes and interfaces!
What is the volatile modifier for Java variables?
Summarize the differences between C # and Java writing
[Java] Difference between "final variable" and "immutable object"
[Java] Difference between equals and == in a character string that is a reference type
[Ruby] What is the slice method? Let's solve the example and understand the difference from slice!
[Ruby] I thought about the difference between each_with_index and each.with_index
The comparison of enums is ==, and equals is good [Java]
Is there a performance difference between Oracle JDK and OpenJDK at the end of 2017?
What is Java Encapsulation?
[Java] Difference between static final and final in member variables
[Java] Note about the difference between equivalence judgment and equality judgment when comparing String classes
What is Java technology?
What is Java API-java
[Java] The difference between the Stream.of () and Arrays.stream () methods that you do not know unexpectedly
Difference between vh and%
[Rails] I investigated the difference between redirect_to and render.
[Java] What is flatMap?
Difference between i ++ and ++ i
[Java] What is JavaBeans?
[Swift] UITextField taught me the difference between nil and ""
[Java] What is ArrayList?
[Java beginner] Difference between length and length () ~ I don't know ~
Regarding the difference between Java array and ArrayList, I compared and corresponded methods with similar functions.