I'm getting used to hibernate but every now and again I hit a stumble, here's another one.
I'm trying to achieve the following:
@OneToMany
@JoinTable(name = "inter_spec",
joinColumns = { @JoinColumn(name = "inter_id") },
inverseJoinColumns = { @JoinColumn(name = "spec_id") })
@WhereJoinTable(clause = "spec_type=SECTION")
public List<Section> getSections() {
return sections;
}
But I get the following error when running my unit test:
[ERROR] JDBCExceptionReporter - Column "SECTIONS0_.SECTION" not found; SQL statement:
All I want is to apply the Where clause so my List sections has only the SECTION type data.
If I remove the Where clause my unit test passes, the assertion on the List has the expected data.
Thanks for reading.
Ahh, this always happens, as soon as I post a question I figure it out!!
Basically, SECTION in the Where clause is an Enum in the Java code, so that line should have been:
@WhereJoinTable(clause = "spec_type='SECTION'")
Notice the single quotes around SECTION which weren't there before!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With