在线等~~~hibernate添加数据到orcal数据库中,成功却没有插入数据到数据库?????!!!!!!

Geilymm Geilymm 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
使用spring的事务管理,该配置的都配置了,流程都没错,就是save()过后,数据库中没有插入数据~~~~~

dao操作:

public void addBaseInfo(BaseInfo baseInfo) {
sessionFactory.getCurrentSession().save(baseInfo);
}

配置文件:

<tx:annotation-driven transaction-manager="transactionManager"/>

<!-- 配置数据源 -->
<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:@localhost:1521:gac"></property>
<property name="username" value="gac"></property>
<property name="password" value="gac"></property>
</bean>

<!-- 配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.tgb.entity.BaseInfo</value>
</list>
</property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="businessService" expression="execution(* com.tgb.manager.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="businessService"/>
</aop:config>
...全文
评论 2
收藏 已收藏
分享
返回顶部
Geilymm
Eclipse 58,439 成员 49,457 内容