-
Notifications
You must be signed in to change notification settings - Fork 0
Cassitory using only prepared statements
Cael edited this page Jun 28, 2019
·
4 revisions
If your project is not using Mappers and you just have the prepared statements then Cassitory gives you a way to generate your repository by generating all the prepared statements needed to accomplish the goal.
Add the following dependency to your build.gradle
annotationProcessor 'uk.co.caeldev:cassitory:1.0.0'
Create your DTO and annotate it with the following Cassitory annotations:
uk.co.caeldev.cassitory.statements.CassitoryEntity
uk.co.caeldev.cassitory.statements.Mapping
eg:
package statements;
import uk.co.caeldev.cassitory.statements.Mapping;
import uk.co.caeldev.cassitory.statements.CassitoryEntity;
@CassitoryEntity(tables = {"users", "users_by_name"})
public class UserDto2 {
@Mapping(table = "users", field = "name",pk = true)
@Mapping(table = "users_by_name", field = "fullName", pk = true)
private String fullName;
public String getFullName() {
return fullName;
}
}
Once you annotated your DTO class then you should be able to find the repository by following the convention of
<DTO_NAME>BaseStatementRepository
and then just instantiate it by
Session session;
UserDtoBaseStatementRepository repo = new UserDtoBaseStatementRepository(session)