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

  • Home
  • SEARCH
  • 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 6680919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:31:52+00:00 2026-05-26T04:31:52+00:00

I have a Java server application with a ton of different entities. So far,

  • 0

I have a Java server application with a ton of different entities. So far, each entity top level entity has its own CRUD service. By top level, I mean the root of a tree of entities that can stand alone.

Now I am getting into the heart of my Flex client and find I am needing/writing many different queries. But where best to put these queries?

Say for example, I have a query to find all “foos” based on their associate with a certain “bar”. Currently that query is on the “foo” service (findAllByBar), but I am finding that it would be very convenient to have it (also?) in the “bar” service (findFoos). On the other hand, I could also create a query service and lump all the queries in there.

Whats a good practice to do here?

  • 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-26T04:31:52+00:00Added an answer on May 26, 2026 at 4:31 am

    Try to layer your application in these perspectives:

    • Domain: design your class as entities like “Customer”, value objects like “Address” or “Color”, and aggregate roots (like “Order” which includes a list of “LineItem”)

    • Repositories: these are the data access for the entities, create a repository for each aggregat root (CustomerRepository, OrderRepository, …)

    • Services: create a coarse grained services spitted by logical business abstractions or bounded context not by entities, it is not logical to create a service for order and a service for items and a service for customers when all these entities are representing one atomic business value of order processing, then your service will use all required repositories to handle the data access.

    example:

    public class OrderRepository {
      public Foo getById(int id) {
         // 
      }
    
      public Foo getByCustomer(Customer customer) {
        //
      }
    }
    
    public class CustomerRepository {
      public Foo getById(int id) {
         // 
      }
    
      public Foo getByUserName(string userName) {
        //
      }
    }
    
    public class TradingService {
      private OrderRepository _orderRepository;
      private CustomerRepository _customerRepository;
    
      public TradingService(OrderRepositoryInterface orderRep, CustomerRepositoryInterface cusRep) {
        _orderRepository = orderRep;
        _customerRepository = custRep;
      }
    
      public void placeOrder(string customerUserName, Order order) {
        Customer customer = _customerRepository.getByUserName(customerUserName);
        order.setCustomer(customer);
        _orderRepository.add(order);
        // ....
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server application in Java which has two simple operations, addTwoInts and
I have a Java based web-application using Java Server Faces and Facelets. I am
I have a client-server application written in Java using CORBA for the communication. The
We have a java application which run as server running on a remote windows
i have a server - client application that runs on java 1.3; i want
We have a Java EE-based web application running on a Glassfish app server cluster.
I have a server behind a firewall. It runs a web application (Java servlets
I have a Java client - server application. The client is designed to run
we have a java server-client application with an applet in the client side. our
i have a web application built with HTML(front-end),java(server-side) and i have a textarea when

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.