Hello,
I've got 2 types of databags in my Java-code. One represents a 'Class' (a bunch of students) and the other represents a 'Test' (something the students have to do). I want to link all the Tests they may do, to a particular Class. I want to use a collection (Map) for this.
I have therefore 3 tables in my database: 'classes' (with primary key 'class_id'), 'tests' (primary key is 'test_id') and an association/join-table 'classes_tests'. This table got two foreign keys 'class_id' and 'test_id' and a third column 'obligatory' that is set true when the test has to be performed.
I use annotations to map the database with the databags. I didn't had any problems until this point, but now I don't succeed to use a 'Map' (like HashMap) wich has a Test as key and the column obligatory as value.
This is the code I have so far for this Map:
Code:
@CollectionOfElements
@JoinTable(name = "classes_tests", joinColumns = @JoinColumn(name = "class_id"))
@MapKey(columns={@Column(name="obligatory")})
private Map<Test,String> tests;