You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
1010 B

package com.mydreamjob.messaging;
import org.springframework.data.jpa.repository.*;
import org.springframework.data.repository.query.Param;
public interface ChatAttachmentRepository extends JpaRepository<ChatAttachment,Long> {
@Modifying
@Query("delete from ChatAttachment a where a.messageId = :id")
void purge(@Param("id") Long messageId);
@Modifying
@Query("delete from ChatAttachment a where a.messageId in (select m.id from Message m where m.senderUserId = :id)")
void purgeForSender(@Param("id") Long userId);
@Modifying(clearAutomatically=true,flushAutomatically=true)
@Query("update Message m set m.attachmentFilename=null, m.attachmentContentType=null, "
+ "m.attachmentSize=null, m.attachmentSha256=null, m.attachmentWidth=null, m.attachmentHeight=null, "
+ "m.version=m.version+1 where m.senderUserId=:id and m.messageType in ('IMAGE','FILE') and m.attachmentSize is not null")
void clearMetadataForSender(@Param("id") Long userId);
}