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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:48:30+00:00 2026-06-11T11:48:30+00:00

I’m writing some code in hibernate where I’m required to update some other table

  • 0

I’m writing some code in hibernate where I’m required to update some other table (hall_calendar) before a row is inserted in my table (hall_block_calendar).
I have status F, E, M from which only those dates submitted by the form having “F” are to be marked “N”. My mapping file for pojo class Hall_calendar.java contains composite key for hall_code and calendar_date and hallbookingcompid in the pojo class.

My query is working fine. However, the for loop throws an exception. I would appreciate any inputs on this.

        public boolean addHallCalendarBlock(Hall_block_calendar hbc, Hall_calendar hc)
{
   //boolean result;
   Session session=HibernateUtil.getSessionFactory().openSession();   
   Transaction tx=null;
   try
    {
       tx=session.beginTransaction();

       Query q=session.createQuery("from Hall_calendar h where h.hallbookingcompid.calendar_date between'"+hbc.getHall_block_from_date()+"' and '"+hbc.getHall_block_to_date()+"' and hall_availability='F'");

       System.out.println("query working: "+q.list());

       if(!q.list().isEmpty())
       {   
           Hall_calendar upd_obj = new Hall_calendar();
           for(Iterator it=q.iterate();it.hasNext();)
           {   


             Object[] row = (Object[]) it.next();
             System.out.println("row[0]: "+(String)row[0]);
             upd_obj= (Hall_calendar) session.load(Hall_calendar.class, (String)row[0]);

             upd_obj.setHall_availability("N"); 
             session.save(upd_obj); 
           }

           session.save(hbc);
           tx.commit();  
       }   
    }
   catch(Exception e)
   {
       tx.rollback();
       e.printStackTrace();
       return false;
   }
   finally
   {
       session.close();
   }
   return true;
}


query working: [com.cmc.sibs.vo.Hall_calendar@7e9bed, com.cmc.sibs.vo.Hall_calendar@4d2125, com.cmc.sibs.vo.Hall_calendar@1bb41d7, com.cmc.sibs.vo.Hall_calendar@df9252]
java.lang.ClassCastException: com.cmc.sibs.vo.Hall_calendar
    at com.cmc.sibs.dao.SibsDao.addHallCalendarBlock(SibsDao.java:21861)
    at com.cmc.sibs.delegates.SibsDelegate.addHallCalendarBlock(SibsDelegate.java:2982)
    at com.cmc.sibs.servlets.AddHallBlocking.doPost(AddHallBlocking.java:86)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
boolean in servlet: false
  • 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-11T11:48:31+00:00Added an answer on June 11, 2026 at 11:48 am

    First off, you’re violating every Java code standard. You are basically writing c++ code with Java. Secondly, I do not get why you iterate the way you do. When you do a query.list(), on a query without a select clause, you will get back full objects. Why not do:

    final List<Hall_calendar> res = (List<Hall_calendar>) q.list();
    for (final Hall_calendar hall_calendar : res) {
        hall_calendar.setHall_availability("N");
        //no need to explicitly save these..
    }
    session.save(hbc);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.