私はSpringが初めてなので、初歩的な質問をご容赦ください。CRUD操作を行うために、春ベースのカサンドラを使用しています。単純な挿入が機能していないようで、誰かが私が間違っていることを指摘できるかどうか疑問に思っていました. 以下は、単に挿入を行ったときに発生するエラーです
java.lang.IllegalAccessError: tried to access class org.springframework.data.mapping.model.BeanWrapper from class org.springframework.data.cassandra.convert.MappingCassandraConverter
at org.springframework.data.cassandra.convert.MappingCassandraConverter.writeInsertFromObject(MappingCassandraConverter.java:233) ~[spring-data-cassandra-1.2.2.RELEASE.jar:na]
at org.springframework.data.cassandra.convert.MappingCassandraConverter.write(MappingCassandraConverter.java:222) ~[spring-data-cassandra-1.2.2.RELEASE.jar:na]
at org.springframework.data.cassandra.core.CassandraTemplate.createInsertQuery(CassandraTemplate.java:841) ~[spring-data-cassandra-1.2.2.RELEASE.jar:na]
at org.springframework.data.cassandra.core.CassandraTemplate.doInsert(CassandraTemplate.java:640) ~[spring-data-cassandra-1.2.2.RELEASE.jar:na]
at org.springframework.data.cassandra.core.CassandraTemplate.insert(CassandraTemplate.java:238) ~[spring-data-cassandra-1.2.2.RELEASE.jar:na]
at org.springframework.data.cassandra.core.CassandraTemplate.insert(CassandraTemplate.java:233) ~[spring-data-cassandra-1.2.2.RELEASE.jar:na]
コードは次のとおりです。
@Configuration
@PropertySource(value = { "classpath:cassandra.properties" })
@EnableCassandraRepositories
public class CassandraConfig {
@Autowired
private Environment environment;
@Bean
public CassandraOperations cassandraTemplate(Session someSession) throws Exception {
return new CassandraTemplate(someSession);
}
@Bean
public CassandraMappingContext mappingContext() {
return new BasicCassandraMappingContext();
}
@Bean
public CassandraConverter converter() {
return new MappingCassandraConverter(mappingContext());
}}
セッションが有効であると仮定します。実際に書き込みを行うコードは次のとおりです
@Component
public class SomeQueries {
@Autowired
CassandraOperations cassandraOps;
public void insertCart(Addresses addr){
cassandraOps.insert(addr);
}
}
アドレスのオブジェクトは次のとおりです。
@Data
@NoArgsConstructor
@Table(value = "addresses")
public class Addresses implements Serializable{
@PrimaryKeyColumn(name = "account_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
private UUID accountId;
@PrimaryKeyColumn(name = "address_id", ordinal = 1, type = PrimaryKeyType.PARTITIONED)
private int addressId;
@PrimaryKeyColumn(name = "is_primary", ordinal = 2, type = PrimaryKeyType.PARTITIONED)
private boolean isPrimary;
@Column("name") private String name;
@Column("creation_date") private Date creationTimestamp;
@Column("last_modified_date") private Date lastModifiedTimestamp;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((accountId == null) ? 0 : accountId.hashCode());
result = prime * result + addressId;
result = prime * result + ((creationTimestamp == null) ? 0 : creationTimestamp.hashCode());
result = prime * result + (isPrimary ? 1231 : 1237);
result = prime * result + ((lastModifiedTimestamp == null) ? 0 : lastModifiedTimestamp.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DeliveryAddresses other = (DeliveryAddresses) obj;
if (accountId == null) {
if (other.accountId != null)
return false;
} else if (!accountId.equals(other.accountId))
return false;
else if (!address.equals(other.address))
return false;
if (addressId != other.addressId)
return false;
if (creationTimestamp == null) {
if (other.creationTimestamp != null)
return false;
} else if (!creationTimestamp.equals(other.creationTimestamp))
return false;
if (isPrimary != other.isPrimary)
return false;
if (lastModifiedTimestamp == null) {
if (other.lastModifiedTimestamp != null)
return false;
} else if (!lastModifiedTimestamp.equals(other.lastModifiedTimestamp))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
}
初期化に欠けているものはありますか?