kundera icon indicating copy to clipboard operation
kundera copied to clipboard

How to retrive two differnt table's particular filed.

Open sbheda opened this issue 10 years ago • 9 comments

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 ?

sbheda avatar Jul 18 '14 05:07 sbheda

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

chhavigangwal avatar Jul 18 '14 12:07 chhavigangwal

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 avatar Jul 18 '14 12:07 sbheda

@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 avatar Jul 19 '14 15:07 chhavigangwal

@chhavigangwal Thank you for replaying. Currently join queries not supported by kundera but is it in your road map to support join queries ?

sbheda avatar Jul 21 '14 06:07 sbheda

Waiting for your replay.....

sbheda avatar Jul 23 '14 13:07 sbheda

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

chhavigangwal avatar Jul 23 '14 16:07 chhavigangwal

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.

sbheda avatar Jul 24 '14 07:07 sbheda

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

mevivs avatar Jul 31 '14 16:07 mevivs

Does kundera support Inner joins with cassandra ?

idofmrsandeep avatar Mar 29 '18 12:03 idofmrsandeep