zoukankan      html  css  js  c++  java
  • spring jpa sqls

    package com.example.repository;
    
    import java.util.List;
    
    import org.springframework.data.jpa.repository.Modifying;
    import org.springframework.data.jpa.repository.Query;
    import org.springframework.data.repository.Repository;
    import org.springframework.data.repository.query.Param;
    
    import com.example.domain.Customers;
    
    //注意:sql里的表名必须和对象名完全一致,包括大小写
    //注意这里出现的都是对象名和对象中的属性名
    public interface CustomersRepository extends Repository<Customers, Long>{
        @Query(value = "from Customers o where id=(select max(id) from Customers p)")
        public Customers getCustomersByMaxId();
    
        @Query(value = "from Customers o where o.name=?1 and o.phone=?2")
        public List<Customers> queryParams1(String name, Integer phone);
    
        @Query(value = "from Customers o where o.name=:name and o.phone=:phone")
        public List<Customers> queryParams2(@Param("name")String name, @Param("phone")Integer phone);
    
        @Query(value = "from Customers o where o.name like %?1%")
        public List<Customers> queryLike1(String name);
    
        @Query(value = "from Customers o where o.name like %:name%")
        public List<Customers> queryLike2(@Param("name")String name);
    
        @Query(nativeQuery = true, value = "select count(1) from Customers o")
        public long getCount();
        
    	@Modifying
    	@Query(value = "update SystemConfigurationManagement o set o.configurationItemName=:configurationItemName, o.configurationItemValue=:configurationItemValue where o.id=:id ")
    	void renameSystemConfigurationManagement(@Param("id") Long id, @Param("configurationItemName") String configurationItemName, @Param("configurationItemValue") String configurationItemValue);
    
        @Modifying
    	@Query(value = "delete SystemConfigurationManagement o where o.id=:id ")
    	void deleteSystemConfigurationManagementById(@Param("id")Long id);
        
        @Modifying
    	@Query(value = "delete SystemConfigurationManagement o where o.id in (:idsList)")
    	void deleteSystemConfigurationManagementByIds(@Param("idsList")List<Long> idsList);
        
    }
    
  • 相关阅读:
    phpmyadmin的登陆配置
    修改xampp-mysql密码
    php实现获取汉字笔画数
    Java学习路线图,专为新手定制的Java学习计划建议
    高德地图Bug 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !stayUp || CLClientIs
    BitCode
    解决 The sandbox is not sync with the Podfile.lock问题时候,如下所示
    iOS时间戳与字符串
    自定义大头针标注泡泡视图无法响应事件
    'The sandbox is not sync with the Podfile.lock'问题解决
  • 原文地址:https://www.cnblogs.com/xiang--liu/p/9710157.html
Copyright © 2011-2022 走看看