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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:03:33+00:00 2026-05-22T13:03:33+00:00

I’ve started switching over a project from hand-written JDBC ORM code to Ebeans. So

  • 0

I’ve started switching over a project from hand-written JDBC ORM code to Ebeans. So far it’s been great; Ebeans is light and easy to use.

However, I have run into a crippling issue: when retrieving a one-to-many list which should be empty there is actually one element in it. This element looks to be some kind of proxy object which has all null fields, so it breaks code which loops through the collection.

I’ve included abbreviated definitions here:

@Entity
class Store {
    ...
    @OneToMany(mappedBy="store",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
    List<StoreAlbum> storeAlbums = new LinkedList<StoreAlbum>();
}

@Entity
class StoreAlbum {
    ...
    @ManyToOne(optional=false,fetch=FetchType.EAGER)
    @JoinColumn(name="store_id",nullable=false)
    Store store;
}

The … are where all the standard getters and setters are. The retrieval code looks like this:

Store s = server.find(Store.class)
            .where()
            .eq("store_id",4)
            .findUnique();

Assert.assertEquals("Sprint",s.getStoreName());
Assert.assertEquals(0, s.getStoreAlbums().size());

The database is known to contain a ‘store’ row for “Sprint”, and the ‘store_album’ table does not contain any rows for that store.

The JUnit test fails on the second assertion. It finds a list with 1 element in it, which is some kind of broken StoreAlbum object. The debugger shows the object as being of the type “com.lwm.catalogfeed.domain.StoreAlbum$$EntityBean$test@1a5e68a” with null values for all the fields which are declared as nullable=false (and optional=false).

Am I missing something here?

  • 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-22T13:03:33+00:00Added an answer on May 22, 2026 at 1:03 pm

    Thought I’d post an update on this… I ended up giving up on EBeans and instead switched the implementation over to use MyBatis. MyBatis is fantastic; the manual is easy to read and thorough. MyBatis does what you expect it to do. I got it up and running in no time.

    EBeans didn’t appear to detect that the join for the associated collection resulted in a bunch of null ids, but MyBatis handled this scenario cleanly.

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

Sidebar

Related Questions

No related questions found

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.