同様の結果が返されるデータを保持するためのフィールドを持つクラスを作成します@QueryResult
- を用いて達成することができます。
- 注釈を
@QueryResult
例:次のように
@QueryResult
open class Principal constructor(applicationToken: String,
profileId: String,
stageName: String,
showMeLaterDays: Float,
roles: Array<Role>)
{
var applicationToken: String
var profileId: String
var stageName: String
var showMeLaterDays: Float
@Convert(RoleArrayAttributeConverter::class)
var roles: Array<Role>
init
{
this.applicationToken = applicationToken
this.profileId = profileId
this.stageName = stageName
this.showMeLaterDays = showMeLaterDays
this.roles = roles
}
//Provide a default constructor for OGM
constructor() : this(applicationToken = "", profileId = "", stageName = "", showMeLaterDays = 0f,
roles = emptyArray())
}
リポジトリとそれを使用する(私は手に持っていたものであるKotlin、IN):
@Query("MATCH (n:CandidateProfile {applicationToken: {0} })
RETURN n.id as profileId, n.applicationToken as applicationToken, n.stageName as stageName, n.showMeLaterDays as showMeLaterDays, n.roles as roles;")
fun findByApplicationToken(token: String): Principal?
- ノードプロパティがクラスフィールド名に対応するように返される方法に注意してください。
- 同じことを関数の結果で行うことができます。
注:もっとイディオム的なKotlin POJOについては、https://github.com/neo4j-examples/movies-kotlin-spring-data-neo4jを参照してください。 –