kenanp 2009-06-16 16:48
浏览 306
已采纳

spring + hiberante 找不到hbm.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

    <!-- local connection properties -->
    <property name="driverClassName">
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
        <value>jdbc:mysql://localhost:3306/ch02_samples</value>
    </property>

    <property name="username">
        <value>root</value>
    </property>
    <property name="password">
        <value>850524li</value>
    </property>
</bean>
<bean id = "sessionFactory"   
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
            <property name="dataSource">
                <ref local = "datasource"/> 
            </property>
            <property name="mappingResources">
                <list>
                    <value>store/Worktable.hbm.xml</value>
                </list>
            </property>

            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                    <prop key="hibernate.hbm2dd1.atuo">update</prop>
                </props>
            </property>

    </bean>
</beans>

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\yichuansuanfa1\geneticAlgorithms\src\hp\worktable.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=store.Worktable]
Caused by: org.hibernate.MappingException: could not instantiate id generator [entity-name=store.Worktable]
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:224)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1203)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:124)
at org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:68)
at hp.mainn.main(mainn.java:119)
Caused by: org.hibernate.MappingException: Dialect does not support sequences
at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:619)
at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:88)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:127)
... 18 more

不知道为什么找不到hbm.xml文件
我的hbm.xml的确存在啊
[b]问题补充:[/b]
谢谢
不过
不管是1,还是L都不行

  • 写回答

6条回答 默认 最新

  • wanghaolovezlq 2009-06-16 17:57
    关注

    D:\yichuansuanfa1\geneticAlgorithms\src\hp\worktable.xml
    这个文件存在吧,

    Dialect does not support sequences

    你的hbm.xml文件的id生成策略不能是sequence,mysql不支持

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥15 pyqt信号槽连接写法
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。