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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:23:03+00:00 2026-05-30T17:23:03+00:00

I am having trouble with this query but ONLY under HSQLDB. We use Oracle

  • 0

I am having trouble with this query but ONLY under HSQLDB. We use Oracle for production database and HSQL for automated integration tests. Here’s my main object:

@Entity
@Table(name="STUDENTS")
@org.hibernate.annotations.Proxy(lazy=false)
public class Student implements Serializable {
...
   @OneToMany(fetch=FetchType.LAZY)
   @JoinColumn(name="STUDENTID",referencedColumnName="ID")
   private Set<StudentRace> races;
...
}

StudentRace looks like this:

@Entity
@Table(name="STUDENTRACE")
@org.hibernate.annotations.Proxy(lazy=false)
public class StudentRace implements Serializable {
...
    @Column(name="STUDENTID")
    private Integer studentid;
...
}

And my JPA query is like this:

entityManager.createQuery("select distinct s from Student s left join fetch s.races "+
  "where s.schoolNumber = :schoolNumber");

I know I have correct data in the HSQLDB database – I can manually do a query and see the data. Yet the Student objects always have “races” as null. As I said, this query works fine in Oracle. Is there some kind of HSQLDB setup thing I’m missing?

Edit: Like this? In Student:

@OneToMany(fetch=FetchType.LAZY, mappedBy="id")
private Set<StudentRace> races;

In StudentRace:

@ManyToOne
@JoinColumn(name="STUDENTID")
private Student student;

Still no luck. The “races” element is still null.

  • 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-05-30T17:23:04+00:00Added an answer on May 30, 2026 at 5:23 pm

    Your mapping is incorrect, because the STUDENTRACE.STUDENTID column is mapped twice: once as a JoinColumn in Student, and once as a column in StudentRace.

    Either make the association unidirectional and remove the studentid field in StudentRace, or make it bidirectional, and have a Student student field in StudentRace, mapped as a ManyToOne, as shown in this example from the Hibernate documentation.

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

Sidebar

Related Questions

I`m having trouble trying to optimize this query with OVER (PARTITION BY ...) because
I'm having trouble getting any information to display from this query. Anyone know where
I'm having trouble wrapping my head around how to write this query. A hypothetical
Im having trouble understanding this : why Microsoft put Xattribute under Xobject ? they
I'm having trouble getting the correct query (oracle) for what I'm looking for. Essentially
I'm having trouble getting the position of an address. However, this problem occurs only
I'm having trouble figuring out this query. I'm using PHP and postgresql 9.1. I
I'm having trouble optimizing this query: SELECT a.id FROM a JOIN b ON a.id=b.id
I'm having trouble coming up with a working query for this situation... Table: [
This is probably stupid simple, but for some reason I'm having trouble getting it

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.