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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:55:17+00:00 2026-06-17T08:55:17+00:00

I have below method in my DAO class. public PublishAction findbyLatestPublishedDate(int tcmURI,int pubID) throws

  • 0

I have below method in my DAO class.

public PublishAction findbyLatestPublishedDate(int tcmURI,int pubID) throws StorageException
{
    log.info("Entering Method: JPAPublishActionDAO.PublishAction.findbyLatestPublishedDate");
    StringBuilder queryBuilder = new StringBuilder();
    queryBuilder.append("select pa from PublishAction pa where pa.id in(select pb.id from PublishAction pb where pb.ITEM_REFERENCE_ID=:tcmURI and pb.PUBLICATION_ID=:pubID and rownum <= 1 order by pb.LAST_PUBLISHED_DATE desc)");

    Map<String, Object> queryParams = new HashMap<String, Object>();   
    queryParams.put("ITEM_REFERENCE_ID", tcmURI);
    queryParams.put("PUBLICATION_ID", pubID);

    log.debug("JPAPublishActionDAO findbyLatestPublishedDate -> queryBuilder- "+ queryBuilder.toString());        
    return executeQuerySingleResult(queryBuilder.toString(), queryParams);
}

It is giving below error:

2013-01-16 12:17:01,381 ERROR DeployPipelineExecutor - Original stacktrace for transaction: tcm:0-5607662-66560
java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [PUBLICATION_ID]

This is query generated by HQL internally in my logs:

2013-01-16 12:17:01,365 DEBUG QueryTranslatorImpl - SQL: select publishact0_.ID as ID66_, publishact0_.ITEM_REFERENCE_ID as ITEM2_66_, publishact0_.LAST_PUBLISHED_DATE as LAST3_66_, publishact0_.PUBLICATION_ID as PUBLICAT4_66_, publishact0_.ACTION as ACTION66_, publishact0_.FLAG as FLAG66_, publishact0_.ITEM_TYPE as ITEM7_66_, publishact0_.SCHEMA_ID as SCHEMA8_66_, publishact0_.URL as URL66_ from AUTN_ITEMS publishact0_ where publishact0_.ID in (select publishact1_.ID from AUTN_ITEMS publishact1_ where publishact1_.ITEM_REFERENCE_ID=? and publishact1_.PUBLICATION_ID=? and rownum<=1 order by publishact1_.LAST_PUBLISHED_DATE desc)

I can see the PUBLICATION_ID column exists in my entity as well as in my SQL Table.

Please suggest.

  • 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-06-17T08:55:18+00:00Added an answer on June 17, 2026 at 8:55 am

    The beautiful thing about JPQL (or HQL) is the fact that you can use in your queries the properties of your Java class. You should not combine JPQL syntax with plain SQL syntax. You should replace pb.ITEM_REFERENCE_ID=:tcmURI, pb.PUBLICATION_ID=:pubID and pb.LAST_PUBLISHED_DATE with pb.tcmuri=:tcmURI, pb.publicationId=:pubID and pb.last_published_date. In addition to this, your parameter map should contain tcmURI and pubID instead of what you placed in there. Please note that I replaced the columns in the database with the actual fields from your entity. As a conclusion, your method should look something like this:

    queryBuilder.append("select pa from PublishAction pa where pa.id in(select pb.id from PublishAction pb where pb.tcmuri=:tcmURI and pb.publicationId=:pubID and rownum <= 1 order by pb.last_published_date desc)");
    
    Map<String, Object> queryParams = new HashMap<String, Object>();   
    queryParams.put("tcmURI", tcmURI);
    queryParams.put("pubID", pubID);
    

    Alternatively you can just split your query in 2 like this:

    StringBuilder queryBuilder = new StringBuilder();
    queryBuilder.append("from PublishAction pb where pb.tcmuri=:tcmURI and pb.publicationId=:pubID order by pb.last_published_date desc");
    
    Map<String, Object> queryParams = new HashMap<String, Object>();   
    queryParams.put("tcmuri", tcmURI);
    queryParams.put("pubID", pubID);
    
    final List<PublishAction> myActions = super.executeQueryListResult(queryBuilder.toString(), queryParams, 1);
    
    if (myActions != null && !myActions.isEmpty()) {
        StringBuilder queryBuilderFinal = new StringBuilder();
        queryBuilderFinal.append("select pa from PublishAction pa where pa.id=:myId");
    
        Map<String, Object> queryParamsFinal = new HashMap<String, Object>();   
        queryParamsFinal.put("myId", myActions.get(0).getId());
    
        return super.executeQuerySingleResult(queryBuilderFinal.toString(), queryParamsFinal)
    }
    

    Note that I can only guess what are the names of the properties in your Java class so I just guessed that your have the tcmuri, publicationId and last_published_date properties.

    Hope this helps.

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

Sidebar

Related Questions

I have the classes below: SuppliersRepository.cs (with the interface defining the method): public class
I have the below method: public String tryGoogleAuthentication(String auth_token){ ContactsService contactsService = new ContactsService(.....);
I have a generic method define as below public T MyMethod<T>(extra params) My method
I have the below method in a singleton class private function encode($inp) { if
I have the below method: public void Enqueue(ICommand itemToQueue) { if (itemToQueue == null)
I have the below method in my dll class library private void Download(string filename)
I have the method below. public Profile readUser(String email){ EntityManager em = EMF.get().createEntityManager(); return
This code below works with both a DAO and dBhelper class. I have 3
I have the below method and I want to try add in String.Compare public
I have the below method which is meant to append information to a file

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.