67,511
社区成员
发帖
与我相关
我的任务
分享
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>vo/Customer.hbm.xml</value>
</list>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:config/hibernate.cfg.xml">
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
</bean>
严重: Servlet.service() for servlet [default] in context with path [/MyWork] threw exception [org.hibernate.hql.ast.QuerySyntaxException: Customer is not mapped [from Customer where custname='zxc']] with root cause
org.hibernate.hql.ast.QuerySyntaxException: Customer is not mapped [from Customer where custname='zxc']
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:277)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
</value>
</property>
<property name="mappingLocations">
<list>
<value>classpath:vo/Customer.hbm.xml</value>
</list>
</property>
</bean>
<property name="mappingLocations">
<list>
<value>classpath:/你的路径/你的路径/*.hbm.xml</value>
</list>
</property>
试试通配符方式,匹配你某个文件夹下面的所有以 hbm.xml结尾的文件<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>vo/Customer.hbm.xml</value></list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/ql/entity/User.hbm.xml</value>
<value>com/ql/entity/Student.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.show_sql=true
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.cache.use_second_level_cache=true
hibernate.cache.provider_class=org.hibernate.cache.OSCacheProvider
hibernate.generate_statistics=true
hibernate.connection.release_mode=auto
hibernate.autoReconnect=true
</value>
</property>
</bean>