I will answer first to the quertion about the queries.
Hibernate OGM converts queries into proper calls to the MongoDB java driver API. It means that it doesn’t generate an equivalent query that can be run using the Mongo CLI client.
So it cannot print the native query.
About the indexes, I think something is wrong in your mapping.
You are using @Inheritance(strategy = InheritanceType.SINGLE_TABLE) but the super class is not an entity and therefore doesn’t have a table (in theory) and it wouldn’t make sense to inherits the name of the table for all the children of the hierarchy. Probably, OGM is ignoring it.
I think you need to declare the indexes on GridListEvent because that’s the entity mapped to the table “BigEvent” (Very confusing by the way).
An alternatve solution that might work is to replace the @MappedSuperclass with @Entity but I wouldn’t go this way because it makes the mapping harder to understand.
I see, the thing I find confusing is that you use @Table(name="BigEvent")
on the entity GridListEvent. You don’t need to tell Hibernate OGM about it. Because of the inheritance configuration it will figure it out on its own.
If in your example replace @MappedSuperClass with @Entity, it should work though.
I gave a better look at this issue and the problem is that @MappedSuperclass is used when you want to inherit properties, associations, and methods.
In this case you are actually creating a hierarchy between entities, therefore @Entity should be used. That’s because you want to have a single table mapping different entities (I think). Otherwise you wouldn’t use InheritanceType.SINGLE.
You can map the entities in the following way:
@Entity
@Table( name = "BigEvent",
indexes = {
@Index(columnList = "type", name = "type_idx"),
@Index(columnList = "activity_id", name = "activity_id_idx")
})
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type")
public abstract class BigEvent implements Serializable {
...
}
@Entity
public class GridListEvent extends BigEvent implements Serializable {
...
}
@Entity
public class OtherEvent extends BigEvent implements Serializable {
...
}