I have a collection in my model that contains a set of \'previous versions\' of my root domain object. The previous versions are therefore \'immutable\' and we will never wa
I used to create a native query for this cases, like below:
@Modifying
@Transactional
@Query(nativeQuery = true, value = "INSERT INTO categorytopic_topic(category_id, topic_id) VALUES (?1, ?2)")
public void addTopic(long categoryId, long topicId);
It's very fast because does not need load the collection.