Hibernate @WhereJoinTable trouble
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 ha开发者_如何学Gos 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!
精彩评论