英文:
Kotlin Spring Boot - How do you skip a property in a class with CrudRepository?
问题
如何使CrudRepository跳过在数据库表中创建字段?也就是说,
@Table
class Property(@Id val id: String?, val name: String, val objectType: String, currentValue: String?) {
}
假设我只想创建一个具有id和name的表,跳过其他字段。这是可能的吗?
谢谢!
英文:
hoping this is a easy question. How do you get the CrudRepository to skip making a field in the db table? i.e.
@Table
class Property(@Id val id: String?, val name: String, val objectType: String, currentValue: String?) {
}
lets say I only wanted a table with id & name created, skipping the others. Is that possible?
Thank you!
答案1
得分: 1
你正在寻找 @Transient 注解。将该注解放在你的字段上,Hibernate 将不会持久化它。
更多信息:https://stackoverflow.com/questions/44272844/kotlin-jpa-and-transient
英文:
You are seeking @Transient annotation.
Put the annotation above your field and Hibernate doesn’t persist it.
For more: https://stackoverflow.com/questions/44272844/kotlin-jpa-and-transient
答案2
得分: 0
@org.springframework.data.annotation.Transient
英文:
I had to do this to get it to work, but Transient is correct!
@org.springframework.data.annotation.Transient
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论