本文介紹了在 JPA 中設(shè)置列??的默認(rèn)值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
是否可以為 JPA 中的列設(shè)置默認(rèn)值,如果,如何使用注釋來完成?
Is it possible to set a default value for columns in JPA, and if, how is it done using annotations?
推薦答案
實(shí)際上在 JPA 中是可能的,雖然使用 @Column<的
columnDefinition
屬性有點(diǎn)小技巧/code> 注解,例如:
Actually it is possible in JPA, although a little bit of a hack using the columnDefinition
property of the @Column
annotation, for example:
@Column(name="Price", columnDefinition="Decimal(10,2) default '100.00'")
這篇關(guān)于在 JPA 中設(shè)置列??的默認(rèn)值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!