InvalidRequestException(为什么:第1行:184匹配不匹配的字符')'期待' - ')

时间:2016-05-11 09:47:23

标签: java cassandra apache-storm kundera

当我尝试使用persist()方法和 kundera 框架将表保存到 cassandra 时,我收到错误:

    18976 [Thread-15-localhostAMQPbolt0-executor[2 2]] INFO  c.i.c.c.CassandraClientBase - Returning cql query  INSERT INTO "pieces"("width","depth","height","idpiece") VALUES(10.0,12.0,11.0,'1') .
18998 [Thread-15-localhostAMQPbolt0-executor[2 2]] INFO  d.c.DatabaseController - insert piece to database: SUCCESS
18998 [Thread-15-localhostAMQPbolt0-executor[2 2]] INFO  d.d.SensorDAOImpl - start to insert data
19011 [Thread-15-localhostAMQPbolt0-executor[2 2]] INFO  c.i.c.c.CassandraClientBase - Returning cql query  INSERT INTO "sensors"("event_time","temperature","pressure","IdSensor","date","this$0") VALUES(1462959800344,10.0,10.0,'1',150055,sensor.entitie.predefinedModel.SensorEntitie@1c4a9b7b) .
19015 [Thread-15-localhostAMQPbolt0-executor[2 2]] ERROR c.i.c.c.CassandraClientBase - Error while executing query  INSERT INTO "sensors"("event_time","temperature","pressure","IdSensor","date","this$0") VALUES(1462959800344,10.0,10.0,'1',150055,sensor.entitie.predefinedModel.SensorEntitie@1c4a9b7b)
19015 [Thread-15-localhostAMQPbolt0-executor[2 2]] INFO  c.i.c.c.CassandraClientBase - Returning delete query DELETE FROM "pieces" WHERE "idpiece" = '1'.
19018 [Thread-15-localhostAMQPbolt0-executor[2 2]] ERROR o.a.s.util - Async loop died!
java.lang.RuntimeException: com.impetus.kundera.KunderaException: com.impetus.kundera.KunderaException: InvalidRequestException(why:line 1:184 mismatched character ')' expecting '-')
        at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:448) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:414) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:73) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.daemon.executor$fn__8226$fn__8239$fn__8292.invoke(executor.clj:851) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.util$async_loop$fn__554.invoke(util.clj:484) [storm-core-1.0.0.jar:1.0.0]
        at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_99]
Caused by: com.impetus.kundera.KunderaException: com.impetus.kundera.KunderaException: InvalidRequestException(why:line 1:184 mismatched character ')' expecting '-')
        at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:180) ~[project-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
        at database.dao.SensorDAOImpl.insert(SensorDAOImpl.java:54) ~[project-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
        at database.controller.DatabaseController.saveSensorEntitie(DatabaseController.java:49) ~[project-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
        at connector.bolt.PrinterBolt.execute(PrinterBolt.java:66) ~[project-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.apache.storm.daemon.executor$fn__8226$tuple_action_fn__8228.invoke(executor.clj:731) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.daemon.executor$mk_task_receiver$fn__8147.invoke(executor.clj:463) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.disruptor$clojure_handler$reify__7663.onEvent(disruptor.clj:40) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:435) ~[storm-core-1.0.0.jar:1.0.0]
        ... 6 more

如你所见,我想使用onetomany 我的班级实体

@Entity
@Table(name = "pieces", schema = "mykeyspace@cassandra_pu")
public class PieceEntitie implements Serializable{

    @Id
    private String IdPiece;
    @Column
    private double width;
    @Column
    private double height;
    @Column
    private double depth;

我的班级传感器实体

@EmbeddedId
    private CompoundKey key;
    @Column
    private float temperature;
    @Column
    private float pressure;

    @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
    @JoinColumn(name="idsensor")
    private List<PieceEntitie> pieces;



    @Embeddable
    public class CompoundKey
    {
            @Column 
            private String IdSensor;           
            @Column 
            private long date;           
            @Column(name = "event_time")
            private long eventTime;



    }

我的桌子:

    CREATE TABLE mykeyspace.sensors (
    idsensor text,
    date bigint,
    event_time timestamp,
    pressure float,
    temperature float,
    PRIMARY KEY ((idsensor, date), event_time)
) WITH CLUSTERING ORDER BY (event_time ASC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
    AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99.0PERCENTILE';

cqlsh:sensor> DESCRIBE table pieces ;

CREATE TABLE mykeyspace.pieces (
    idpiece text PRIMARY KEY,
    depth double,
    height double,
    idsensor text,
    width double
) WITH bloom_filter_fp_chance = 0.01
    AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
    AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99.0PERCENTILE';

教程紧随其后; https://github.com/impetus-opensource/Kundera/wiki/Polyglot-Persistence

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我通过分离CompoundKey类和传感器类解决了这个问题。 在我将CompoundKey类放入传感器类之前,所以Kundera试图将CompoundKey作为属性插入