abu593218127
abu593218127
2016-01-07 12:22

刚学的spingmvc 想使用hibernate添加数据实现主键自增?求指点

  • 数据
  • oracle
  • hibernate
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
    <property name="url"
        value="jdbc:oracle:thin:@127.0.0.1:1521/orcl"></property>
    <property name="username" value="scott"></property>
    <property name="password" value="tiger"></property>
</bean>

<!-- 配置SessionFactory -->
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.format_sql">true</prop>
        </props>
    </property>
    <!-- 注解扫描的包 -->
    <property name="annotatedClasses">
        <list>
            <value>entity.AccountBo</value>
            <value>entity.UsersBo</value>
            <value>entity.QuestionBo</value>
        </list>
    </property>
</bean>

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答