When using the HQL query in today's project, the Qingaocenterinfo is not mapped[from Qingaocenterinfo where ...] appears.
There is obviously a problem with the hibernate mapping relationship.
This exception occurs first to see whether the table name in the database table is used in the query statement, not the entity class.
To view my code:
Centerlist = Manager.find ("From Qingaocenterinfo center where center.type =?") and Center.centername =? ", new Object[]{type,centername});
Found no problem ah, the solution, from yesterday afternoon to this morning, tinkering for a long time ...
。。。。。
Finally, the problem is found, and the from xxx,xxx used for HQL queries is not the name of the entity class, but the entityname(Hibernate annotation).
Such as:
@Entity @table (name= "Qing_ao_center_info") public class Qingaocenterinfo { ...}
HereThe specified entityname is not displayed after @Entity, so the name of the entity class is used by default.
In My Code:
@Entity (name= "Qing_ao_center_info") @Table (name= "Qing_ao_center_info") public class Qingaocenterinfo { ...}
Can be found to indicate theentityname, so when using HQL queries, the FromQing_ao_center_info, not fromQingaocenterinfo;
Centerlist = Manager.find ("From Qing_ao_center_info CENTER where center.type =?") and Center.centername =? ", new Object[]{type,centername});