How does BeanPropertyRowMapper work inside spring?

I know it BeanPropertyRowmapperuses a method setterwhen I run a request select, but uses a methodgetter ?

I ran into a problem below:

The databasedefaultPriority value is in string, but I want to set the value intin the SMSActionpojo class .

class SMSAction implements Serializable {

private int defaultPriority;

public int getDefaultPriority() {
    System.out.println("Inside getDefaultPriority()");
    return defaultPriority;
}

public void setDefaultPriority(String defaultPriority) {
    System.out.println("Inside setDefaultPriority(String defaultPriority)"+defaultPriority);

    if(defaultPriority.equalsIgnoreCase("L")){
        System.out.println("Condition");
        this.defaultPriority = 1;
    }
  }
}    

and this is the error I get:

Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [select SMSACTIONID,SMSACTIONCODE,ACTIONDESC,CASID,DEFAULTPRIORITY from tblsmsaction]; SQL state [99999]; error code [17059]; Fail to convert to internal representation; nested exception is java.sql.SQLException: Fail to convert to internal representation
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:660)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)

How to solve the problem described above when the data type is different from the database and my pojo? When I changed to , then it works fine , but I can’t understand why to use , and also my printed inside is not displayed . return type of getDefaultPriority()stringBeanPropertyRowmappergetDefaultPrioriy()loggetDefaultPriority()

. JPA. , .

+4
1

-, - ( ) . set - ( class). Setters/Getters ; , int, , , int , / bean.

, String , :

// [db layer] here you already got the real value(s) through a database call
SMSAction action = new SMSAction();

// priority is some arbitrary name I used to simulate the variable that holds the String coming from the database
if (priority.equalsIgnoreCase("L")) {
  action.setDefaultPriority(1);
}
// ...

- , ; , , DTO/wrapper - .

!

0

All Articles