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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:03:04+00:00 2026-06-04T05:03:04+00:00

I tried to get all MainIntervals in a certain date interval. But I get

  • 0

I tried to get all MainIntervals in a certain date interval. But I get always null.

Here is the JPA Entity

@Table(name="MAIN_INTERVAL")
 @NamedQueries({
 @NamedQuery(name = MainInterval.FIND_ALL, query = " select m from MainInterval m"),
 @NamedQuery(name = MainInterval.FIND_BETWEEN, 
    query = "select m from MainInterval m where m.mainIntervalStart 
    BETWEEN :startDate AND :endDate 
    AND m.mainIntervalEnd BETWEEN :startDate AND :endDate"
   )  }) 


public class MainInterval implements Serializable {

public static final String FIND_ALL = "MainInterval.findAll";
 public static final String FIND_BETWEEN = "MainInterval.findBetween";

private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="MAIN_INTERVAL_ID")
private Long id;

@Column(name="MAIN_INTERVAL_START")
@Temporal(javax.persistence.TemporalType.DATE)
private Date mainIntervalStart;

@Column(name="MAIN_INTERVAL_END")
@Temporal(javax.persistence.TemporalType.DATE)
private Date mainIntervalEnd; }

And in the EJB SessionBeans I have the method:

public List<MainInterval> findMainIntervalsBetween(Date startDate, Date endDate){
      List<MainInterval> resultList = em.createNamedQuery(MainInterval.FIND_BETWEEN, MainInterval.class)
              .setParameter("startDate", startDate, TemporalType.DATE).setParameter("endDate", endDate, TemporalType.DATE).getResultList();
      return resultList;
}

But when I call it from JSF with CDI the resultList is always null. Although I have some MainIntervals that meet the conditions between startDate and endDate.

I would be very grateful to every answer or links for tutorial.
Best regards!

  • 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-04T05:03:06+00:00Added an answer on June 4, 2026 at 5:03 am

    Your query is:

    select m from MainInterval m where m.mainIntervalStart 
    BETWEEN :startDate AND :endDate 
    AND m.mainIntervalEnd BETWEEN :startDate AND :endDate
    

    Your first row’s interval is [01.05.2012, 31.05.2012], and your second row’s interval is [01.05.2012, 01.08.2012]. The arguments of the query are 10.05.2012, 20.05.2012.

    So, for your first row:

    m.mainIntervalStart BETWEEN :startDate AND :endDate 
    01.05.2012          BETWEEN 10.05.2012 AND 20.05.2012 : false
    

    So the first row is not returned.

    For your second row:

    m.mainIntervalStart BETWEEN :startDate AND :endDate 
    01.05.2012          BETWEEN 10.05.2012 AND 20.05.2012 : false
    

    So the second row isn’t returned either.

    Everything looks normal to me.

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

Sidebar

Related Questions

I tried to recursively get all files and folder list.But I can only get
I've searched all over and tried everything but I still get: invalid multibyte char
I'm trying to get all records with date greater then now. I tried this
I tried to get my application run at a specified time but I can't
Firstly I tried to get fabric working, but it kept asking me for a
i have tried to get the sine wave example running on an AsioOut, but
This should be something encountered by programmers often, but I never tried to get
I need to get all table rows on a page that contain a specific
I am trying to get all text on page. I have tried this without
I successfully integrate the face-book API and able to get all user profile but

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.