com.datastax.driver.core.exceptions.InvalidTypeException: Column phones is of type 'org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UserType(complex,70686f6e65,616c696173:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))', cannot set to a list

DataStax JIRA | Nathan Scully | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    I am receiving an InvalidTypeException when attempting to set a collection on a UDT. I am copying the example from the Datastax site: [http://www.datastax.com/documentation/developer/java-driver/2.1/java-driver/reference/udtApi.html] Setup: {code:java} session.execute("CREATE TYPE complex.phone (" + " alias text," + " number text);" ); session.execute("CREATE TYPE complex.address (" + " street text," + " zip_code int," + " phones list<frozen<phone>>);" // NOTE: In the example this is 'phones list<phone>' - but I receive the following error if I don't set this to frozen: InvalidQueryException: Non-frozen collections are not allowed inside collections: list<phone> ); session.execute("CREATE TABLE complex.users (" + " id uuid PRIMARY KEY," + " name text," + " addresses frozen <address>);"); {code} And then running the following as a test: {code:java} PreparedStatement insertUserPreparedStatement = session.prepare("INSERT INTO complex.users (id, name, addresses) VALUES (?, ?, ?);"); PreparedStatement selectUserPreparedStatement = session.prepare("SELECT * FROM complex.users WHERE id = ?;"); UserType addressUDT = session.getCluster().getMetadata().getKeyspace("complex").getUserType("address"); UserType phoneUDT = session.getCluster().getMetadata().getKeyspace("complex").getUserType("phone"); UDTValue phone1 = phoneUDT.newValue() .setString("alias", "home") .setString("number", "1-707-555-1234"); UDTValue phone2 = phoneUDT.newValue() .setString("alias", "work") .setString("number", "1-800-555-9876"); UDTValue address = addressUDT.newValue() .setString("street", "123 Arnold Drive") .setInt("zip_code", 95476) .setList("phones", ImmutableList.of(phone1, phone2)); // ERROR THROWN HERE Map<String, UDTValue> addresses = new HashMap<String, UDTValue>(); addresses.put("Work", address); UUID userId = UUID.fromString("fbdf82ed-0063-4796-9c7c-a3d4f47b4b25"); session.execute(insertUserPreparedStatement.bind(userId, "G. Binary", addresses)); {code} This throws the error: {code:java} Exception in thread "main" com.datastax.driver.core.exceptions.InvalidTypeException: Column phones is of type 'org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UserType(complex,70686f6e65,616c696173:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))', cannot set to a list at com.datastax.driver.core.AbstractData.setList(AbstractData.java:277) at com.datastax.driver.core.AbstractData.setList(AbstractData.java:297) at DatastaxUDTExample.loadUsers(DatastaxUDTExample.java:92) at DatastaxUDTExample.main(DatastaxUDTExample.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) {code}

    DataStax JIRA | 2 years ago | Nathan Scully
    com.datastax.driver.core.exceptions.InvalidTypeException: Column phones is of type 'org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UserType(complex,70686f6e65,616c696173:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))', cannot set to a list
  2. 0

    I am receiving an InvalidTypeException when attempting to set a collection on a UDT. I am copying the example from the Datastax site: [http://www.datastax.com/documentation/developer/java-driver/2.1/java-driver/reference/udtApi.html] Setup: {code:java} session.execute("CREATE TYPE complex.phone (" + " alias text," + " number text);" ); session.execute("CREATE TYPE complex.address (" + " street text," + " zip_code int," + " phones list<frozen<phone>>);" // NOTE: In the example this is 'phones list<phone>' - but I receive the following error if I don't set this to frozen: InvalidQueryException: Non-frozen collections are not allowed inside collections: list<phone> ); session.execute("CREATE TABLE complex.users (" + " id uuid PRIMARY KEY," + " name text," + " addresses frozen <address>);"); {code} And then running the following as a test: {code:java} PreparedStatement insertUserPreparedStatement = session.prepare("INSERT INTO complex.users (id, name, addresses) VALUES (?, ?, ?);"); PreparedStatement selectUserPreparedStatement = session.prepare("SELECT * FROM complex.users WHERE id = ?;"); UserType addressUDT = session.getCluster().getMetadata().getKeyspace("complex").getUserType("address"); UserType phoneUDT = session.getCluster().getMetadata().getKeyspace("complex").getUserType("phone"); UDTValue phone1 = phoneUDT.newValue() .setString("alias", "home") .setString("number", "1-707-555-1234"); UDTValue phone2 = phoneUDT.newValue() .setString("alias", "work") .setString("number", "1-800-555-9876"); UDTValue address = addressUDT.newValue() .setString("street", "123 Arnold Drive") .setInt("zip_code", 95476) .setList("phones", ImmutableList.of(phone1, phone2)); // ERROR THROWN HERE Map<String, UDTValue> addresses = new HashMap<String, UDTValue>(); addresses.put("Work", address); UUID userId = UUID.fromString("fbdf82ed-0063-4796-9c7c-a3d4f47b4b25"); session.execute(insertUserPreparedStatement.bind(userId, "G. Binary", addresses)); {code} This throws the error: {code:java} Exception in thread "main" com.datastax.driver.core.exceptions.InvalidTypeException: Column phones is of type 'org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UserType(complex,70686f6e65,616c696173:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))', cannot set to a list at com.datastax.driver.core.AbstractData.setList(AbstractData.java:277) at com.datastax.driver.core.AbstractData.setList(AbstractData.java:297) at DatastaxUDTExample.loadUsers(DatastaxUDTExample.java:92) at DatastaxUDTExample.main(DatastaxUDTExample.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) {code}

    DataStax JIRA | 2 years ago | Nathan Scully
    com.datastax.driver.core.exceptions.InvalidTypeException: Column phones is of type 'org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UserType(complex,70686f6e65,616c696173:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))', cannot set to a list

    Root Cause Analysis

    1. com.datastax.driver.core.exceptions.InvalidTypeException

      Column phones is of type 'org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UserType(complex,70686f6e65,616c696173:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))', cannot set to a list

      at com.datastax.driver.core.AbstractData.setList()
    2. DataStax Java Driver for Apache Cassandra - Core
      AbstractData.setList
      1. com.datastax.driver.core.AbstractData.setList(AbstractData.java:277)
      2. com.datastax.driver.core.AbstractData.setList(AbstractData.java:297)
      2 frames
    3. Unknown
      DatastaxUDTExample.main
      1. DatastaxUDTExample.loadUsers(DatastaxUDTExample.java:92)
      2. DatastaxUDTExample.main(DatastaxUDTExample.java:57)
      2 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:483)
      4 frames
    5. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
      1 frame