Reputation: 125
I have MongoDB database called test with collection called USstates. Now I connect to db using Eclipselink
EntityManagerFactory emf = Persistence.createEntityManagerFactory("mongo");
EntityManager em = emf.createEntityManager();
But find operation always return null. In MongoDB shell to use find I need to type
db.USstates.find({...})
I don't know where to define in my application that I want to use USstates collection. In persistence.xml I specify connection but not collection:
<property name="eclipselink.nosql.property.mongo.port" value="27017"/>
<property name="eclipselink.nosql.property.mongo.host" value="localhost"/>
<property name="eclipselink.nosql.property.mongo.db" value="test"/>
So... where should I notify my application that I want to use USstates? or it is not necessary?
Upvotes: 0
Views: 292
Reputation: 26
Collection name is specified in class in @NoSql anotation as value of dataType.
Example:
@Entity
@NoSql(dataType="USstates", dataFormat=DataFormatType.MAPPED)
public class UsStatesClass {
...
}
Upvotes: 1