InvalidQueryException: Undefined column name typeid

Author: Hindol Dey

I have the following database pojo for an employee class. The tables are already created

@Table(value = "employee") {
public class Employee implements Serializable{

    @Id
    @PrimaryKeyColumn(name = "employee_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
    private String empId;

    @Column(value="info")
    @CassandraType(type = DataType.Name.UDT, userTypeName = "emp_info")
    private EmployeeInfo info;

    // getters & setters
}

When I am trying to do repository.findById(), it is giving me the following error.

org.springframework.data.cassandra.CassandraInvalidQueryException: Query; CQL [SELECT * FROM employee WHERE empid='123';]; Undefined column name typeid; nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Undefined column name empid.

It seems that somehow my code is not picking up the mentioned column name "employee_id". Not sure what I am doing wrong here. I have tried both the attribute name and value for @PrimaryKeyColumn. They are both giving me the same error.

My stacktrace is,

org.springframework.data.cassandra.CassandraInvalidQueryException: Query; CQL [SELECT * FROM employee WHERE empid='123';]; Undefined column name typeid; nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Undefined column name empid.
web_1  |    at org.springframework.data.cassandra.core.cql.CassandraExceptionTranslator.translate(CassandraExceptionTranslator.java:139)
web_1  |    at org.springframework.data.cassandra.core.cql.CassandraAccessor.translate(CassandraAccessor.java:334)
web_1  |    at org.springframework.data.cassandra.core.cql.CqlTemplate.translateException(CqlTemplate.java:732)
web_1  |    at org.springframework.data.cassandra.core.cql.CqlTemplate.query(CqlTemplate.java:298)
web_1  |    at org.springframework.data.cassandra.core.cql.CqlTemplate.query(CqlTemplate.java:318)
web_1  |    at org.springframework.data.cassandra.core.CassandraTemplate.select(CassandraTemplate.java:246)
web_1  |    at org.springframework.data.cassandra.repository.query.CassandraQueryExecution$SingleEntityExecution.execute(CassandraQueryExecution.java:137)
web_1  |    at org.springframework.data.cassandra.repository.query.CassandraQueryExecution$ResultProcessingExecution.execute(CassandraQueryExecution.java:188)
web_1  |    at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:85)
web_1  |    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:602)
web_1  |    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:590)
web_1  |    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
web_1  |    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
web_1  |    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
web_1  |    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
web_1  |    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
web_1  |    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
web_1  |    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
web_1  |    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
web_1  |    at com.sun.proxy.$Proxy137.findByTypeId(Unknown Source)
web_1  |    at com.demo.employee.ConfigService.readConfig(ConfigService.java:163)

Please let me know if I am missing out any information to share.

Originally Sourced from: https://stackoverflow.com/questions/57456541/invalidqueryexception-undefined-column-name-typeid