# Findall method does not get all attributes of the class

**URL:** <https://discourse.hibernate.org/t/findall-method-does-not-get-all-attributes-of-the-class/7558>\
**Category:** Miscellaneous\
**Created:** [April 26, 2023, 6:57pm UTC](https://discourse.hibernate.org/t/findall-method-does-not-get-all-attributes-of-the-class/7558 "2023-04-26T18:57:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_DeGre](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/christophe_degre/32/2318_2.png) [@Christophe\_DeGre](https://discourse.hibernate.org/u/Christophe_DeGre)\
**Post date:** [April 26, 2023, 6:57pm UTC](https://discourse.hibernate.org/t/findall-method-does-not-get-all-attributes-of-the-class/7558/1 "2023-04-26T18:57:18Z")

</div>

My issue: i use findall method via JPArepository interface to interact with a mysql database. Findall returns a only **4 attributes** of my class among 10. All entries are returned but are not complete. Furthermore when i make an axios post from my frontend react application only the **same 4 fields** are recorded inside database, the remaining 6 attributes are null inside the table. here are my settings:

```auto

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/userdatabase?useSSL=false&serverTimezone=UTC
spring.datasource.username=xxxxxx
spring.datasource.password=xxxx
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql: true
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.format_sql=true

```

If you want to see any part of my code i can send it.

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [April 27, 2023, 7:22am UTC](https://discourse.hibernate.org/t/findall-method-does-not-get-all-attributes-of-the-class/7558/2 "2023-04-27T07:22:17Z")

</div>

Yeah, share all the code and then we can talk further.

---

<div class="post-metadata">

**Author:** ![Christophe\_DeGre](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/christophe_degre/32/2318_2.png) [@Christophe\_DeGre](https://discourse.hibernate.org/u/Christophe_DeGre)\
**Post date:** [April 27, 2023, 6:21pm UTC](https://discourse.hibernate.org/t/findall-method-does-not-get-all-attributes-of-the-class/7558/3 "2023-04-27T18:21:38Z")

</div>

```auto
Sure! here is my user class:
import jakarta.persistence.*;

import java.sql.Date;
import java.util.Objects;
import java.util.Random;
import java.util.Set;

@Entity
@Table(name = "usertable")
public class User {

    public User() {

    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)

    private long user_id;

    @Column

    private String lastName;

    public enum Role {
        Student, Teacher, Admin
    }

    public enum Level {
        Primaire, Collège, Lycée, Supérieur
    }

    @Column

    private String firstName;
    @Column

    private Level level;
    @Column

    private String city;

    @Column

    private String picture;
    @Column

    private String pseudo;
    @Column

    private String email;
    @Column

    private String password;
    @Column

    private String phone;
    @Column

    private Date dateOfBirth;

    @Column

    private Role role;

    public User(String lastName, String firstName, Level level, String city, String picture, String pseudo, String email, String password, String phone, Date dateOfBirth, Role role) {

        this.lastName = lastName;
        this.firstName = firstName;
        this.level = level;
        this.city = city;
        this.picture = picture;
        this.pseudo = pseudo;
        this.email = email;
        this.password = password;
        this.phone = phone;
        this.dateOfBirth = dateOfBirth;
        this.role = role;

    }

    public User(int user_id, String lastName, String firstName, Level level, String town) {
        super();
        this.user_id = user_id;
        this.lastName = lastName;
        this.firstName = firstName;
        this.level = level;
        this.city = town;
    }

    public long getUser_id() {
        return user_id;
    }

    public void setUser_id(int user_id) {
        this.user_id = user_id;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public Level getLevel() {
        return level;
    }

    public void setLevel(Level level) {
        this.level = level;
    }

```

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [April 28, 2023, 6:50am UTC](https://discourse.hibernate.org/t/findall-method-does-not-get-all-attributes-of-the-class/7558/4 "2023-04-28T06:50:39Z")

</div>

> [@Christophe\_DeGre](#):
>
> Findall returns a only **4 attributes** of my class among 10

What does that mean exactly? Can you show some sample code with assertions that fail but shouldn’t? Don’t forget that if your table rows have null column values, they will be null in the Java objects as well. Some JSON serialization libraries omit attributes for null values.
