1

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?

4

1 回答 1

2

数据库中的字符串总是有长度的;因为你没有指定一个,它默认为 255。这篇文章告诉你如何改变它:

hibernate属性字符串长度问题

于 2012-09-03T17:10:53.767 回答