Java Code Examples for org.springframework.data.jpa.repository.Query

The following examples show how to use org.springframework.data.jpa.repository.Query. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: torrssen2   Source File: WatchListRepository.java    License: MIT License 11 votes vote down vote up
@Query(value = "SELECT w.* FROM   WATCH_LIST w  " + "WHERE  w.use = true " + "AND  ((w.use_regex = false AND "
        + "       REPLACE(UPPER(?1), ' ', '') LIKE "
        + "       REPLACE(UPPER(CONCAT('%', w.title, '%', IFNULL(w.release_group, ''), '%')), ' ', '')) OR "
        + "      (w.use_regex = true  AND REGEXP_LIKE(?1, w.title, 'i')) AND REPLACE(UPPER(?1), ' ', '') LIKE "
        + "       REPLACE(UPPER(CONCAT('%', IFNULL(w.release_group, ''), '%')), ' ', '')) "
        + "     LIMIT 1"
// + "AND ((IFNULL(w.quality, '100P+') LIKE '%+' AND "
// + " CAST(REPLACE(UPPER(IFNULL(?2, '100')), 'P', '') AS INTEGER) "
// + " >= CAST(REPLACE(UPPER(IFNULL(w.quality, '100P+')), 'P+', '' ) AS
// INTEGER)) OR "
// + " (UPPER(w.quality) LIKE '%P' AND "
// + " UPPER(IFNULL(?2, '')) = UPPER(w.quality))) "
        , nativeQuery = true)
public Optional<WatchList> findByTitleRegex(String title, String quality);
 
Example 2
Source Project: ZTuoExchange_framework   Source File: AdminDao.java    License: MIT License 4 votes vote down vote up
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query("update Admin a set a.lastLoginTime=?1,a.lastLoginIp=?2 where a.id=?3")
int updateAdminLastTimeAndIp(Date date, String ip, Long memberId);
 
Example 3
Source Project: ZTuoExchange_framework   Source File: MemberWalletDao.java    License: MIT License 4 votes vote down vote up
@Query(value="select sum(a.balance) as allBalance from member_wallet_:weekDay a where a.coin_id = :coinName AND balance >=10000 AND member_id NOT IN (66946,65859,13029,55)",nativeQuery = true)
BigDecimal getWalletBalanceAmount(@Param("coinName")String coinName,@Param("weekDay")int weekDay);
 
Example 4
Source Project: WeEvent   Source File: BrokerRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Transactional
@Modifying
@Query(value = "update t_broker set delete_at=:deleteAt where id =:id", nativeQuery = true)
void deleteById(@Param("id") Integer id, @Param("deleteAt") Long deleteAt);
 
Example 5
Source Project: youkefu   Source File: OnlineUserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select count(id) from QualityMissionHis where orgi = ?1 and qualityuser = ?2")
Long countByQualityuserFromQualityMissionHis(String orgi, String qualityuser);
 
Example 6
Source Project: ZTuoExchange_framework   Source File: ExchangeOrderRepository.java    License: MIT License 4 votes vote down vote up
@Query(value="select base_symbol unit,FROM_UNIXTIME(completed_time/1000, '%Y-%m-%d'),sum(turnover) amount from exchange_order where FROM_UNIXTIME(completed_time/1000, '%Y-%m-%d') = :date and direction = 1 and status = 1 group by unit",nativeQuery = true)
List<Object[]> getExchangeTurnoverBase(@Param("date") String date);
 
Example 7
Source Project: code-examples   Source File: NoteRepository.java    License: MIT License 4 votes vote down vote up
@Query("SELECT n FROM Note n WHERE n.title = ?1 ORDER BY n.priority ASC")
List<Note> findByTitleOrderByPriorityAsc(String title);
 
Example 8
Source Project: youkefu   Source File: OnlineUserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select qualityorgan,count(id) as misscount from QualityMissionHis  where orgi = ?1 and qualityarbitrate=?2  GROUP BY qualityorgan ")
List<Object> findByQualityarbitrateGroupbyOrganFromQualityMissionHis(String orgi,int qualityarbitrate);
 
Example 9
Source Project: txle   Source File: TxEventEnvelopeRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("FROM TxEvent t WHERE t.globalTxId = ?1 AND t.localTxId = ?2")
List<TxEvent> selectSubEventByLocalTxId(String globalTxId, String localTxId);
 
Example 10
Source Project: ZTuoExchange_framework   Source File: ExchangeOrderRepository.java    License: MIT License 4 votes vote down vote up
@Query(value = "select exchange from ExchangeOrder exchange where exchange.time< :cancleTime and exchange.status=0 and exchange.memberId in (:sellMemberId,:buyMemberId)")
List<ExchangeOrder> queryExchangeOrderByTimeById(@Param("cancleTime") long cancelTime,@Param("sellMemberId") long sellMemberId,@Param("buyMemberId") long buyMemberId);
 
Example 11
Source Project: stockMarket   Source File: UserStockRepository.java    License: MIT License 4 votes vote down vote up
@Query(value="SELECT * FROM market.user_stock where userId=?1 limit ?2, ?3" ,nativeQuery = true)
//(pageNo-1)*pageSize
List<UserStockEnitity> getPageStock(String userId, Integer pageSize, Integer pageNum);
 
Example 12
Source Project: ZTuoExchange_framework   Source File: MemberWalletDao.java    License: MIT License 4 votes vote down vote up
@Query(value="select sum(a.balance)+sum(a.frozen_balance) as allBalance from member_wallet a where a.coin_id = :coinName",nativeQuery = true)
BigDecimal getWalletAllBalance(@Param("coinName")String coinName);
 
