valchkou / cassandra-driver-mapping

JPA addon for DataStax Java Driver for Cassandra
58 stars 24 forks source link

Add support to @Embedded #85

Open gb opened 6 years ago

gb commented 6 years ago

Fixes #84

rahulsrivastava71 commented 5 years ago

why this change is required i am not able to get it, as the commit message also do not explain it

gb commented 5 years ago

@rahulsrivastava71 sorry for the lack of the description, IMHO the code was self-explanatory, but let me try to fix it:

Given an entity A that contains an Object B as part of it table fields.

Example:

@Table
class A {
      @Id
      long id;
      @Column
      String field1; 
      @Embedded
      B embeddedField;
}

@Embeddable
class B {
     @Column
     String field2;
     @Column
     String field3;
     @Column
     String field4;
}

In JPA, we have a concept of Embedded/Embeddable. If you save the entity A, all the fields from the Embeddable B should also be saved.

i.e. Table A { id, field1, field2, field3, field4 }

Without my PR, the embedded/embeddable is completely ignored, so, if you save A, you only will persist Table A { id, field1 }, after my change, it works as expected.

rahulsrivastava71 commented 5 years ago

LGTM!