java.lang.IllegalArgumentException: UDT conversion mismatch: expected type umv.entitlement, got umv.entitlement

DataStax JIRA | Christopher Batey | 2 years ago
  1. 0

    I have a simple UDT example and trying to use the Datastax Driver mapping feature. Here's my UDT: {code} cqlsh:umv> DESCRIBE TYPE umv.entitlement ; CREATE TYPE umv.entitlement ( name text, start_date timestamp, end_date timestamp ); {code} Here is my table: {code} cqlsh:umv> DESCRIBE TABLE household_entitlement; CREATE TABLE umv.household_entitlement ( household_id text, provider text, entitlement frozen<entitlement>, PRIMARY KEY ((household_id, provider)) ) {code} Which all works in CQLSH. Then from Java I have the following class to map the UDT to: {code} @UDT(name = "entitlement", keyspace = "umv") public static class Entitlement { @Field(name = "name") private String name; @Field(name = "start_date") private Date startDate; @Field(name = "end_date") private Date endDate; public String getName() { return name; } public Date getStartDate() { return startDate; } public Date getEndDate() { return endDate; } public void setName(String name) { this.name = name; } public void setStartDate(Date startDate) { this.startDate = startDate; } public void setEndDate(Date endDate) { this.endDate = endDate; } @Override public String toString() { return "Entitlement{" + "name='" + name + '\'' + ", startDate=" + startDate + ", endDate=" + endDate + "} " + super.toString(); } } {code} And then some code to select all from the table: {code} public static void main(String[] args) throws Exception { Cluster cluster = Cluster.builder().addContactPoint("192.168.10.10").build(); Session umvKeyspace = cluster.connect("umv"); UDTMapper<Entitlement> mapper = new MappingManager(umvKeyspace).udtMapper(Entitlement.class); ResultSet execute = umvKeyspace.execute("select * from household_entitlement"); for (Row row : execute) { UDTValue entitlement = row.getUDTValue("entitlement"); System.out.println(entitlement); System.out.println(mapper.fromUDT(entitlement)); } umvKeyspace.close(); cluster.close(); } {code} I get the following exception: {code} Exception in thread "main" java.lang.IllegalArgumentException: UDT conversion mismatch: expected type umv.entitlement, got umv.entitlement at com.datastax.driver.mapping.UDTMapper.fromUDT(UDTMapper.java:66) at UDTSpike.main(UDTSpike.java:22) {code} The versions are: {code} vagrant@cassandra-spark:~$ cqlsh Connected to Test Cluster at 192.168.10.10:9042. [cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3] {code} However if i use 2.1.1 of the driver it works fine.

    DataStax JIRA | 2 years ago | Christopher Batey
    java.lang.IllegalArgumentException: UDT conversion mismatch: expected type umv.entitlement, got umv.entitlement
  2. 0

    I have a simple UDT example and trying to use the Datastax Driver mapping feature. Here's my UDT: {code} cqlsh:umv> DESCRIBE TYPE umv.entitlement ; CREATE TYPE umv.entitlement ( name text, start_date timestamp, end_date timestamp ); {code} Here is my table: {code} cqlsh:umv> DESCRIBE TABLE household_entitlement; CREATE TABLE umv.household_entitlement ( household_id text, provider text, entitlement frozen<entitlement>, PRIMARY KEY ((household_id, provider)) ) {code} Which all works in CQLSH. Then from Java I have the following class to map the UDT to: {code} @UDT(name = "entitlement", keyspace = "umv") public static class Entitlement { @Field(name = "name") private String name; @Field(name = "start_date") private Date startDate; @Field(name = "end_date") private Date endDate; public String getName() { return name; } public Date getStartDate() { return startDate; } public Date getEndDate() { return endDate; } public void setName(String name) { this.name = name; } public void setStartDate(Date startDate) { this.startDate = startDate; } public void setEndDate(Date endDate) { this.endDate = endDate; } @Override public String toString() { return "Entitlement{" + "name='" + name + '\'' + ", startDate=" + startDate + ", endDate=" + endDate + "} " + super.toString(); } } {code} And then some code to select all from the table: {code} public static void main(String[] args) throws Exception { Cluster cluster = Cluster.builder().addContactPoint("192.168.10.10").build(); Session umvKeyspace = cluster.connect("umv"); UDTMapper<Entitlement> mapper = new MappingManager(umvKeyspace).udtMapper(Entitlement.class); ResultSet execute = umvKeyspace.execute("select * from household_entitlement"); for (Row row : execute) { UDTValue entitlement = row.getUDTValue("entitlement"); System.out.println(entitlement); System.out.println(mapper.fromUDT(entitlement)); } umvKeyspace.close(); cluster.close(); } {code} I get the following exception: {code} Exception in thread "main" java.lang.IllegalArgumentException: UDT conversion mismatch: expected type umv.entitlement, got umv.entitlement at com.datastax.driver.mapping.UDTMapper.fromUDT(UDTMapper.java:66) at UDTSpike.main(UDTSpike.java:22) {code} The versions are: {code} vagrant@cassandra-spark:~$ cqlsh Connected to Test Cluster at 192.168.10.10:9042. [cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3] {code} However if i use 2.1.1 of the driver it works fine.

    DataStax JIRA | 2 years ago | Christopher Batey
    java.lang.IllegalArgumentException: UDT conversion mismatch: expected type umv.entitlement, got umv.entitlement
  3. 0

    Failed Decode, retrieved files unreadable.

    GitHub | 6 months ago | mupet0000
    java.lang.IllegalArgumentException: tag mismatch, expected 1 got 2490
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Array subscript operator fails for array[null][null]

    GitHub | 2 years ago | nezihyigitbasi
    java.lang.IllegalArgumentException: Expected one type, got {}
  6. 0

    Server unable to decode large response

    GitHub | 8 months ago | Endebert
    java.lang.IllegalArgumentException: Invalid value type, expected INTEGER, got STRING

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      UDT conversion mismatch: expected type umv.entitlement, got umv.entitlement

      at com.datastax.driver.mapping.UDTMapper.fromUDT()
    2. com.datastax.driver
      UDTMapper.fromUDT
      1. com.datastax.driver.mapping.UDTMapper.fromUDT(UDTMapper.java:66)
      1 frame
    3. Unknown
      UDTSpike.main
      1. UDTSpike.main(UDTSpike.java:22)
      1 frame