@@ -77,19 +77,8 @@ public List<String> getAllCustomUrls(Item item) {
7777 @ Override
7878 public void replaceCustomUrl (Context context , Item item , String newUrl ) {
7979 try {
80- // Ensure the item is fully managed by the current Hibernate session.
81- // The item received from event consumers may reference a detached entity
82- // (e.g., after a context.uncacheEntity/reloadEntity cycle in the caller),
83- // which would cause a "detached entity passed to persist" error
84- // when creating new MetadataValue objects. Evicting and re-fetching
85- // guarantees a clean, fully-managed entity.
86- context .uncacheEntity (item );
87- Item managedItem = itemService .find (context , item .getID ());
88- if (managedItem == null ) {
89- return ;
90- }
91- itemService .clearMetadata (context , managedItem , "dspace" , "customurl" , null , ANY );
92- itemService .addMetadata (context , managedItem , "dspace" , "customurl" , null , null , newUrl );
80+ itemService .clearMetadata (context , item , "dspace" , "customurl" , null , ANY );
81+ itemService .addMetadata (context , item , "dspace" , "customurl" , null , null , newUrl );
9382 } catch (SQLException e ) {
9483 throw new SQLRuntimeException (e );
9584 }
0 commit comments