You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that when having composite key in the entity, generated DDL differs when @PrimaryKeyColumn.name is used.
spring-data-cassandra version - 4.0.4
java-driver-core - 4.15.0
cassandra server - 4.0.8
Example:
@PrimaryKeyClass
public class PersonKey implements Serializable {
@PrimaryKeyColumn(name = "firstname", type= PrimaryKeyType.PARTITIONED)
private String firstName;
@PrimaryKeyColumn(name="aname", type = PrimaryKeyType.PARTITIONED)
private String aName;
@PrimaryKeyColumn(name="lastname", type = PrimaryKeyType.CLUSTERED)
private String lastName;
@PrimaryKeyColumn(name= "bname", type = PrimaryKeyType.CLUSTERED)
private String bName;
}
Generated DDL is
CREATE TABLE springtest.person (
aname text,
firstname text,
bname text,
lastname text,
age text,
PRIMARY KEY ((aname, firstname), bname, lastname)
) WITH CLUSTERING ORDER BY (bname ASC, lastname ASC)
CREATE TABLE springtest.person (
firstname text,
aname text,
lastname text,
bname text,
age text,
PRIMARY KEY ((firstname, aname), lastname, bname)
) WITH CLUSTERING ORDER BY (lastname ASC, bname ASC)
It seems issue is not using class field name as column name while ordering the properties of the primary key class Entity. Please confirm whether this is an issue.
Thanks
The text was updated successfully, but these errors were encountered:
It is unfortunate to have the name within the column name comparison, but we always considered the column name as comparison argument. This issue is a bug at its core because we should not sort by column name but rather fall back to the field order.
For the time being, please use @PrimaryKeyColumn(ordinal = …) to provide a sort order for your columns.
mp911de
changed the title
Generated DDL is different when column name is used in composite primary key CassandraPersistentPropertyComparator and CassandraPrimaryKeyColumnAnnotationComparator sort properties by column name
Apr 6, 2023
I found that when having composite key in the entity, generated DDL differs when @PrimaryKeyColumn.name is used.
spring-data-cassandra version - 4.0.4
java-driver-core - 4.15.0
cassandra server - 4.0.8
Example:
Generated DDL is
Generated DDL is
It seems issue is not using class field name as column name while ordering the properties of the primary key class Entity. Please confirm whether this is an issue.
Thanks
The text was updated successfully, but these errors were encountered: