I have a JPA project which searches tweets by keword and should persist the key - tweet pairs in the database. The project has the following entities :
Now I have a class for persisting a Keyword,
As you can see in the Keyword Entity, it has a joinTable and therefore a field that can have a set of tweets.
So whenever I get a key and a set of tweets, first I make a user entity, a set of hashtags and urls out of that tweet. Then I have a new tweet entity object.
In the next step I add this tweet(these tweets) to the keyword entity object.
Now I persist this keyword.
Problem: When I want to search for a keyword for the next time, the keyword exists and I should merge, but I get the following error :