Hello @Moses_Mutesasira, @Agaba_Derrick_Junior, @mherman22
I have been writing tests for the testcalculated services
And this ResultCalculation.java entity has two columns that I’m not yet sure how to represent them in datasets
one as a Set
@CollectionTable(name = "test_operations", joinColumns = @JoinColumn(name = "result_calculation_id", referencedColumnName = "id"))
@Column(name = "test_id")
private Set<Test> test;
and the other a Map
@CollectionTable(name = "test_result_map", joinColumns = @JoinColumn(name = "result_calculation_id", referencedColumnName = "id"))
@MapKeyColumn(name = "test_id")
@Column(name = "result_id")
private Map<Integer, Integer> testResultMap;
I thought of designing them like this:
<!-- ElementCollection: Set<testId> -->
<test_operations result_calculation_id="1" test_id="401" />
<test_operations result_calculation_id="2" test_id="402" />
And like this:
<!-- ElementCollection: Map<testId, resultId> -->
<test_result_map result_calculation_id="1" test_id="401" result_id="301" />
<test_result_map result_calculation_id="2" test_id="402" result_id="302" />
Though the compiler throws an Exceptionorg.dbunit.dataset.NoPrimaryKeyException:
thus suggesting that test_operations
and test_result_map
must have an id
column, making them look like this:
<!-- ElementCollection: Set<testId, resultId> -->
<test_operations id="1" result_calculation_id="1" test_id="401" />
- Which then makes me think that we should make them Java objects (entities) and use the
@JoinColumn(name = "id")
annotation to map them to theResultCalculation
entity
Please, I’m requesting for your ideas here, how can I create a data set for the ResultCalculation
table?