私は休止状態に慣れておらず、直接テーブルマッピングシナリオ以外で動作させるのに苦労しています。基本的に、BookInvoiceというユーザー定義のJavaクラスがあります。このクラスは非永続的(dbテーブルではない)であり、以前に定義および注釈が付けられたdbテーブルの列を使用します。@Entityとしてラベル付けしようとするたびに、既存のdbテーブルではないためできないと表示されます。取得しないようにマップするにはどうすればよいですか
不明なエンティティ:com.acentia.training.project15.model.BookInvoice
私が経験しているエラーメッセージ。
私のSQLクエリは良好で、データベースから情報を取得できます。ただし、それらはクラスObjectとして返され、呼び出し元のメソッドに送り返すために、目的のBookInvoiceクラスにキャストすることは許可されていません。以下のplsは、これまでの私の仕事の断片を見つけます。。。
既存のdbテーブルクエリに準拠する私の通常のクラスはすべて正常に機能することに注意してください。問題が発生しているのは非永続的なクラスだけです。
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クラス:
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. . . .
スタックトレーススニペット:
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:不明なエンティティ:
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)
..。