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 6852111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:19:54+00:00 2026-05-27T01:19:54+00:00

I have 4 tables Titles having the following fields, id (PK), Name, AuthorId(FK) &

  • 0

I have 4 tables

  1. Titles having the following fields, id (PK), Name, AuthorId(FK) & PublishedId(FK)
  2. Author having id(FK), Author Name & Contact Details
  3. Publisher having, id(PK), Publisher Name & RegionId(FK)
  4. Region having, id(PK), Region Name, Published Date & Published Cost.

Now in my View, I am accepting

  1. Author Name, and my code looks like

    SearchTemplate _tempTemplate = new SearchTemplate();
    Criterion criterion = null;

        if (rcValue.getOperator().equalsIgnoreCase("like")) {
                        criterion = Restrictions.like(rcValue.getDisplayName(), rcValue.getOperandValue());
                    } else if (rcValue.getOperator().equalsIgnoreCase("is")) {
                        criterion = Restrictions.eq(rcValue.getDisplayName(), rcValue.getOperandValue());
                    } else if (rcValue.getOperator().equalsIgnoreCase("not")) {
                        criterion = Restrictions.ne(rcValue.getDisplayName(), rcValue.getOperandValue());
                    }
    
    _tempTemplate.addCriterion(criterion);
    

When I search for Name, I get the right results, but when I search for my Author Name, what do I need to change in my above code?

2.When I search of Published Date, what do I need to change, because its a multi-table search, if its SQL I can easily write it, but using Hibernate now and with an implementation of ‘SearchTemplate’

/*The SearchTemplate is used to pass search parameters to the DAO layer.
 *
 * By having all the search parameters in one place (the SearchTemplate), 
 * we prevents combinatory explosion of 'find' method signatures in the DAO/Service layer.
 * This leads to more stable DAO/Service interfaces as you can add search parameters to the
 * SearchTemplate without adding new methods to your interfaces.
 *
 * A SearchTemplate helps you drive your search in the following areas:
*/

Can someone help with this?

  • 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-27T01:19:55+00:00Added an answer on May 27, 2026 at 1:19 am

    First question:

    You need to make a join (assuming the root entity is title):

    criteria.createAlias("author", "author");
    criteria.add(Restrictions.eq("author.name", authorName);
    

    Second question:

    same answer: you need to make joins:

    criteria.createAlias("publisher", "publisher");
    criteria.createAlias("publisher.region", "region");
    criteria.add(Restrictions.eq("region.publishedDate", someDate));
    

    This SearchTemplate is a really bad idea, IMO. Instead of having well-defined methods with a clear contract like :

    List<Title> findTitlesWithName(String name)
    List<Title> findTitlesPublishedBy(Long publisherId)
    Title findLatestTitleFromAuthor(String authorId)
    

    You’ll have a single method

    List<Title> findTitles(SearchTemplate criteria)
    

    What must you put in the criteria? What’s the type of the criteria? What will the method do with these criteria? Which ordering will be applied? Which related entities will be fetched or lazily loaded?

    An “explosion” of find methods is a good thing, because each find method has its own contract, optimizations, and goal. Each can also be unit-tested. That’s the goal of a DAO. Without these methods, you might as well have a unique method such as

    List find(String hql, Object[] arguments)
    

    But I fail to see the goal of such a DAO.

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

Sidebar

Related Questions

I have 2 tables: comments & blog blog has the following fields: id(Unique key),title,
I have following tables: products - 4500 records Fields: id, sku, name, alias, price,
I am having issues with the following stored procedure query. I have 3 tables:
I have the following tables: CATEGORIES -- entry_id, cat_id TITLES -- entry_id, title DATA
I have two tables that are related via a mapping table: keywords titles I
I have the following tables: CREATE TABLE title ( booktitle VARCHAR( 60 ), title_id
In my application I have the following tables: Posts id title content Users id
I have two tables: author (id, first_name, last_name) books (id, title, rate, author_id) and
I have the following tables: articles: id, title, content tags: id, tag, tagCategory tags2articles:
I have 3 tables, t1, t2, and t3 as follows: t1 ___ t1id name

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.