Reputation: 1729
I understand what this message means, but I do not understand why it is giving this message. I say this because I'm not trying to update this field.
Column definition:
@Column(name="company_name")
private String companyName;
Then I create a Query using EntityManager.
Query
query = em.createQuery("update Client set companyName = :companyName" +
" where id = :id");
query.setParameter("companyName", client.getCompanyName());
query.setParameter("id", client.getId());
query.executeUpdate();
And the exception reads: Data truncation: Data too long for column 'company_cnpj' at row 1
But I'm not changing the 'company_cnpj' row. Why is it giving me this error?
Upvotes: 1
Views: 9804
Reputation: 3200
Strings in the database always have a length; since you didn't specify one, it defaults to 255. This post tells you how to change it:
hibernate property string length question
Upvotes: 2