OneToMany关系无效

时间:2016-05-11 14:09:44

标签: java hibernate cassandra one-to-many kundera

我想在我的传感器类与使用 kundera 作为框架的片段类和 cassandra 作为我的数据库之间创建一个关系:

我试图做的是:每个传感器与许多部件相关联:

传感器1____0 *件

但是在完成这个配置之后(下面),我得到了两个没有任何关系的单独的表:

 idsensor | date  | event_time               | pressure | temperature
----------+-------+--------------------------+----------+-------------
        1 | 33544 | 1970-01-01 00:00:00+0000 |       10 |          10

(1 rows)
cqlsh:sensor> select * from pieces;

 idpiece | date | depth | event_time | height | idsensor | sensorkey | width
---------+------+-------+------------+--------+----------+-----------+-------
       1 | null |    12 |       null |     11 |     null |      null |    10

关键课程:

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

传感器类

   public class SensorEntitie implements Serializable {
    @EmbeddedId
    private SensorKey sensorkey;
    @Column
    private float temperature;
    @Column
    private float pressure;
    @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
    @JoinColumns({
        @JoinColumn(name = "idsensor", referencedColumnName = "idsensor"),
        @JoinColumn(name = "date", referencedColumnName = "date",
            insertable = false, updatable = false),
        @JoinColumn(name = "event_time", referencedColumnName = "event_time",
            insertable = false, updatable = false)
})
    private Set<PieceEntitie> pieces;

件类:

public class PieceEntitie implements Serializable{


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

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

我该如何创建这种关系?

1 个答案:

答案 0 :(得分:0)

使用Cassandra 3后问题已解决

因为在我使用cassandra 2.1之前