Problem entering data into database

Asked

Viewed 105 times

0

I am trying to insert a mass of data into the Mysql database using Hibernate. However I have the following error:

18:15:30,221 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 59) HHH000388: Unsuccessful: INSERT INTO tb_pessoa_fisica (id,nome,cpf,telefone_comercial,telefone_residencial,telefone_celular,email,idade,data_nascimento) VALUES (92,"Zeph Damon Maddox","64871487509","(14)3523-6032","(55)8246-5275","(38)7000-8218","[email protected]",58,"2015-04-26")
18:15:30,221 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 59) Data truncation: Data too long for column 'cpf' at row 1

My attribute is like this in java:

@NotBlank
@Pattern(regexp="\\d{11}", message="ATENÇÃO: Deve ser informado 11 dígitos!")
@Column(columnDefinition="char(11)", nullable=false)
private String cpf;

Someone help me understand this problem and solve it?

  • check these parameters <Property name="Hibernate.hbm2ddl.auto" value="update"/> <Property name="Hibernate.dialect" value="org.hibernate.dialect.Mysql5dialect"/> No persistence.xml

  • @Marcelo Está assim: <!-- language: java --> <Property name="Hibernate.hbm2ddl.auto" value="create-drop" /> <Property name="Hibernate.show_sql" value="true" /> <Property name="Hibernate.dialect" value="org.hibernate.dialect.Mysql5dialect" /> <Property name="Hibernate.format_sql" value="true" /> <Property name="Connection.pool_size" value="5" />

2 answers

1

18:15:30,221 ERROR [org.hibernate.tool.hbm2ddl.Schemaexport] (Serverservice Thread Pool -- 59) Data truncation: Data Too long for column 'Cpf' at Row 1

I noticed that the row above is giving problem in the CPF column

The information is very large and being cut (truncation). See if your cfp column is String? How are the annotations in this column ?

Check if there are no problems post the class to check.

0


The main problem was that Hibernate did not delete this table in question, before there was a field problem with a lower value than it had tried to insert. After manually deleting the table, I started again and it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.