-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: No HQL-like querying in OGM?
PostPosted: Wed Nov 04, 2015 7:34 pm 
Newbie

Joined: Thu Apr 07, 2005 8:58 am
Posts: 6
Hi,

I am using OGM and trying to write a query to retrieve a parent object (person) by defining the existence of a child object (email). However, when running this code I obtain the following exception. I can run such a query in Hibernate ORM. Is OGM lacking the ability to convert this query into a native query for my mongodb storage unit?

exception in thread "main" java.lang.IllegalStateException: Can't target multiple types: org.Person already selected before org.Email


Code:
OgmSession ogmSession = em.unwrap(OgmSession.class);
Query query = ogmSession.createQuery("from Person as p " +
"where exists (select e from Email as e where e.email = :email " +
"AND e member of p.emailList)");
query.setParameter("email", email);
return (Person) query.uniqueResult();

person.emailList is a collection of Email entities.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.