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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:06:08+00:00 2026-06-09T16:06:08+00:00

I have a db table(Hibernate conf all done), ResourceRequest( resource, startTime, endTime, status )

  • 0

I have a db table(Hibernate conf all done),

  ResourceRequest( resource, startTime, endTime, status )

between the startTime and endTime the resource is occupied.

Problem Statement:
For a input of inStartTime and inEndTime, I have to find the next available slot if it is already occupied in the given slot.
Have to write a hibernate query for this.

One quick solution that I could think of is:
Querying the resourcerequests for the given resource into a collection and then manipulating it to get the next available slot.

But I want have that as my last resort. Any help is appreciated.

thanks.

  • 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-09T16:06:09+00:00Added an answer on June 9, 2026 at 4:06 pm

    in sql

    SELECT * FROM slots s1 WHERE
        s1.endTime > :inStartTime AND
        not exists (SELECT 1 FROM slots s2 WHERE s2.startTime > s1.endTime AND s2.startTime < DateAdd(s1.endTime, :inEndMinusInStart))
    ORDER BY
        s1.startTime
    
    
    // and criteria to tweak
    
    DetachedCriteria subquery = DetachedCriteria.for(Slot.class)
        .add(<filter on resource>)
        .add(Restrictions.propertyGt("startTime", "s1.endTime"));
        .add(Restrictions.propertylt("startTime", Projections.sqlFunction("dateadd", Projections.property("s1.endTime"), inStartTime - inEndTime, Hibernate.dateTime));
    
    session.createCriteria(Slot.class, "s1")
        .add(<filter on resource>)
        .add(Restrictions.gt(endTime, inStartTime))
        .add(Subqueries.notExists(subquery))
    

    hope it helps

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

Sidebar

Related Questions

I have this table structure and would like to map it using Fluent Hibernate
I have a table called Person which I have already mapped in hibernate I
I'm using Hibernate 4.0.1.Final. I have a table with a unique constraint column …
We have a DB table that is mapped into a hibernate entity. So far
I have a database table using an enum. This is already working with hibernate
I have a hibernate question. My table is of the form: Id, Date --
I have a MySQL database includes a table named 'Task'. and I used Hibernate
I have an entity defined as follows @Entity(name = Report) @Table(name = REPORTS) @org.hibernate.annotations.Entity(dynamicInsert
I want to make an hibernate querycount on a table. I have to values,
I'm using Coldfusion ORM (Hibernate), and have a cfc mapped to a database table.

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.