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

The Archive Base Latest Questions

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

I am new to hibernate and am having difficulty trying to get it to

  • 0

I am new to hibernate and am having difficulty trying to get it to work for anything other than a direct table mapping scenario. Basically, I have a user defined Java class called: BookInvoice. This class is a non-persistent (not a db table) and uses columns from previously defined and Annotated) db tables. Every time I try to label it as an @Entity it tells me I cant because it is not an existing db table. How do I map it so that I dont get the

Unknown entity: com.acentia.training.project15.model.BookInvoice

error message that I have been experiencing.

My sql queries are good and I am able to get the info from the db; however, they come back as class Object and I am not permitted to cast them into my desired BookInvoice class in order to send it back to the calling method. Below pls find snipets of my work thus far . . .

Please note all of my regular classes that conform to existing db tables queries work fine, it is just the ones that are non-persistent that I am having issues with.

PurchaseOrderInvoiceDAO:

        List<BookInvoice> bInvoiceList = null;
        final String bookInvoiceQuery =
                "SELECT Books.ID, PO_Details.QUANTITY, Books.ISBN, Books.TITLE, Books.AUTHOR, Author.Name, Books.PUBLISHED, Books.COVER, Books.SERIES, Books.SERIES_NO,\n" +
                        "          Books.SUBJECT_ID,Books.PRICE\n" +
                        "        FROM Purchase_Order, PO_Details, Books, Author\n" +
                        "        WHERE Purchase_Order.ID=?\n" +
                        "        AND Purchase_Order.ID=PO_Details.PO_ID\n" +
                        "        AND PO_Details.Book_ID=Books.ID\n" +
                        "        AND Books.AUTHOR=Author.ID";

        Query bookInvoicQ = getSession().createSQLQuery(bookInfoQuery).addEntity(BookInvoice.class);
        bookInvoicQ.setInteger(0, id);
        bList = (List<Books>) bookInvoicQ.list();

BookInvoice class:

        public class BookInvoice {

            Integer id = null;
            Integer quantity = null;
            String isbn = null;
            String title = null;
            Integer authorId = null;
            Date publishedDate = null;
            String cover = null;
            String series = null;
            Integer seriesNo = null;
            Integer subjectId = null;
            Double price = null;

            public BookInvoice(final Integer id, final Integer quantity, final String isbn, final String title,
                   final Integer authorId, final Date publishedDate, final String cover,
                   final String series, final Integer seriesNo, final Integer subjectId, final Double price) {
                   this.id = id;
                   this.quantity = quantity;
                   this.isbn = isbn;
                   this.title = title;
                   this.authorId = authorId;
                   this.publishedDate = publishedDate;
                   this.cover = cover;
                   this.series = series;
                   this.seriesNo = seriesNo;
                   this.subjectId = subjectId;
                   this.price = price;
           }

           public BookInvoice(){}

           public Integer getId() {
               return id;
           }

           etc. . . .

Stack Trace Snippet:

           Struts Problem Report

           Struts has detected an unhandled exception:

           Messages:    
           Unknown entity: com.acentia.training.project15.model.BookInvoice
           File:    org/hibernate/impl/SessionFactoryImpl.java
           Line number:     693
           Stacktraces

org.hibernate.MappingException: Unknown entity:
com.acentia.training.project15.model.BookInvoice
org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:693)

org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.getSQLLoadable(SQLQueryReturnProcessor.java:335)
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processRootReturn(SQLQueryReturnProcessor.java:376)
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:355)
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:171)
org.hibernate.loader.custom.sql.SQLCustomQuery.(SQLCustomQuery.java:87)
org.hibernate.engine.query.NativeSQLQueryPlan.(NativeSQLQueryPlan.java:67)
org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:166)
org.hibernate.impl.AbstractSessionImpl.getNativeSQLQueryPlan(AbstractSessionImpl.java:160)
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
com.acentia.training.project15.bo.PurchaseOrderInvoiceBO$PurchaseOrderInvoiceDAO.getById(PurchaseOrderInvoiceBO.java:196)

…

  • 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-18T09:31:27+00:00Added an answer on June 18, 2026 at 9:31 am

    Ok! Finally broke down and talked to my supervisor about this. He explained that I am doing like waaaaaay to much extra work on this.

    Basically, if I set the @Entity class/DB mappings up correctly then they will get all of the right information (ie. @OneToMany, etc.) from the mappings of the classes that correspond directly to the DB tables. Basically, Hibernate will go down as many levels (PO_Details ->Payments->Books, etc) they would give me all the additional information that I need and I wouldn’t need to create my own custom classes.

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

Sidebar

Related Questions

I am new to hibernate queries, and trying to get a grasp on how
I'm new to Hibernate, I just started to do a mapping to a table,
Firstly, I am somewhat new with Hibernate. To get to know the technology I
I am new to hibernate and I am having some trouble with the named
I'm relatively new with hibernate so please be gentle. I'm having an issue with
I am pretty new to Hibernate. I am having problem understanding these simple logics.
My current Hibernate project is having some mapping problems. But first of all, I'll
I am using Hibernate 3, and having a particular issue when persisting a new
I am currently exploring Hibernate annotation and I am finding it better than having
I'm trying to add ehcache (v2.6.0) to my Hibernate 4.1.5.SP1 project, but having some

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.