Tag: 版本库

Kotlin使用SpringData Jpa定制存储库

这是我的代码。 我定制了我的存储库。 interface ChapterDao { fun test(novelId:String):List<Chapter> } class ChapterDaoImpl constructor(@PersistenceContext var entityManager: EntityManager){ fun test(novelId: String): List<Chapter> { val query = entityManager.createNativeQuery("select c.name, c.number from chapter c where c.novel.id = $novelId") val resultList = query.resultList as Array<Array<Any>> var chapterList:ArrayList<Chapter> = ArrayList<Chapter>() for (item in resultList){ chapterList.add(Chapter(item.get(0) as String,item.get(1) as Int)) } return chapterList } […]