Example 13
Source Project: WeBASE-Collect-Bee   Source File: AccountInfoRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Transactional
@Modifying
@Query(value = "delete from  #{#entityName} where block_height >= ?1", nativeQuery = true)
public void rollback(long blockHeight);
 
Example 14
Source Project: Exam-Online   Source File: ExamResultDAO.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "select * from exam_result where sys_user_id = ?2 and exam_id = ?1 order by id desc limit 1", 
		nativeQuery = true)
ExamResult findByExamIdAndUserId(Long examId, Long userId);
 
Example 15
Source Project: web-flash   Source File: LoginLogRepository.java    License: MIT License 4 votes vote down vote up
@Modifying
@Transactional
@Query(nativeQuery = true,value = "delete from t_sys_login_log")
int clear();
 
Example 16
Source Project: flash-waimai   Source File: LoginLogRepository.java    License: MIT License 4 votes vote down vote up
@Modifying
@Transactional
@Query(nativeQuery = true,value = "delete from t_sys_login_log")
int clear();
 
Example 17
Source Project: Spring-Boot-Book   Source File: UserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Modifying(clearAutomatically=true)
@Transactional
@Query("update User set active=:active where email=:email")
int setActive(@Param("active") Integer active, @Param("email") String email);
 
Example 18
Source Project: Spring-Boot-Book   Source File: CartRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "select * from cart c where c.user_id=:user_id", nativeQuery = true)
List<Cart> findCartByIdNative(@Param("user_id") long user_id);
 
Example 19
Source Project: WeBASE-Front   Source File: MonitorRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "select m from Monitor m where m.groupId = ?1 and m.timestamp between ?2 and ?3 order by m.id")
public List<Monitor> findByTimeBetween(int groupId, Long startTime, Long endTime);
 
Example 20
Source Project: ZTuoExchange_framework   Source File: MemberWalletDao.java    License: MIT License 4 votes vote down vote up
@Transactional
@Modifying
@Query(value = "TRUNCATE TABLE member_wallet_:weekDay",nativeQuery = true)
int dropWeekTable(@Param("weekDay")int weekDay);
 
Example 21
Source Project: WeEvent   Source File: BrokerRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Transactional
@Modifying
@Query(value = "update t_broker set delete_at=:deleteAt where broker_url =:brokerUrl", nativeQuery = true)
void deleteByBrokerUrl(@Param("brokerUrl") String brokerUrl, @Param("deleteAt") Long deleteAt);
 
Example 22
Source Project: openvsx   Source File: ExtensionRepository.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Query("select max(e.downloadCount) from Extension e")
int getMaxDownloadCount();
 
Example 23
Source Project: youkefu   Source File: OnlineUserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select AVG(duration) from StatusEvent where orgi = ?1 and (discaller = ?2 or discalled = ?3) and ?4 < createtime and createtime < ?5 and misscall = false ")
Long countByToadyExtDurFromStatusEvent(String orgi, String ani, String called, Date begin, Date end);
 
Example 24
Source Project: ZTuoExchange_framework   Source File: AppealDao.java    License: MIT License 4 votes vote down vote up
@Query("select count(a.id) as defendantNum from Appeal a where a.associateId = :memberId")
Long getBusinessAppealAssociateIdStatistics(@Param("memberId")Long memberId);
 
Example 25
Source Project: ZTuoExchange_framework   Source File: CoinDao.java    License: MIT License 4 votes vote down vote up
@Query("select a from Coin a where a.unit in (:units) ")
List<Coin> findAllByOtc(@Param("units") List<String> otcUnits);
 
Example 26
Source Project: youkefu   Source File: OnlineUserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select result , count(id) as records from InviteRecord where orgi = ?1 and agentno = ?2 and createtime > ?3 and createtime < ?4 group by result")
List<Object> findByOrgiAndAgentnoAndCreatetimeRange(String orgi ,String agentno , Date start , Date end);
 
Example 27
Source Project: txle   Source File: TxEventEnvelopeRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("SELECT count(T) FROM TxEvent T WHERE T.type = 'SagaStartedEvent' AND FUNCTION('CONCAT_WS', ',', T.globalTxId, T.instanceId, T.category, T.expiryTime, T.retries, T.creationTime) LIKE CONCAT('%', ?1, '%')")
long findTxListCount(String searchText);
 
Example 28
Source Project: txle   Source File: TxEventEnvelopeRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "SELECT DISTINCT T2.localTxId FROM TxEvent T2 WHERE T2.globalTxId IN (SELECT T1.globalTxId FROM TxEvent T1 WHERE T1.type = 'SagaEndedEvent' AND T1.globalTxId IN (SELECT T.globalTxId FROM TxEvent T WHERE T.localTxId IN ?1)) AND T2.localTxId IN ?1")
Set<String> selectEndedGlobalTx(Set<String> localTxIdSet);
 
Example 29
Source Project: ZTuoExchange_framework   Source File: MemberWalletDao.java    License: MIT License 4 votes vote down vote up
@Transactional
@Modifying
@Query(value="UPDATE member_wallet SET balance=balance+:teamBalance where coin_id = 'BHB' AND member_id=:teamId",nativeQuery = true)
int updateTeamWallet(@Param("teamBalance")BigDecimal teamBalance,@Param("teamId")long teamId);
 
Example 30
Source Project: youkefu   Source File: OnlineUserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select count(id) from QualityMissionHis where orgi = ?1 and qualityuser = ?2 and qualityappeal = ?3 and qualityarbitrate = ?4")
Long countByQualityuserAndQualityappealAndQualityarbitrateFromQualityMissionHis(String orgi, String qualityuser,int qualityappeal,int qualityarbitrate);