2023年11月29日发(作者:)

实体类和数据表的映射异常(XXXisnotmapping[]

在使⽤SSH框架开发过程,使⽤hibernate框架提供的⼯具类实现与数据库数据交互,在执⾏cmd操作时,如果出现以下异常:

或者

nested exception is yntaxException

详细异常信息

21:08:31,951 ERROR DefaultDispatcherErrorHandler:42 - Exception occurred during processing request: Customer is not mapped [from Customer];

nested exception is .internal.yntaxException: Customer is not mapped [from Customer]

ateQueryException: Customer is not mapped [from Customer]; nested exception is

.internal.yntaxException: Customer is not mapped [from Customer]

at tHibernateAccessException(:176)

at ute(:344)

at eWithNativeSession(:309)

at (:863)

at _lCustomer(:26)

at _lCustomer(:22)

at _stomer(:38)

at 0(Native Method)

at (:57)

at (:43)

at (:606)

at Method(:870)

at propriateMethod(:1293)

at thod(:68)

at thodWithDebugInfo(:117)

at thod(:108)

at thod(:1369)

at ueBody(:90)

at teGetValueBody(:212)

at ue(:258)

at ue(:494)

at ue(:458)

at il$2.execute(:309)

at eAndExecute(:340)

at ue(:307)

at Action(:423)

at ActionOnly(:287)

at (:250)

at ept(:41)

at (:244)

at ept(:256)

at (:244)

at rcept(:167)

at ept(:98)

at (:244)

at rcept(:265)

at rcept(:76)

at ept(:98)

at (:244)

at ept(:138)

at (:244)

at rcept(:229)

at ept(:98)

at (:244)

at rcept(:229)

at ept(:98)

at (:244)

at ept(:191)

at (:244)

at (:244)

at ept(:73)

at (:244)

at ept(:125)

at (:244)

at ept(:91)

at (:244)

at ept(:253)

at (:244)

at ept(:100)

at (:244)

at ept(:141)

at (:244)

at ept(:145)

at (:244)

at rcept(:171)

at ept(:98)

at (:244)

at ept(:139)

at (:244)

at ept(:164)

at (:244)

at ept(:193)

at (:244)

at ept(:189)

at (:244)

at e(:54)

at eAction(:564)

at eAction(:81)

at er(:99)

at alDoFilter(:241)

at er(:208)

at erInternal(:151)

at er(:107)

at alDoFilter(:241)

at er(:208)

at (:220)

at (:122)

at (:505)

at (:169)

at (:103)

at (:956)

at (:116)

at e(:436)

at s(:1078)

at ctProtocol$s(:625)

at point$(:318)

at ker(:1145)

at PoolExecutor$(:615)

at read$(:61)

at (:745)

问题分析与解决:

上⾯的异常的抛出主要有⼏个⽅⾯:

1、如果你使⽤的xml配置⽂件开发⽅式,检查hibernate核⼼配置⽂件中是否声明映⼊实体类的映射⽂件。简单是说,使⽤标

resource=”/项⽬全路径名称/映射实体类的名称.”>建⽴实体类与表的映射关系。

2、检查HQL语句书写书否正确。From 后⾯跟的是实体类名称⽽不是数据表的名称,同时注意⼤⼩写和单词拼写错误,以及不能包含中多

的空格。

3、如果经过以上两步的检测,执⾏结果仍然报上⾯的错误信息,那么在你hql语句中from 后⾯直接跟实体类的全名称。