JPA - Different ID Generation Strategies for Tests

For production, we use an Oracle database with some fancy identifier materials

@Id
@GeneratedValue(generator = "generator")
@GenericGenerator(name = "generator", strategy = "guid", parameters = {})
@Column(name="PROPERTY_ID")
private String propertyId;

For testing, I thought that I just use the H2 database in memory and how the identifier is generated feels less important (I’m not even sure that guid will work with H2), so is it possible to have different settings for testing and production?

+3
source share
1 answer

You can map objects (partially) to orm.xml, which will differ in the test resources folder (say src/test/resources). I'm not sure if this will cancel the annotation, if one exists, so give it a try.

+2

Source: https://habr.com/ru/post/1770542/


All Articles