Rob
Rob

Reputation: 23

Wrong Column Name Used By Spring Data/Hibernate

It started as a problem in my Table model class, and I was able to fix that by specifying the naming strategies, and using @Column.

The problem I have now is in the CrudRepository interface.

List<TableModel> findByRefNo(int RefNo);

The column name is 'RefNo', I have no control over this.

Hibernate keeps looking for 'refNo'

I suspect this is still a naming strategy issue.

How do I specify the column name in the interface?

Upvotes: 1

Views: 184

Answers (1)

heniotierra
heniotierra

Reputation: 108

Use @Query annotation, I believe that will solve your problem. Like:

@Query("SELECT m FROM TableModel m WHERE m.RefNo = ?1")
List<TableModel> findByRefNo(int RefNo);

Upvotes: 1

Related Questions