kundera icon indicating copy to clipboard operation
kundera copied to clipboard

Compound partition key with foreign key reference

Open si24803 opened this issue 8 years ago • 2 comments

Hello again, team Kundera.

First of all, thank you for your great work and top notch support. I'm using kundera-cassandra 3.8 and kundera-cassandra-ds-driver 3.8 and have a mapping problem for autogeneration of the schema. My problem is as follows:

`// parent entity A { @Id string id; string value; }

and

// child entity B { @EmbeddedId @OrderBy(value="clusterValue DESC") Bck clusteringKey; string value;

@ManyToOne @MapsId("clusterKey.partitionKey.A_ID") A a; }

Bck { @Embedded Bpk partitionKey; string clusterValue; }

// B's partition key @Embeddable Bpk { string year; string A_ID; }`

Kundera is unable to establish this relation without duplicating fields. Can you tell me if this is possible/desirable? If the mapping field is in the clustering key, it works. If the mapping field is in the B class, it also works. So why not in the partition key? I don't want the OneToMany in A since B can only be retrieved by combining both year and A_ID.

Thank you

si24803 avatar Mar 23 '17 01:03 si24803

Of course, Bck is also Embeddable

si24803 avatar Mar 23 '17 09:03 si24803

@si24803

Hey Pedro,

This feature is not supported in Kundera. We can discuss your use case and come up with a better data model. I am not able to understand the point of keeping a join column as a part of partition key, as it wont be useful in reverse querying if at all required.

Lets discuss on gitter.

-Karthik

karthikprasad13 avatar Mar 23 '17 16:03 karthikprasad13