0

Does Hibernate OGM support MongoDB DBRefs?

If no, how this support may be added? I guess Hibernate should provide any extension mechanism like custom type mapper, converters or something like that.

Thanks!

PS. Please, be constructive and don't write about "anti-pattern". Sometimes we work according to specific requirements with the legacy products...

S2201
  • 1,339
  • 3
  • 18
  • 35

1 Answers1

1

No, it doesn't support them.

It seems a natural mapping for associations like @OneToOne, @ManyToOne and so on. You would have to change the dialect to achieve this.

An alternative could be the use of the org.hibernate.boot.model.TypeContributor service interface; it will allow you to use the annotation @Type, like @Type(type = "mongodb_ref"). You can have a look at the MongoDBTypeContributor class for an example. It's the class we use to map an ObjectId to the datastore. I'm not sure if using this approach you can also map the fact that it is an association (if you need this information).

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30