开发者

JPA - Different id generating strategy for tests

开发者 https://www.devze.com 2023-01-21 03:20 出处:网络
For production we are using a Oracle database with some fancy stuff for IDs @Id @GeneratedValue(generator = \"gen开发者_高级运维erator\")

For production we are using a Oracle database with some fancy stuff for IDs

@Id
@GeneratedValue(generator = "gen开发者_高级运维erator")
@GenericGenerator(name = "generator", strategy = "guid", parameters = {})
@Column(name="PROPERTY_ID")
private String propertyId;

For testing I thought I'd just use a H2 in memory database and how the ID is generated feels less important (not even sure guid would work with H2) so is it possible to have different setups for test and production?


You can map your entities (partially) in orm.xml, which would differ in the test resources folder (say src/test/resources). I'm not sure whether it will override the annotation if such exists, so give it a try.

0

精彩评论

暂无评论...
验证码 换一张
取 消