JDBI Object Request

I used to use JDBI before for Java persistence, but it was always a free API, not an object API. Now try the object's API.

I have a DAO Object, which is pretty simple:

public interface PersonDAO {

@SqlQuery("insert into person(id,first_name,last_name,position) values(:id,:firstName,:lastName,:position)")
void insertPerson(@Bind("id") Integer id,
                  @Bind("firstName") String firstName,
                  @Bind("lastName") String lastName,
                  @Bind("position") String position);
}

Tested the query in mysql, it works fine, but ran it in unit test:

@Test 
public void testInsertPerson() {
    PersonDAO personDao = dao.getRegHandle().attach(PersonDAO.class);
    personDao.insertPerson(888888,"Tom", "Ford", "Manager");
}

I get an exception:

java.lang.IllegalStateException: method com.hrweb.dao.PersonDAO # insertPerson is annotated as if it were returning a value, but the method is not valid.

What am I doing wrong here?

+4
source share
1 answer

, SqlQuery, SqlUpdate insert. JDBI:

:

@SqlUpdate("insert into person(id,first_name,last_name,position) values(:id,:firstName,:lastName,:position)")

.

+7

Source: https://habr.com/ru/post/1527261/


All Articles