Announcement Announcement Module
Collapse
No announcement yet.
MongoDB--Inheritance. Multiple docs saved in same collections Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MongoDB--Inheritance. Multiple docs saved in same collections

    Hey guys,
    I can't find if document inheritance is supported in Spring-data-mongodb. If so, does it use discriminator and how?
    Say I have the following classes...

    @Document(collection="coll")
    public class Parent{
    @Id
    private String id
    private String type
    }

    @Document(collection="coll")
    public class Child1 extends Parent{
    private String prop1
    }

    @Document(collection="coll")
    public class Child2 extends Parent{
    private String prop2
    }

    They all need to go to the same collection, They have a "discriminator" called type (can be used as a discriminator). I want the saves to all work and queries to be polymorphic. How can I do this? I can implement this myself without using discriminator etc, but wanted to see if Spring-data already supports this.

    Thanks so much.
Working...
X