Reputation: 2974
I already had hsql db for testing and I added a couple of tables to that.
I updated .dtd and .xml files properly but was unable to run junits as "NoSuchTableException" was being thrown from dbunit test cases.
In the DAO class I added following property for the culprit table.
@Column(name = "keyword_id", columnDefinition = "int REFERENCES master_keyword(keyword_id)")
Once I removed columnDefinition attribute, junit worked fine. I understand that columnDefinition is database specific, does that mean, we should not use this while running junits?
I spent a lot of time on this. Problem is resolved but any thoughts on this?
Upvotes: 0
Views: 603
Reputation: 691635
If your unit tests use the annotations to automatically create the database tables, then obviously the columnDefinition
attribute is taken into account: that's its purpose.
So if you have database-specific stuff, for another database than the one you're using, in the column definition, then obviously it won't work.
It looks like you want to define a foreign key constraint here. Why don't you use a OneToOne or ManyToOne association then?
Upvotes: 1