2015-12-03 10 views
0

Я работаю с jpa connect to mysql. когда я использую запрос следующим образом базы данных таблицы:Ошибка запроса jpa spring boot

public interface CommentRepository extends JpaRepository<Comment1, Integer>{ 
 
\t @Query(value = "SELECT * FROM comment1 WHERE contribution_id=:contributionId",nativeQuery = true) 
 
\t List<Comment1> findByContributionId(@Param("contributionId") String contributionId); 
 
}

package com.example; 
 

 
import java.io.Serializable; 
 
import java.sql.Timestamp; 
 
import java.util.List; 
 

 
import javax.annotation.Generated; 
 
import javax.persistence.Column; 
 
import javax.persistence.Entity; 
 
import javax.persistence.GeneratedValue; 
 
import javax.persistence.GenerationType; 
 
import javax.persistence.Id; 
 
import javax.persistence.JoinColumn; 
 
import javax.persistence.ManyToOne; 
 
import javax.persistence.OneToMany; 
 

 
/** 
 
* Comment1エンティティクラス 
 
* 
 
*/ 
 
@Entity 
 
public class Comment1 implements Serializable { 
 

 
\t private static final long serialVersionUID = 1L; 
 

 
\t /** commentIdプロパティ */ 
 
\t @Id 
 
\t @GeneratedValue(strategy = GenerationType.IDENTITY) 
 
\t @Column(name = "comment_id", precision = 11, nullable = false, unique = true) 
 
\t public Integer commentId; 
 

 
\t /** contributionIdプロパティ */ 
 
\t @Column(name = "contribution_id", precision = 20, nullable = false, unique = false) 
 
\t public Integer contributionId; 
 

 
\t /** userIdプロパティ */ 
 
\t @Column(precision = 11, nullable = false, unique = false) 
 
\t public Integer userId; 
 

 
\t /** commentプロパティ */ 
 
\t @Column(length = 2000, nullable = true, unique = false) 
 
\t public String comment; 
 

 
\t /** photoIdプロパティ */ 
 
\t @Column(precision = 11, nullable = true, unique = true) 
 
\t public Integer photoId; 
 

 
\t /** stampIdプロパティ */ 
 
\t @Column(precision = 11, nullable = true, unique = true) 
 
\t public Integer stampId; 
 

 
\t /** likeCountプロパティ */ 
 
\t @Column(precision = 11, nullable = false, unique = false) 
 
\t public Integer likeCount; 
 

 
\t /** updateDateプロパティ */ 
 
\t @Column(nullable = true, unique = false) 
 
\t public Timestamp updateDate; 
 

 
\t /** createDateプロパティ */ 
 
\t @Column(nullable = false, unique = false) 
 
\t public Timestamp createDate; 
 

 
\t /** deleteFlgプロパティ */ 
 
\t @Column(precision = 11, nullable = false, unique = false) 
 
\t public Integer deleteFlg; 
 

 
\t // public List<Stamp1> stamp1List; 
 

 
\t /** stampPlaceプロパティ */ 
 
\t @Column(precision = 11, nullable = false, unique = false) 
 
\t public Integer stampPlace; 
 

 
}

Мой сделки контроллер

package com.example; 
 

 
import java.util.List; 
 

 
import javax.transaction.Transactional; 
 

 
import org.springframework.beans.factory.annotation.Autowired; 
 
import org.springframework.stereotype.Service; 
 

 

 
@Service 
 
@Transactional 
 
public class ServiceComment { 
 
\t @Autowired 
 
\t CommentRepository commentRepository; 
 
\t 
 
\t public String findByFb(String contributionId){ 
 
\t \t List<Comment1> datas = commentRepository.findByContributionId(contributionId); 
 
\t \t if (datas.size() != 0){ 
 
\t \t \t Comment1 data = datas.get(0); 
 
\t \t \t return "found " + datas.size()+ "recore"; 
 
\t \t \t 
 
\t \t }else return "not found recore"; 
 
\t \t 
 
\t } 
 
}

Моя проблема: Текущая таблица моей базы данных «Комментарий1» существует с 500 строк. с colume "contrib_id" имеет значение от 1 до 2235659. - Когда я запрашиваю значение value_id от 1 до 918 -> query succes - при запросе с 919 по 2235659 он не может найти ни одной строки, хотя она существует на таблице. Я думаю, что это связано с запросом на ограничение конфигурации или с любой проблемой. . Пожалуйста, помогите решить эту проблему. Спасибо!

ответ

0

UPDATE: Я проверяю больше времени и нахожу причину, что он относится к colume create_date Если дата создания> 2015-06-24 15:47:52, он не может запросить true.

enter image description here