kundera
kundera copied to clipboard
How to retrive two differnt table's particular filed.
Hi, I have two table and i want to get particular column value in select query in mongoDB. My JPQL query is :
Query q = em.createQuery(" select emp.name , prj.name form Employee emp , Project prj where emp.ID = prj.employee.id")
Isit possible in mongoDB ?
You can select particular columns in select query in mongoDB. However, in order to retrieve the data from multiple tables having relations you need to define associations in entity objects and query them . A sample entity class :
https://github.com/impetus-opensource/Kundera/blob/trunk/src/kundera-mongo/src/test/java/com/impetus/client/crud/compositeType/association/UserInfo.java
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "user_id")
private List<MongoPrimeUser> timeLine;
and corresponding test case can be found at : https://github.com/impetus-opensource/Kundera/blob/trunk/src/kundera-mongo/src/test/java/com/impetus/client/crud/compositeType/association/UserInfoTest.java
selectiveColumnTweetBodyWithAllCompositeColClause = "Select u.firstName from UserInfo u where u.userInfoId = :id";
Chhavi
Thank you chhavigangwal for replay. I got one field values from one entity but if i want to get two different fields from two entities using join then is it possible in mongoDB ?
@sbheda
Currently you cannot select the specific column of associated entity in mongoDB using Kundera. However , we will add this support soon in the trunk.
Also, join queries are not supported in Kundera. It handles related data via associations.
Chhavi
@chhavigangwal Thank you for replaying. Currently join queries not supported by kundera but is it in your road map to support join queries ?
Waiting for your replay.....
Two things here :
- MongoDB does not support joins and so, at times, requires bit of denormalization. For better understanding modelling using MongoDB you can refer to : http://docs.mongodb.org/ecosystem/tutorial/model-data-for-ruby-on-rails/.
- Join queries are not really needed in case of NoSQL and since main idea behind Kundera is to make working with NoSQL easier, supporting join queries is much a part of road map as of now.
Hope that Helps! Chhavi
It's difficult to us to denormalize data as of now.
join query will help us lot
Is there any approximate date when you are going to release join query support. It will help us to plan our development accordingly.
IMHO, being a high level api, Kundera allows to work and build generic platform to interact with multiple nosql datastores. But it doesn't encourage to use all JPA type features with Nosql datastores. Ideally Applications must avoid joins,relations etc with nosql datastores and that's why those are not supported with nosql datastores e.g. Mongodb. Try to build a map-reduce or stream processing use case for the same. Doing such in-memory computation is not an option and should be avoided.
-Vivek
Does kundera support Inner joins with cassandra ?