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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:33:19+00:00 2026-06-16T01:33:19+00:00

I would like to retrieve the Reservation which has no reference ReservationInstance in DB

  • 0

I would like to retrieve the Reservation which has no reference ReservationInstance in DB by JPQL query. ReservationInstance entity have Reservation entity. It is OneToOne unidirectional.

Reservation Table

ID      NAME
0001    AAA
0002    BBB
0003    CCC
0004    DDD

ReservationInstance Table

ID      SOME_COLUMN     RESERVATION_ID  
0001    somedata        0004

How can I retrieve the Reservation list (For AAA, BBB and CCC) which has no ReservationInstance reference?

My Entities

public class Reservation implements Serializable {
    .....
    private String id;
    .....
    private String name;
    //getter and setter
}

public class ReservationInstance implements Serializable {
    ....
    private String id;
    ....
    private Date fromTime;
    ....
    private Date toTime;

    @OneToOne
    @JoinColumn(name = "RESERVATION_ID", referencedColumnName = "ID")
    private Reservation reservation;
}

Update Post

I used the query as below

SELECT r FROM Reservation r LEFT JOIN ReservationInstance ri WHERE ri.reservation IS NULL

I get the exception

[EL Severe]: 2012-12-18 16:37:02.817--ServerSession(1733641680)--Local Exception Stack: 
Exception [EclipseLink-8023] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [Reservation.findAbandonedReservation: SELECT r FROM Reservation r LEFT JOIN ReservationInstance ri WHERE ri.reservation.id IS
 NULL].
Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException
    at org.eclipse.persistence.exceptions.JPQLException.syntaxError(JPQLException.java:352)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.handleRecognitionException(JPQLParser.java:350)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.addError(JPQLParser.java:242)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.reportError(JPQLParser.java:359)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.joinAssociationPathExpression(JPQLParser.java:11880)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.join(JPQLParser.java:11488)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.identificationVariableDeclaration(JPQLParser.java:11302)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.fromClause(JPQLParser.java:11164)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectStatement(JPQLParser.java:355)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.document(JPQLParser.java:275)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.parse(JPQLParser.java:130)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.buildParseTree(JPQLParser.java:91)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:207)
    at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:106)
    at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:90)
    at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:509)
    at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:470)
    at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:1815)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:409)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:666)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:615)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:389)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:164)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:221)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:209)
    at org.ace.mrbs.ost.comp.reservation.persistence.ReservationDAO.deleteAbandonedReservation(ReservationDAO.java:110)
    at org.ace.mrbs.ost.comp.reservation.persistence.ReservationDAO.main(ReservationDAO.java:130)
Caused by: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.joinAssociationPathExpression(JPQLParser.java:11868)
    ... 23 more
  • 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-16T01:33:20+00:00Added an answer on June 16, 2026 at 1:33 am

    MY first choice would be to make the relation Bi-Directional.

    Turns out LEFT JOIN with ON will only be supported in JPA 2.1 so I suggest something like this:

    SELECT r FROM Reservation r WHERE r IS NOT IN (SELECT ri.reservation FROM ReservationInstance ri)
    

    Not 100% sure this works, if not try using r.id IS NOT IN some query the returns the ids.

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

Sidebar

Related Questions

I would like to retrieve an ordered query result, but I need to have
I have a set of URLs for which I would like to retrieve the
I have the following string which i would like to retrieve some values from:
I have an SQL Server 2000 db, and I would like to retrieve summary
I have an SDF file and I would like to retrieve its schema and
I would like to retrieve any text a user may have highlighted with the
I would like to retrieve today's data. At the moment I have something like
I would like to retrieve some columns from a table, without the id column,
I would like to retrieve several items in one cell of a table in
I have a logo and I would like to retrieve the most used colors,

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.