0

I am trying to fetch all the data from a single collection in MongoDB using Hibernate OGM transaction type RESOURCE_LOCAL as follows : Persistence.xml

<persistence-unit name="NOSQLPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
    <class>jpa.nosql.entity.Customer</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.ogm.datastore.provider" value="org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider"/>
      <property name="hibernate.ogm.mongodb.host" value="127.0.0.1"/>
      <property name="hibernate.ogm.mongodb.port" value="27017"/>
      <property name="hibernate.ogm.mongodb.database" value="test"/>
    </properties>
</persistence-unit>

CustomerRepositoryImpl.java

public List<Customer> getAllCustomers() {
    return em.createQuery( "SELECT c FROM Customer c", Customer.class ).getResultList();
}

But I am getting error as below :

org.hibernate.ogm.exception.NotSupportedException: OGM-14 - typed queries are not supported yet

How can I fetch all the data instead of finding single row by Id ?

Sowmya
  • 453
  • 1
  • 5
  • 18

1 Answers1

0

Hibernate OGM should work with the query you are trying to run. I can see some errors in the persistence.xml but I'm not sure they are related to the issue.

Anyway, you should replace your current properties with the following ones:

  <property name="hibernate.ogm.datastore.provider" value="mongodb"/>
  <property name="hibernate.ogm.datastore.host" value="127.0.0.1:27017"/>
  <property name="hibernate.ogm.datastore.database" value="test"/>

You can find more configuration options in the documentation: https://docs.jboss.org/hibernate/stable/ogm/reference/en-US/html_single/#_configuring_mongodb

Also, make sure to have the hibernate-ogm-mongodb dependency on the classpath:

<dependency>
    <groupId>org.hibernate.ogm</groupId>
    <artifactId>hibernate-ogm-mongodb</artifactId>
    <version>5.1.0.Final</version>
</dependency>

If this doen't solve the issue try to add more information about the project, please.

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30