Problem displaying data to grid Vaadin 24

Hi, usually i dont have any problem inserting data to Grid, but i got very unique problem that i can’t fix for days.

Why my grid data like this (the row apply all data with the last data column, in my case. like Attachment 1, All row filled with the ‘Balance Available’ data.)?
i tried to reconfigure my grid, and set each column with key. and i got the same result. (if you told me that the data is the problem, its not correct, because i tested it and it return correct data.)

What i do is creating Dialog, and i add Grid to Dialog, i got no problem with different grid.

below is my fullcode for the Dialog below (Attachment 2).

Thank you so much.

EDIT : I tried it with the base entity layout on the grid, it works perfectly. but the placement of each column is not right. so i need to re-position it

if you wonder the Entity.

@Data
@Entity
@Table(name = "payadv_balance")
public class PayadvBalance extends AbstractEntityUUID {

    @JsonProperty("balance_max_amount")
    private double balanceMaxAmount;

    @JsonProperty("balance_used_amount")
    private double balanceUsedAmount;

    @JsonProperty("balance_first_period")
    private LocalDate balanceFirstPeriod;

    @JsonProperty("balance_last_period")
    private LocalDate balanceLastPeriod;

    @JsonProperty("current_available_balance")
    private double currentAvailableBalance;

    @JsonProperty("tp_customer_id")
    private String tpCustomerId;

    @JsonProperty("paid_status")
    @Column(name = "paid_Status")
    private boolean isPaid;
}

image.png

Only thing that comes to mind would be equals or hash code problems - your object is an entity and therefore lombok’s data annotation can cause some interesting problems

And remove your invisible id column

Also remove the IDs und Keys If you don’t need them. If you don’t use preconfigured columns, it’s also unnecessary to pass Bla.class to the grid’s constructor. So that no columns are created and removed from you again. Additionally I can only see a Component annotation, which in case makes this component a singleton which is impossible

NEVER use @Data with JPA. Equals and hashCode are wrong and can lead to stack overflows

thanks for replying!. i tried to remove @Data annotation, and remove all the unnecessary keys but it still return the same.

im using @Data to other entities and added it to other grid it works perfectly.

and yes. this is Component. and it getting called from the main layout with the Entity data.

below is the result if i dont use any addColumn .

and this is my JPA Query

    @Query("select b from PayadvBalance b where b.tpCustomerId = :tpUserId order by b.createdDate desc ")
    List<PayadvBalance> findAllByTpCustomerIdOrderByCreatedDateDesc(@Param("tpUserId") String tpUserId);

image.png

Maybe you have that Data in your entity superclass as well?

That Data annotation (and more specifically default equals/hashCode generation in Lombob) should indeed be killed with :fire:. It is only legid for immutable classes.

Been just today working on an article explaining why.

https://twitter.com/MattiTahvonen/status/1752639768158953663

An Gist made earlier today related to my unfinished article: A code snippet that helps to explain why you should not use @Data annotation or override equals/hashCode without further thinking. · GitHub

And my work in progress JDK PR related to the same issue cluster: Improved the JavaDocs of the equals method by mstahv · Pull Request #16823 · openjdk/jdk · GitHub

thanks for reply!.

“Maybe you have that Data in your entity superclass as well?” No, im using auto generate column and uuid. this is my “AbstractEntityUUID”


@MappedSuperclass
public class AbstractEntityUUID {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;

    @Version
    private int version;

    @JsonProperty("created_by")
    private String createdBy;
    @JsonProperty("created_date")
    private LocalDateTime createdDate;
    @JsonProperty("updated_by")
    private String updatedBy;
    @JsonProperty("updated_date")
    private LocalDateTime updatedDate;

    //getter setter...
}

and yeah. im so sorry because english is not my first language so i dont think i understand the article. but i made it simple.

so what i do is remove the unused column and this is the result (below). and maybe i just need to render the result. is there any way to render the data without addColumn? (im using getColumnByKey but it return this error

Cannot invoke "com.vaadin.flow.component.grid.Grid$Column.setRenderer(com.vaadin.flow.data.renderer.Renderer)" because the return value of "com.vaadin.flow.component.grid.Grid.getColumnByKey(String)" is null
```)
![image.png|1208x751](upload://8SY6sjjaiBaU2oIk6ww1x8ZrG3E.png)

You should post a bit longer stacktrace so we could help.

im sorry, this is the full stacktrace
stacktrace-error.txt (15.4 KB)

anyway. @JsonProperty is not changing the key right? because i use this entity for microservice

btw,
i try to add the renderGrid() to the setBalanceDetail() so it’ll be trigger when component is open. i know this is stupid but i give it a shot
image.png

You server and code is not in sync. You don’t have this line (at least in your snippet you sent) BalanceDetailView.java:186

In the screenshot it is there.

You are referencing to your columns with “key” and there is no such column, that is what the error is about.