class PartitionUserKey(email: String, id: UUID) {
var email: String = email
var id: UUID = id
}
class CompositeUserKey(email: String, userId: Long, id: UUID = UUID.randomUUID()) {
@EmbeddedId
var key: PartitionUserKey = PartitionUserKey(email = email, id = id)
var userId = userId
}
@Table(name = "UserBean",
indexes = arrayOf(
Index(name = "userbean_email_idx", columnList = "email")
)
)
public class UserBean(userId: Long,
aboutMeInfo: String,
firstName: String,
lastName: String,
email: String,
passwordHash: String) : BaseBean() {
@EmbeddedId
var key: CompositeUserKey = CompositeUserKey(email, userId)
var createdDate: Date = Date()
var firstName: String = firstName
var lastName: String = lastName
var profilePicUrl: String = ""
var aboutMeInfo: String = aboutMeInfo
var passwordHash: String = passwordHash
var postsCount: Long = 0
var messagesCount: Long = 0
var chatsCount: Long = 0
var loginCount: Long = 0
var activeSessionCount: Long = 0
var hasLikesTotal: Long = 0
var hasCommentsTotal: Long = 0
var hasRepostsTotal: Long = 0
var friendsIds: MutableList<String> = mutableListOf<String>()
var followingFriendsIds: MutableList<String> = mutableListOf<String>() // that u requested
var followersFriendsIds: MutableList<String> = mutableListOf<String>()
val email: String
@Transient
get() = key.key.email
val userId: Long
@Transient
get() = key.userId
override var id: UUID
@Transient
get() = key.key.id
@Transient
set(value) {
key.key.id = value
}
}
code for get
// get Entity Metadata
val emeta = EntityTypeParser.getEntityMetadata(UserBean::class.java)
// get field metadata by property/field name
val fmeta = emeta.getFieldMetadata("email")
// build query.
val query = QueryBuilder.select().all()
.from(Connection.keyspaceName, emeta.tableName).where(
eq(fmeta.columnName, email))
// run query
val result = Connection.mappingSession.getByQuery(UserBean::class.java, query)
in result gives arraylist with nulls, but not objects
code for bean
code for get
in result gives arraylist with nulls, but not objects