Custom gridtypes howto

I have found many, many guides to implementing a custom usertype in Hibernate ORM, but when it comes to OGM, the web is almost silent.

I trying to convert a simple project from using a MySQL backend to using Neo4j.

I’m using the latest release of Hibernate OGM (5.3.1).

In my current implementation i have a UserType mapping LocalDateTime and other customer objects to columns in MySQL - works great.

However having moved to OGM, I not get errors like:
Caused by: org.hibernate.HibernateException: OGM000059: Unable to find a GridType for LocalDateTime

How do I correctly handle custom objects like LocalDateTime objects (and other custom objects) in Hibernate OGM?

I have searched for custom GridType and the only example I found pointed me to MongoDBTypeContributor.

But I’m having trouble to translate this to my problem.

Please advice.

Best regards


At the moment there is not a mechanism similar to ORM for custom grid types in OGM.
Depending on the use case, there are 3 ways to add custom types at the moment:

  1. With a TypeContributor like in the example you have already found
  2. with an AttributeConverter, an example is here:
  3. You can extends the base dialect and override the method public GridType overrideType(Type type). You can see an example in this test where it ovverides the method extending MapDialect: Make sure to use your new dialect class by setting the property hibernate.ogm.datastore.grid_dialect with the name of the class

I hope this helps,

Hi DavideD,

Thank you very much for your reply.

Suggestion no. 2 was the way to go for me.

Best regards