Created 07-06-2017 11:07 AM
Hi All,
I have a phoenix table which there is a column which stores an array as the variable type.
The table is defined as below:
CREATE TABLE IF NOT EXISTS ENVI_DATA ( PATIENT_ID VARCHAR(50) NOT NULL, RECORD_DATE TIMESTAMP NOT NULL, STEPS INTEGER NULL, STEPS_TIME TIMESTAMP NULL, SPEED FLOAT NULL, SPEED_TIME TIMESTAMP NULL, USER_ROUTES BIGINT[] NULL, LATITUDE INTEGER NULL, LONGITUDE INTEGER NULL, LOCATION_RECORD_TIME TIMESTAMP NULL, CONSTRAINT PK PRIMARY KEY ( PATIENT_ID, MOBILE_ID, RECORD_DATE ) ) VERSIONS=3,SALT_BUCKETS=16;
The USER_ROUTES BIGINT[] NULL, is defined as long[] in the program.
And I have a method to query the data:
public EnviData query(String id){ String querySql= "SELECT * FROM ENVI_DATA where PATIENT_ID=?"; RowMapper<EnviData> rowMapper = new BeanPropertyRowMapper<EnviData>(EnviData.class); return jdbcTemplate.update(querySql, rowMapper, id); }
However, I got the following error:
"Failed to convert property value of type 'org.apache.phoenix.schema.types.PhoenixArray$PrimitiveLongPhoenixArray' to required type 'long[]' for property 'USER_ROUTES'
Which means the USER_ROUTES cann't convert to the type of long[].
I want to ask, do I need to write my own row mapper for this?
Created 07-06-2017 02:31 PM
You likely need to share your application and the stack-trace to get help. It seems like this might be more of an issue with Spring and Phoenix.
Created 07-26-2017 09:22 AM
Can you try something like this:-
String querySql= "SELECT * FROM ENVI_DATA where PATIENT_ID=?"; RowMapper<EnviData> rowMapper = newRowMapper<EnviData>(){ @Override public EnviData mapRow(ResultSet rs,int rowNum) throwsSQLException{ EnviData data =new EnviData(); data.setPatientId(rs.getString(1)); data.setUserRoutes(rs.getArray(7).getArray()); } return jdbcTemplate.update(querySql, rowMapper, id);
Created 07-27-2017 11:57 AM
Hi Ankit,
Thanks for your information. I solved the problem by changing long[] to Long[].