Sheheryar Umair
02/06/2024, 12:58 PM@Entity
@Table(name = "\"User\"")
class User(
@Id
@Column(nullable = false, updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Int,
@Column(nullable = false)
val name: String,
@Column(nullable = false)
val email: String,
@Column(nullable = false)
val password: String,
@Column(nullable = false)
val mobile: String,
@Column(nullable = false)
val role: String,
@Column(nullable = false)
val companyName: String,
@Column(nullable = false)
val address: String,
@Column(nullable = false)
val billingAddress: String,
@Column
val isDeleted: LocalDateTime,
)
The error I am getting is org.hibernate.InstantiationException: No default constructor for entity
. Can someone assist me to solve this.Emil Kantis
02/06/2024, 1:09 PMSheheryar Umair
02/06/2024, 1:12 PMplugins {
id("org.jetbrains.kotlin.plugin.allopen") version "1.9.22"
}
Emil Kantis
02/06/2024, 1:17 PMkotlin("plugin.spring") version "1.9.22"
Emil Kantis
02/06/2024, 1:17 PMSheheryar Umair
02/06/2024, 1:17 PMSzymon Jeziorski
02/06/2024, 1:41 PMplugin.spring
would just open classes annotated with Spring bean annotations @Component
, @Service
etc, it will not help you with this particlar issue.
To ensure default empty constructor is generated for JPA entities you would need to use plugin.jpa
.
Take a look at this guide:
https://spring.io/guides/tutorials/spring-boot-kotlin/
also, don't skip Persistence with JPA part, as opening JPA classes is needed for lazy fetching to work properlySheheryar Umair
02/06/2024, 1:41 PMSheheryar Umair
02/06/2024, 1:44 PM_kotlin_("plugin.jpa") _version_ "1.9.22"
has solved the error. Thank you!Emil Kantis
02/06/2024, 1:45 PMEmil Kantis
02/06/2024, 1:45 PMkqr
02/06/2024, 1:50 PMval id
is working?Sheheryar Umair
02/06/2024, 1:52 PM