0
回答
hibernate +springmvc +sqlserver 2008 能新增查询,不能修改删除
【腾讯云】学生服务器套餐10元/月 >>>   
<properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
       <property name="hibernate.hbm2ddl.auto" value="auto"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.connection.autocommit" value="false"></property>
       <property name="hibernate.generate_statistics"  value="true"/>
       <property name="hibernate.format_sql" value="true"/>
       <property name="hibernate.cache.use_query_cache" value="true"/>
       <property name="hibernate.cache.use_second_level_cache" value="true" /> 
       <property name="hibernate.cache.provider_class"
        value="org.hibernate.cache.HashtableCacheProvider" />
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/algEntityManagerFactory"/> 
       <property name="hibernate.jdbc.fetch_size" value="25"/>
       <!-- <property name="hibernate.default_schema" value="hcqs"/>  -->

    </properties>



@Transactional
public void update(Users users){


// em.merge(users);

String sql =" update Users set login_name =:login_name,password =:password,phone_number =:phone_number,is_alarm =:is_alarm"
+ ",email=:email,user_name =:user_name,remark=:remark where user_id =:user_id ";
Query query = em.createNativeQuery(sql);
query.setParameter("user_id", users.getUser_id());
query.setParameter("user_name", users.getUser_name());
query.setParameter("login_name", users.getLogin_name());
query.setParameter("phone_number", users.getPhone_number());
query.setParameter("is_alarm", users.getIs_alarm());
query.setParameter("email", users.getEmail());
query.setParameter("remark",users.getRemark());
query.executeUpdate();
}

举报
顶部