[hibernate-dev] hooking native MongoDB queries on mapped entities

Davide D'Alto davide at hibernate.org
Wed Apr 10 12:24:01 EDT 2013


As an experiment I've added a method to the mongodb provider:
MongoDBDatastoreProvider#(Session session, String sqlString, Class<T>
entityType)
With this method it is possible to execute a native query like "{ $query :
{ author : 'Oscar Wilde' }, $orderby : { name : 1 } }" that will return a
MongoDBOgmCursor that is similar to the DBCursor except that it returns an
Object of the type entityType.

I'm using the same approach used for the OgmMassIndexer therefore the
return type must be en entity.

Do you think something like this can be useful?


On Mon, Apr 8, 2013 at 12:09 PM, Emmanuel Bernard <emmanuel at hibernate.org>wrote:

> From what I understand, this would be equivalent to the
> @NAtiveNamedQuery support in JPA where you define the binding between
> the result set and the objects. We can give it a shot. I wonder how much
> of this is related to the JP-QL query mechanism though and should be
> shared.
>
> Emmanuel
>
> On Sun 2013-04-07 14:19, Sanne Grinovero wrote:
> > Looks like a good idea:
> > https://forum.hibernate.org/viewtopic.php?f=31&t=1025793
> >
> > Davide can you help them figuring out how to hook it all up?
> >
> > Sanne
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list