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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:39:26+00:00 2026-06-18T05:39:26+00:00

I am using OpenJPA 2.2.1 and ran into the following problem: TypedQuery<OdpObjectScheduleEntity> q =

  • 0

I am using OpenJPA 2.2.1 and ran into the following problem:

TypedQuery<OdpObjectScheduleEntity> q = em.createQuery(
    "SELECT s FROM OdpObjectScheduleEntity s WHERE s.updateFreq IS NOT NULL",
    OdpObjectScheduleEntity.class);
List<OdpObjectScheduleEntity> result = q.getResultList();

This is OdpObjectScheduleEntity:

package ru.focusmedia.odp.server.datastore.jpa.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import ru.focusmedia.odp.server.datastore.api.objects.OdpObjectScheduleRecord;

@Entity
@Table(name = "object_schedules")
public class OdpObjectScheduleEntity implements OdpObjectScheduleRecord {
    // fetch=FetchType.EAGER is the default. 
    // I've also tried explicitly setting it, no difference.
    @OneToOne(optional = false) 
    @Column(nullable = false)
    @Id
    private OdpObjectEntity object;

    @Column(name = "update_freq_seconds", nullable = true)
    private Integer updateFreq;

    protected OdpObjectScheduleEntity() {
        // for JPA
    }

    public OdpObjectScheduleEntity(OdpObjectEntity object, Integer updateFreq) {
        this.object = object;
        this.updateFreq = updateFreq;
    }

    @Override
    public OdpObjectEntity getObject() {
        return object;
    }

    @Override
    public Integer getUpdateFreq() {
        return updateFreq;
    }

    public void setUpdateFreq(Integer updateFreq) {
        this.updateFreq = updateFreq;
    }

    @Override
    public String toString() {
        return "OdpObjectScheduleEntity [object=" + object + ", updateFreq="
                + updateFreq + "]";
    }
}

But the elements of the result seem to look as if object is fetched lazily, e.g., OdpObjectScheduleEntity [object=OdpObjectEntity [id=23851, name=null, parent=null, odpClass=null], updateFreq=120]. Am I missing something obvious or is this a bug in OpenJPA? I can work around this by doing something awful like

for (OdpObjectScheduleEntity schedule : result) {
    // simply schedule.getObject() doesn't work
    schedule.getObject().toString();
}

Is there a better way to force loading the relationship?

  • 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-18T05:39:28+00:00Added an answer on June 18, 2026 at 5:39 am

    I haven’t ever used OpenJPA, so I cannot tell you what’s exactly wrong, but you could try using JOIN FETCH:

    TypedQuery<OdpObjectScheduleEntity> q = em.createQuery(
        "SELECT s FROM OdpObjectScheduleEntity s LEFT JOIN FETCH s.object WHERE s.updateFreq IS NOT NULL",
        OdpObjectScheduleEntity.class);
    List<OdpObjectScheduleEntity> result = q.getResultList();
    

    For more information, see for example http://docs.oracle.com/html/E24396_01/ejb3_langref.html#ejb3_langref_fetch_joins

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

Sidebar

Related Questions

While using OpenJPA, if I mark a class with annotation @Entity, is there a
I have a Spring 3 application using openJPA as persistence management, following section works
Using the DateTime class, if I try to run the following code: $mydate =
I'm using OpenJPA and I have a lock problem. I already understand what's an
I am using JPA2 with it's Criteria API to select my entities from the
Using Open JPA 2.0, Database is DB2 9.7. For query like SELECT COUNT(1) FROM
I am using JPA with openjpa implementation beneath, on a Geronimo application server. I
In pom.xml I have (taken from http://struberg.wordpress.com/2012/05/10/using-jpa-in-real-projects-part-1/ ): <properties> <openjpa.sql.action>refresh</openjpa.sql.action> <database.driver.name>org.postgresql.Driver</database.driver.name> <database.connection.url>jdbc:postgresql://myURL</database.connection.url> <database.user>user</database.user> <database.password>password</database.password>
Using SQL Server 2008 R2 we are looking for a way to select the
I'm having trouble handling IDs of my databse tables using OpenJPA and HSQLdb. I

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.