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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:31:08+00:00 2026-06-04T17:31:08+00:00

I tried the documentation but I’ve got nothing. I tried searching for it on

  • 0

I tried the documentation but I’ve got nothing. I tried searching for it on google and stackoverflow but there is still no help. I’ve got a singleton class and this class has a onetomany relationship to another class. Here’s my code.

@Entity
public class HomeLibrary extends BaseModelObject {
    @OneToMany(mappedBy = "homeLibrary", cascade = { CascadeType.ALL })
    private Collection<Book> books = new ArrayList<Book>();

    private static HomeLibrary sharedHomeLibrary = new HomeLibrary();

    public static HomeLibrary getSharedHomeLibrary() {
        return sharedHomeLibrary;
    }

    public Collection<Book> getBooks() {
        return books;
    }

    public void setBooks(Collection<Book> books) {
        this.books = books;
    }

    private HomeLibrary() {
    }
}

And I got an error in testing. It seems that the table cannot be built.

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [HibernateApplicationContext-aop.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on edu.fudan.ss.persistence.hibernate.Book.homeLibrary references an unknown entity: edu.fudan.ss.persistence.hibernate.HomeLibrary
  • 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-04T17:31:09+00:00Added an answer on June 4, 2026 at 5:31 pm

    Hibernate needs your default constructor to be present in order to create entity, since your constructor is hidden it cannot create your HomeEntity.

    Either constructor should be public or package visibility, hibernate should be be able to use setAccessible(true) // Note I havent tried package visibility option.

    Hibernate and in general framework who create entity uses Class<T>.newInstance() via reflection.

    mappedBy means that mapping is done by the Owning side, the dependent need not define the mapping.

    So in your case you will place mappedBy in Book if you are defining mapping in HomeLibraryor vice versa.

    This post on SO speaks about creating objects via Factory method, you can use that to have your singleton object.

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

Sidebar

Related Questions

I have tried searching on Google and also read the documentation but no success.
I tried reading the documentation but this still wasn't clear to me: Suppose my
I tried reading the documentation but I still don’t really understand how magento's xml
I have searched the documentation and tried various techniques but have't found a suitable
I tried: form = JournalForm(initial={'tank': 123}) but as the documentation says, it does not
I have tried to find some decent documentation on traversing in jQuery, but have
I'm pretty new to Ruby. I've tried looking over the online documentation, but I
What exactly does execve() do? I've tried looking at the documentation (http://linux.die.net/man/2/execve) but given
I've tried reading the documentation but it is rather impenetrable so I'm hoping someone
I've looked at the documentation but I couldn't find if there was a method

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.