Data conversion error converting "CAPTAIN"
Shivanshu-Mishra opened this issue · 3 comments
Hi ,
I am working with SpringJpa exercise.
There as mentioned in example I created JPAOfficer DAO class with below mentioned implementation for findAll().
@Override public List<Officer> findAll() { return entityManager.createQuery("SELECT o FROM Officer o", Officer.class).getResultList(); }
Unit test for it fails with
Hibernate: select officer0_.id as id1_0_, officer0_.first_name as first_na2_0_, officer0_.last_name as last_nam3_0_, officer0_.rank as rank4_0_ from officers officer0_
2019-10-19 20:54:04.238 WARN 1484 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 22018, SQLState: 22018
2019-10-19 20:54:04.238 ERROR 1484 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : Data conversion error converting "CAPTAIN" [22018-199]
Unittest
@Test public void testFindAll() { List<String> dbNames=dao.findAll().stream() .map(Officer::getLast) .collect(Collectors.toList()); assertTrue(dbNames.contains("kirk")); }
I am not understanding whatsthe problem
Sorry I did not read that this problem is mentioned ahead.
@column(nullable = false)
@Enumerated(EnumType.STRING)
private Rank rank;
Thanks Ken for your time and consideration.
Best regards
Shivanshu