I am trying to use the following query:
Code:
public CollectionItem getCollectionItemByItemId(String id)
{
String nativeQuery = "{'item_id':{'$oid' : '" + id + "'}}";
//javax.persistence.Query q = em.createQuery("SELECT item FROM CollectionItem ci WHERE ci.item.id = '" + id + "'");
try
{
javax.persistence.Query query = em.createNativeQuery(nativeQuery, CollectionItem.class);
return (CollectionItem)query.getSingleResult();
}
catch(NoResultException e)
{
//no result
}
return null;
}
The commented out code is a query that is currently not supported. Unfortunately, when I switch to the native query, I run into the existing error of not being able to execute multiple native queries in a single request. That causes the error: "cannot associate the collection with multiple sessions" error. I tried to pull down the latest OGM code and build it to see if some of these issues have been resolved but I ran into trouble there as well.