S2hh配的sequence问题,疑惑中,解答对的200分送给他,谢谢了,在线等!!!!!!!!!!!!!!

yangxuebao123 2010-10-02 10:00:49
先贴简单的配置


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<context:property-placeholder location="classpath:conf/jdbc.properties"/>
<!-- Enable @Transactional support -->
<tx:annotation-driven/>
<context:annotation-config />
<!-- Enable @AspectJ support -->
<aop:aspectj-autoproxy/>

<aop:config>
<aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* com.ifinesoft.asms.service.*.*(..))"/>
</aop:config>
<!--
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="inse*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="remove*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="edit*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="do*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="create*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="*Update" propagation="REQUIRED" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
-->


<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>

<!-- Scans for @Repository, @Service and @Component -->
<context:component-scan base-package="com.ifinesoft.asms"/>

</beans>




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.ym.gps.model.DeviceInfo" table="DEVICEINFO">
<id name="id" type="java.lang.Integer" column="ID">
<generator class="sequence">
<param name="sequence">seq_deviceinfo</param>
</generator>
</id>
<property name="deviceNo" column="DEVICENO" />
<property name="deviceSim" column="DEVICESIM" />
<property name="deviceSold" column="DEVICESOLD" type="java.lang.Integer"/>
<property name="deviceAddTime" column="DEVICEADDTIME" type="java.sql.Timestamp" />
<property name="deviceSoldTime" column="DEVICESOLDTIME" type="java.sql.Timestamp" />
<property name="deviceCompanyId" column="DEVICECOMPANYID" type="java.lang.Integer"/>
<property name="deviceTypeId" column="DEVICETYPEID" type="java.lang.Integer"/>
<property name="deviceEffictive" column="DEVICEEFFICTIVE" type="java.lang.Integer"/>
<property name="devicePrice" column="DEVICEPRICE" type="java.lang.Integer"/>
<property name="deviceEndTime" column="DEVICEENDTIME" type="java.sql.Timestamp" />
</class>
</hibernate-mapping>







问题是,我在数据库建立了序列化,然后我通过外面的页面添加值的时候,发现添加不进去, 只能走到basedao层, 当然 程序也不报错....数据没有添加到数据库,里面的实体类除了ID为null,其他都有值,我调试过了....

删除和查询方法都能用...

...全文
91 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangxuebao123 2010-10-02
  • 打赏
  • 举报
回复
我改了,问题有回来了, 还是走到basedao层,但是数据添加不进去....


也不报错...
marqio 2010-10-02
  • 打赏
  • 举报
回复
修改
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
此处需要修改 <tx:method name="get*" read-only="true"/>
将约束放大,去掉read-only试试
zdekun 2010-10-02
  • 打赏
  • 举报
回复
配置的问题,看看sesseionFactory的配置和事务的配置应该就可以了
yangxuebao123 2010-10-02
  • 打赏
  • 举报
回复
在我几改,终于有异常信息了

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
zdekun 2010-10-02
  • 打赏
  • 举报
回复
从配置上看,应该没有什么问题吧,建议先在数据库中执行下select seq_deviceinfo.nextval from dual这条语句,然后就是看看你执行insert语句的方法的事务配置。
yangxuebao123 2010-10-02
  • 打赏
  • 举报
回复
控制台没有任何hibernate 语句

但是在查询和删除都是有语句的...
zdekun 2010-10-02
  • 打赏
  • 举报
回复
你执行insert的时候,控制台有没有出现 hibernate: select seq_deviceinfo.nextval from dual 的语句。
yangxuebao123 2010-10-02
  • 打赏
  • 举报
回复
来一个人啊,帮我想想...

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