String): User } personRepository.findByUsername("nobody") org.springframework.dao.EmptyResultDataAccessException: Result must not be null! at org.springframework.data.repository.core.support.MethodInvocationValidator.invoke at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed at org.springframework.aop.framework.JdkDynamicAopProxy.invoke ...
String): User } personRepository.findByUsername("nobody") org.springframework.dao.EmptyResultDataAccessException: Result must not be null! at org.springframework.data.repository.core.support.MethodInvocationValidator.invoke at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed at org.springframework.aop.framework.JdkDynamicAopProxy.invoke https://docs.spring.io/spring-data/jpa/docs/2.1.6.RELEASE/reference/html/#repositories.nullability.kotlin nullability에 주의!
var id: Long?, @Column(nullable = false) var name: String, var phoneNumber: String? ) @Entity class Person( @Id @GeneratedValue var id: Long? = null, @Column(nullable = false) var name: String = "", var phoneNumber: String? = null ) org.springframework.orm.jpa.JpaSystemException: No default constructor for entity: : com.example.demo.Person
no-arg constructor를 자동으로 만들어줍니다. Gradle/Maven 플러그인으로 추가합니다. kotlin-jpa kotlin-noarg + JPA를 위한 기본 설정 @Entity, @Embeddable, @MappedSuperclass http://kotlinlang.org/docs/reference/compiler-plugins.html#jpa-support
a.person println(person::class) SQL: select ... from asset asset0_ where asset0_.id=? SQL: select ... from person person0_ where person0_.id=? class com.example.demo.Person 프록시 객체가 아니다?
Long?, @Column(nullable = false) var name: String, var phoneNumber: String? ) @Entity open class Person( @Id @GeneratedValue open var id: Long?, @Column(nullable = false) open var name: String, open var phoneNumber: String? )
= false) var name: String, var phoneNumber: String? ) @Entity open class Person( @Id @GeneratedValue open var id: Long?, @Column(nullable = false) open var name: String, open var phoneNumber: String? ) ✨