Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:32:45+00:00 2026-05-30T19:32:45+00:00

The problem is about searching by query in different collections. There is a method

  • 0

The problem is about searching by query in different collections.

There is a method in AdvancedDatastore interface:

<T> Query<T> createQuery(String kind, Class<T> clazz, DBObject q);

But its only create query with given baseQuery and I need full clone of Query but with different DBCollection field.
Any suggestions?

Here is my method to convert query:

public Query<Vacancy> convertQuery(Query<T> query) {
        QueryImpl<T> queryImpl = (QueryImpl<T>) query;
        DBObject dbO = queryImpl.getQueryObject();
        Query<T> our_query = ((AdvancedDatastore)this.getDatastore()).createQuery("AnotherCollectionName", T.class, dbO);           
        return our_query;
    }

Update

Works fine with reflection, but I dont like this dirty way because of perfomance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:32:47+00:00Added an answer on May 30, 2026 at 7:32 pm

    That looks like a good solution for now. You cannot change the underlying collection/kind once a query is created — it is immutable.

    If you want this functionality one would need to implement a deep clone operator for the Query/QueryImpl or request that be done in morphia.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading about the problem of passing empty std::string objects between DLLs and EXEs,
In my question about searching for date ranges I tried simplifying the problem and
I have a problem about searching a text. I think it is Ja because
I did spend an hour searching before I posted about this problem. The table
I'm searching about my problem here and find some tips, but doesn't work anyway,
I have a problem about div position relative alignment. I want the second div
I have a little problem about using jQuery (I really do not know jQuery
I've got a problem about onbeforeunload recently that I need to pop up a
I have hit upon this problem about whether to use bignums in my language
I have got a strange problem about in_array recently which I cannot understand. e.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.