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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:16:42+00:00 2026-06-11T18:16:42+00:00

For example, I have the Service entity: @OneToMany(fetch = FetchType.EAGER, mappedBy = service) public

  • 0

For example, I have the Service entity:

@OneToMany(fetch = FetchType.EAGER, mappedBy = "service")
public List<ServiceStatus> getServiceStatuses() {
    return serviceStatuses;
}

and the ServiceStatus entity:

@ManyToOne
@JoinColumn(name = "service", nullable = false)
public Service getService() {
    return service;
}

@Column(name = "date", nullable = false)
@Temporal(TemporalType.DATE)
public Date getDate() {
    return date;
}

Now I need to query all the Service objects so that each of it has only those ServiceStatus objects where ServiceStatus.date is between date1 and date2. That is, if there are 10 ServiceStatus objects with the proper date, the serviceStatuses list will have only those 10 objects and nothing more. Is it possible?

Thanks in advance.

  • 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-11T18:16:43+00:00Added an answer on June 11, 2026 at 6:16 pm

    I solved the problem using @Filter:

    @FilterDef(name = "dateFilter", parameters = {
            @ParamDef(name = "date1", type = "date"),
            @ParamDef(name = "date2", type = "date") })
    @Filter(name = "dateFilter", condition = "date >= :date1 and date <= :date2")
    

    and applying it to session:

    session.enableFilter("dateFilter")
                    .setParameter("date1", date1)
                    .setParameter("date2", date2);
    

    BTW, when working with Hibernate, what should I use for queries: it’s own mechanism or “raw” SQL like “inner join” in this case?

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

Sidebar

Related Questions

Does anyone know, or better yet have an example, of a WCF service that
Example I have a repository class (DAL): public class MyRepository : IMyRepository { public
Example-I have a person class Public Class Person Private _fname As String Public Property
We have a WCF service that uses Entity Framework to query a SQL database.
For example I have two entities Class A { public Guid Id {get;set;} public
I have a service that gets a JPA entity from outside code. In this
i got a problem by using CrudRepository. Example: i have two entities, entity A
i have a parent entity Service and a child ExtendedService in a SINGLE_TABLE inheritance.
Lets say I have a lists of entities (for example, a list of TODO
If I for example have <p> some long text </p> on my HTML page,

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.