Here we are dealing with the persistence of objects coming from the browser. We need to ensure that, in the database, there is no difference between the name of the Manufacturer all in High Cash or all in Low Cash.
Assuming that the information entered by the user is the right one most of the time, we should not (most of the time) touch the data and coerce it. Not even coercion to force high/low cash.
Ideally, DBMS should treat this column as insensitive to the case/case insensitive. You can specify how the column will be created using the property columnDefinition
annotation @Column
. For example, in the international SO, they did an example of changing the collation one-column for latin1_general_cs
.
In the case of Mysql, there are several leotard and ways to place yourself in a column. If the value of leotard is omitted, it will use the default for the table; if this is also omitted, it will use what is configured in the database.
In our case, we want to make sure you’re insensitive to the case, so we can put it in the column:
// baseado no exemplo do link do SO internacional
@Column(name = "NAME_COL", columnDefinition = "VARCHAR(250) COLLATE latin1_general_ci")
private String name;
Recommended reading:
What is DBMS? Mysql, SQL Server, Sqlite?
– Jefferson Quesado
I am using Mysql
– user67378
A priori, let the bank take care when making comparisons. This you guarantee in the creation of the table. I will try to describe better in a reply
– Jefferson Quesado
in the case I’m using JPA and Hibernate, I don’t know if there are any notes or anything like that that can facilitate.
– user67378