Reputation: 1571
I have a mysql database which is latin1 encoded and I want to Serialize into my Entity.
What i'm getting is a strange error, which I think is related with the db encoding:
2016-04-18 23:52:32.765 DEBUG 41409 --- [pool-2-thread-1] org.hibernate.SQL : select newsletter0_.id_customer as id_custo1_0_, newsletter0_.active as active2_0_, newsletter0_.ape as ape3_0_, newsletter0_.birthday as birthday4_0_, newsletter0_.company as company5_0_, newsletter0_.date_add as date_add6_0_, newsletter0_.date_upd as date_upd7_0_, newsletter0_.deleted as deleted8_0_, newsletter0_.email as email9_0_, newsletter0_.firstname as firstna10_0_, newsletter0_.id_default_group as id_defa11_0_, newsletter0_.id_gender as id_gend12_0_, newsletter0_.id_lang as id_lang13_0_, newsletter0_.id_risk as id_risk14_0_, newsletter0_.id_shop as id_shop15_0_, newsletter0_.id_shop_group as id_shop16_0_, newsletter0_.ip_registration_newsletter as ip_regi17_0_, newsletter0_.is_guest as is_gues18_0_, newsletter0_.last_passwd_gen as last_pa19_0_, newsletter0_.lastname as lastnam20_0_, newsletter0_.max_payment_days as max_pay21_0_, newsletter0_.newsletter as newslet22_0_, newsletter0_.newsletter_date_add as newslet23_0_, newsletter0_.note as note24_0_, newsletter0_.optin as optin25_0_, newsletter0_.outstanding_allow_amount as outstan26_0_, newsletter0_.passwd as passwd27_0_, newsletter0_.secure_key as secure_28_0_, newsletter0_.show_public_prices as show_pu29_0_, newsletter0_.siret as siret30_0_, newsletter0_.website as website31_0_ from ps_customer newsletter0_
2016-04-18 23:52:32.769 WARN 41409 --- [pool-2-thread-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: S1009
2016-04-18 23:52:32.769 ERROR 41409 --- [pool-2-thread-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Value '21�
0000-00-00�2016-04-10 18:01:472016-04-10 18:01:[email protected]
172.19.0.202016-04-10 14:01:47Delizia012016-04-10 18:01:47�00.000000 de4a592876ec78ec014eb47a6cd1b49f 849de5fcc5bab384d4b5cc6089e010ed0��' can not be represented as java.sql.Timestamp
If I execute the query on my database I get the result on mysql workbench. It seams that hibernate cannot parse properly the result.
I set the following properties:
spring.jpa.properties.hibernate.connection.characterEncoding=latin1
spring.jpa.properties.hibernate.connection.CharSet=latin1
But it still does not work
Upvotes: 1
Views: 1157
Reputation: 1571
At the end problem was not the charset but a date with value in the database like this: "0000-00-00" that is not suppurted by java.sql.Timestamp or java.sql.Date so I had to add to the connection string the following parameter zeroDateTimeBehavior=convertToNull
so in properties it will be:
spring.datasource.url=jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull
Upvotes: 2