Hibernate @WhereJoinTable problem

I get used to hibernation, but from time to time I come across a stumble, here's another one.

I am 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 when starting my unit test:

The following error occurs:

[ERROR] JDBCExceptionReporter - column "SECTIONS0_.SECTION" was not found; SQL statement:

All I want to do is apply the Where clause so that only the data of type SECTION is in my sections of the list.

If I delete the Where my unit test clause, the statement in the list has the expected data.

Thanks for reading.

+6
hibernate jointable
source share
1 answer

Ah, that always happens, as soon as I post a question, I find out.

Basically, SECTION in the Where clause is Enum in Java code, so the line should be:

 @WhereJoinTable(clause = "spec_type='SECTION'") 

Pay attention to single quotes around SECTION, which were not there before!

+9
source share

All Articles