recently I have changed the packages of the entities already persisted. Some works fine however I find this one:
Exception in thread “pool-1-thread-1” org.hibernate.type.SerializationException: could not deserialize
Caused by: java.lang.ClassNotFoundException: persistencia.BooleanObservable
Which has to be cat.tactictic.servidorTerrats.persistencia.BooleanObservable.
The persistence.xml and mapping.xml files are already changed. I think, it happens when reading.
I hope someone helps to solve this. Thank you.
BooelanObservable is just a class with a boolean inside. (Call me silly).
DiaSetmana is an entity that has this BooleanObservable inside. And the two things I did wrong:
instanciate BooleanObservable without using the import statement so in the declaration looked like this:
- seleccionat = new (persistencia.BooleanObservable());
- and I had to change it to seleccionat = new (cat.tactictic.servidorTerrats.persistencia.BooleanObservable());
- it might have been declared using the import:
seleccionat = new BooleanObservable();
didn’t use embbeded in jpa declaration
Nowadays, I have updated diasetmana to use the import statement and I have inserted the embedded and embeddable inside the mapping file. And the error comes just starting the server: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL “alter table DiaSetmana add column valorBoolea boolean not null” via JDBC Statement
Caused by: org.postgresql.util.PSQLException: ERROR: column “valorboolea” contains null values
So is there a way to arrange this? Or the solution is the replication of the database through a program where the two definitions work together? The older to read the entities and the newer to insert the values into a new database?
Thank you for reading it,
The exception that you get is due to the fact that you use hbm2ddl update which is definitely not recommend for production use. Apparently you changed the column valorboolea to be not-null which Hibernate now tries to apply on the database. You should use a migration tool like Liquibase or Flyway to migrate your database instead where you can be in full control of how to migrate data to the new schema.