1
我有一張名爲LocalEventSessions
的表格。它有2列,localevent_id
和session_id
。如何刪除連接表中的行?
在我LocalEventSessionRepository
我有這樣的代碼:
List<LocalEventSession> findAllByLocalEventSessionId_localEventId(Integer id);
這將返回屬於LocalEvent所有會話的列表。這用於顯示會話。
我想刪除與localevent的會話關係。所以我寫了這一點:
Integer deleteByLocalEventIdAndSessionId(@Param("localevent_id") Integer lid, @Param("session_id") Integer sid);
我預計這將在LocalEventSession
表基礎上,localevent_id
和session_id
刪除記錄。我可以毫無問題地編譯代碼,但是當我用Wildfly部署它時,我收到了一些錯誤。在堆棧跟蹤結束時,它顯示Wildfly無法找到localEventId屬性。
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [localEventId] on this ManagedType [net.atos.eventsite.jar.LocalEventSession]"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./beheerback"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
如果我沒有deleteBy
方法聲明中部署它的代碼編譯,並沒有任何問題展開。
要刪除連接表的一行,只需從使用該連接表映射的集合中刪除該元素:'course.students.remove(student)' –
@JBNizet在arraylist上使用.remove我能te從數組中刪除一個對象,但不是從表中刪除一個對象。我所要做的就是找到正確的對象,並使用Spring的.delete()方法將它從數據庫中刪除。像這樣'localEventSessionRepository.delete(j);'J是一個for循環比較localevent_id和sessions_id的對象。 –
它正在尋找'localEventId',但你似乎有'localevent_id'。 –