课程:播放列表有很多歌曲
@OneToMany
private List<Track> tracks = new ArrayList<Track>();
歌曲已存在于数据库中。 我正在尝试创建一个播放列表,其中包含一个没有休眠的曲目列表,试图创建重复的曲目
Playlist playlist = new Playlist(playlistName);
PersistenceUtil.persist(playlist);
playlist.addTracks(tracks);
PersistenceUtil.merge(playlist);
错误讯息:
Caused by: java.sql.BatchUpdateException: Duplicate entry '4' for key 'tracks_id'
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1269)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:955)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:56)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1168)
... 14 more