I'm running my app in SpringBootTest. Using IN memory db.
I'm getting error in my spring app when i try to get record from db.
I'm using:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
In this app/test I'm also doing save to db and it works fine.
Db table is build of two simple columns DUMMY_ID and REQUEST.
Error: Method threw 'org.hibernate.LazyInitializationException' exception. Cannot evaluate ....... $HibernateProxy$JjtlVUy6.toString()
Problematic method -> requestsRepository.getById("dummyId");
@Repository
@Transactional
public interface RequestsRepository extends JpaRepository<RequestsEntity, String> {
}
@Data
@Entity
@Component
@Table(name = "REQUESTS", schema = "", catalog = "")
public class RequestsEntity {
@Id
@Column(name = "DUMMY_ID")
private String dummyId;
@Column(name = "REQUEST")
private String request;
public RequestsEntity() {
}
public RequestsEntity(String dummyId, String request) {
this.dummyId = dummyId;
this.request = request;
}
}
I don't know why getById is failing.