I want to get entity with fields like
"id":[1],
"text":[some text]
to be able to manipulate them, but i get link to entity that look like
org.springframework.data.jpa.repository.support.SimpleJpaRepository@b1e8d6a
With this
@Repository
@Transactional
public interface QuestionRepository extends JpaRepository<Question, Long> {
@Query(value = "SELECT new io.stepa.StepaDomashniyBot.model.Question(QT.id, QT.text) FROM questionTable as QT WHERE id = 1", nativeQuery = true)
Question getFirstQuestion();
}
My entity:
@Getter
@Setter
@Entity(name = "questionTable")
public class Question {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Column(name = "text", nullable = false, length = 1000)
private String text;
How can i get entity?
I tried:
@Repository
@Transactional
public interface QuestionRepository extends JpaRepository<Question, Long> {
@Query(value = "SELECT new io.stepa.StepaDomashniyBot.model.Question(QT.id, QT.text) FROM questionTable as QT WHERE id = 1", nativeQuery = true)
Question getFirstQuestion();
}
Expecting:
"id":[1],
"text":[some text]
New contributor
Petr Goldberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.