我在使用Spring-boot CrudRepository时遇到问题,我想做的是在一段时间内查找数据
我通过这个查询,结果没问题
<form method="POST">
<?php
$con=mysqli_connect("localhost","root","admin","MyDatabase");
$sql = mysqli_query($con, "SELECT id, username, comment_body, user_id, DATE_FORMAT(date_created, '%M %d %Y') AS date_created FROM news_comments WHERE entry_id = '" . $entry_id. "'");
?>
<?php while ($comment = mysqli_fetch_array($sql)) { ?>
<table class="table">
<thead>
<tr>
...
</tr>
<td>
<?php echo $comment['username']; ?>
</br>
<?php echo $comment['comment_body']; ?>
</br>
<?php echo $comment['date_created'];?>
</td>
...
<td>
<button name = "report">Report</button>
<?php if(isset($_POST['report'])) {
$id = $comment['id'];
$conn=mysqli_connect("localhost","root","admin","MyDatabase");
$sqli = mysqli_query($con, "UPDATE news_comments SET isFlagged = 1 WHERE id = '$id'");
} ?>
</td>
....
</table>
这也没关系
List<T> findByTimestampAfter(@Param("timestamp") Date start)
但我尝试了以下三种方法不起作用:
List<T> findByTimestampBefore(@Param("timestamp") Date end)
我想得到的是时间范围内超过100个数据,但只有一个时间戳结束时
我尝试执行这个sql statementselect:
List<T> findByTimestampBetween(@Param("timestamp") Date start,@Param("timestamp") Date end)
List<T> findByTimestampAfterAndTimestampBefore(@Param("timestamp") Date start,@Param("timestamp") Date end)
List<T> findByTimestampGreaterThanEqualAndTimestampLessThanEqual(@Param("timestamp") Date start,@Param("timestamp") Date end)
我可以看到超过100个数据。
我想我无法解决这个问题
答案 0 :(得分:0)
自动查看从jpa执行的查询。如果您只是使用正确的调试记录器。还要告诉上述三种方法取得的正确结果。
答案 1 :(得分:0)
方法名称中不支持关键字between
。您应该定义自定义查询,例如:
@Query("select * from exchange where timestamp > ?1 AND timestamp < ?2")
Object[] findByTimeCustomQuery(Date dFrom, Date dTo);