Comments (2)
I came here to ask the same thing. Spring Boot documentation has links to the following examples :
- https://github.com/sdeleuze/spring-boot-kotlin-demo: uses
data class
for their JPA entities - https://github.com/spring-petclinic/spring-petclinic-kotlin: Does, as they appear to be following the standard JPA conventions with
BaseEntity
etc.
So one example using JPA uses data class
and one doesn't. Both of these are Spring examples, which should it be?
from tut-spring-boot-kotlin.
https://github.com/sdeleuze/spring-boot-kotlin-demo is an old personal sample, this one is the reference. The blog post linked explains why immutable data classes are not a good fit with JPA:
To combat this issue, always override equals() and hashCode() when using data classes for entities.
This is absolutely safe to use. However, it almost defeats the purpose of using data classes, as it makes decomposition useless and only uses one field in toString(). A plain old class might be a better option for entities.
So it is possible to use data classes with a lot of care but JPA is not really designed to work with them, hence the choice to use regular mutable classes in this project.
from tut-spring-boot-kotlin.
Related Issues (20)
- Tutorial v2
- No default constructor for entity: : blog.Article HOT 5
- 官方教程中存在错误 HOT 3
- Update Gradle build to use the Kotlin DSL
- BlogProperties.kt code is referenced before it is created in tutorial HOT 3
- Web dependency not found
- MediaType.APPLICATION_JSON_UTF8 is Deprecated HOT 1
- Gradle sync fails HOT 1
- [Build Error ] Kotlin spring boot build error ! Help me . HOT 1
- Writing your first Kotlin controller section does not give the desired result HOT 5
- `freeCompilerArgs` should use `+=` operator HOT 4
- Junit-Platform.properties file not necessary scince junit-jupiter 5.0+ HOT 1
- Error using @Scheduled in kotiln suspend HOT 1
- what's the right way to use kotlin data class to instance different impl of an interface HOT 2
- Fix H2 database support with Spring Boot 2.7+ HOT 1
- Upgrade to Spring Boot 2.7.1
- The document must be modified.
- Enable Annotation Processor not work HOT 4
- [issue] error: unresolved reference: springframework on compilaton HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tut-spring-boot-kotlin.