Skip to content
Advertisement

PostgreSQL’s JSONB data type with Hibernate: Error creating bean with name ‘entityManagerFactory’ defined in class path resource-Unable to load class

Now I learn about nested jsons and geojson and how to save them in PostgreSQL as JsonB directly in database and before starting.

Inspiration source: https://thorben-janssen.com/persist-postgresqls-jsonb-data-type-hibernate/

Error I get when running the app:

JavaScript

Here is the Main Entity:

JavaScript

Here is the geojson(nested json) I want to save as Jsonb in a column in database:

JavaScript

Here is the implementation of Usertype for my json:

JavaScript

here is the registration of hibernate dialect:

JavaScript

App.properties:

JavaScript

and finally, here is the POM.xml

JavaScript

I don’t understand why i get the error about the FeatureType, if anyone can help me. Thank you!

Advertisement

Answer

I found an way easier solution working for hibernate 5 or higher:

Found a different approach that worked as expected:

JavaScript

Base Entity:

JavaScript

Main entity:

JavaScript

Geojson(nested json) I want to save as Jsonb in a column in database:

JavaScript

I’m not sure yet why I was not able to use @TypeDefs directly on “Geojson” class, and i needed to create a BaseEntity, but it works.

PS: If you tried storing some other type of data before, please make sure that you drop the table and create a new one before running the app, since the table was created with a different variable type for that column.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement