Announcement Announcement Module
Collapse
No announcement yet.
CassandraTemplate.queryForList() not returning proper types? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CassandraTemplate.queryForList() not returning proper types?

    I've got a test case that looks like this:


    @Test
    public void testPojoMapping() {
    Person p = new Person();
    p.setFirstName("Hello");
    p.setLastName("Cassandra");
    template.insert(p);
    final List<Person> people = template.queryForList("select * from Person", Person.class);
    assertEquals(1, people.size());
    assertEquals(p, people.get(0));
    }

    The second assertion fails, because what is returned from the query isn't a List<Person> but a List<String> (the first column in the result set is the id, which is a String). Is there something I have to do to get it to actually return a Person object?

  • #2
    FYI:

    https://github.com/jwcarman/cassandr...plateTest.java

    Comment


    • #3
      Nevermind, RTFM: "Executes the provided CQL and returns all values in the first column of the Results as a List of the Type" DUH! Is there a way to reverse-map my objects?

      Comment


      • #4
        Please, move your question to the StackOverflow - we are going to close this forum soon and rely on SO.
        We need to clean this forum (old unanswered question) before close it.

        Thanks for understanding

        Comment

        Working...
        X