junit测试正常,能显示SQL语名,在ORCALE中也能查到保存后的记录。
问题部署到服务器通过action添加不到数据库,后台也不显示SQL语句,也不报异常。将数据库换成sql server 2005完全正常。欲哭无泪啊,在网上搜了很久,也有人遇到同样的问题,也按同样方式处理过,还是不行,晕啊各位大虾们帮下忙啊。这是后台提示信息,没有insert语句咯:
信息: Server startup in 11258 ms
action保存
Hibernate: 
    select
        authorityDir_Sequence_db.nextval 
    from
        dual
savae
我把配置文件和一些相关的代码贴上,各位帮忙,小弟在此拜谢.<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx 
         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.gxyx.tmms" />
<aop:aspectj-autoproxy />
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean> <bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.gxyx.tmms.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<!--<prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2005Dialect</prop>-->
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="javax.persistence.validation.mode">none</prop><!--Unable to get the default Bean Validation factory-->
</props>
</property>

</bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" /> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean></beans>
dao实现类
package com.gxyx.tmms.dao.impl;import java.util.ArrayList;
import java.util.List;import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Component;import com.gxyx.tmms.dao.AuthorityDirDao;
import com.gxyx.tmms.model.AuthorityDir;
@Component("authorityDirDao")
public class AuthortiyDirDaoImpl extends SuperDao implements AuthorityDirDao {
public void save(AuthorityDir ad) {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(ad);
System.out.println("savae");
} public List<AuthorityDir> findAll() {
// TODO Auto-generated method stub
List<?> results = this.getHibernateTemplate().find("from AuthorityDir");
List<AuthorityDir> ads=new ArrayList<AuthorityDir>();  
for(Object o:results){
ads.add((AuthorityDir)o);
}
return ads;
} public void delete(AuthorityDir ad) {
// TODO Auto-generated method stub
this.getHibernateTemplate().delete(ad);
} public void update(AuthorityDir ad) {
// TODO Auto-generated method stub
this.getHibernateTemplate().saveOrUpdate("ID", ad);
} public List<AuthorityDir> queryByPage(DetachedCriteria hql, int beginIndex, int pageSize) {
// TODO Auto-generated method stub
List<?> results = this.getHibernateTemplate().findByCriteria(hql, beginIndex, pageSize);
List<AuthorityDir> ads=new ArrayList<AuthorityDir>();  
for(Object o:results){
ads.add((AuthorityDir)o);
}
return ads;
} public int queryRowCount(DetachedCriteria hql) {
// TODO Auto-generated method stub
return this.getHibernateTemplate().findByCriteria(hql).size();
}
}实体类
package com.gxyx.tmms.model;import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;@Entity
@Table(name="RGP_AuthorityDir")
@SequenceGenerator(name="authorityDir_Sequence",sequenceName="authorityDir_Sequence_db")
public class AuthorityDir {
private int ID;
private String name;
private String tag;
private String description;
@Id
@GeneratedValue(generator="authorityDir_Sequence")
public int getID() {
return ID;
}
public void setID(int iD) {
ID = iD;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

解决方案 »

  1.   


    <!--spring事务管理-->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" /> <aop:config>
    <aop:pointcut id="bussinessService" expression="execution(public * com.gxyx.tmms.service..*.*(..))" />
    <aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" />
    </aop:config>
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <tx:method name="get*" read-only="true" />
    <tx:method name="add*" propagation="REQUIRED" />
    </tx:attributes>
    </tx:advice>