In JPA is there an annotation to specify that boolean fields should be persisted as an integer. I'm using OpenJPA and it's currently persisting boolean fields as bits. I'd rather use integer 1 or 0.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can specify the column definition:
@Column(name="boolColumn",
columnDefinition="INT(1)")
回答2:
You can use the following annotation:
@Type(type="numeric_boolean")
If you want to write Y and N instead of 0, 1, you can use
@Type(type="yes_no")