I have the following POJO:
@Table(name = "order", readConsistency = "QUORUM", writeConsistency = "QUORUM")
public class Order {
@Column(name = "id")
@PartitionKey
private String id;
@Column(name = "customer_id")
private String customerId;
@Column(name = "loyalty_id")
private String loyaltyId;
@Column(name = "customer_email")
private String customerEmail;
public Order() {
}
... getters and setters
}
And now I am writing the OrderDao as following:
import com.datastax.oss.driver.api.mapper.annotations.*;
@Dao
public interface OrderDao {
@Select
Order findById(String orderId);
@Insert
void save(Order order);
@Delete
void delete(Order order);
}
And when I do ./gradlew build
I get the following errors:
error: Invalid return type: Select methods must return one of [ENTITY, OPTIONAL_ENTITY, FUTURE_OF_ENTITY, FUTURE_OF_OPTIONAL_ENTITY, PAGING_ITERABLE, FUTURE_OF_ASYNC_PAGING_ITERABLE]
Order findById(String orderId);
error: Insert methods must take the entity to insert as the first parameter
void save(Order order);
^
error: Missing entity class: Delete methods that do not operate on an entity instance must have an 'entityClass' argument
void delete(Order order);
^
I am implementing by following the documentation here: https://docs.datastax.com/en/developer/java-driver/4.2/manual/mapper/ . What could be the possible cause of this?
Thanks.
You are missing the @Entity
annotation on your Order
class:
@Entity
@Table(name = "order", readConsistency = "QUORUM", writeConsistency = "QUORUM")
public class Order {