我想从具有特定sql语句的列表中删除对象 示例:包含消息列表的档案。
我希望在删除邮件后,列表会自动刷新。情况确实如此,但是当我使用远程Java应用程序启动应用程序时,我必须使用实体管理器手动刷新档案。我想知道为什么在我想调试代码时会有这样的差异。
我使用weblogic作为应用服务器。
感谢。
BenefitDossier dossier = dossierRepo.getDossierByDossierId(dossierIdentifier, CREATED);
// perform the removing
messageRepository.removeOrUpdateMessagesFromDossier(dossier.getDossierId(), COMPLETENESS_RECOGNITION);
dossierRepo.refresh(dossier); // need to add this statement only in debug mode
return dossier;
@PersistenceContext(unitName = "dmb-jta")
protected EntityManager em;
public void removeOrUpdateMessagesFromDossier(DisBenMessageCategory category, String dossierNr) {
if (category.preserveHistory()) {
updateMessagesRemovalTimestamp(category, dossierNr);
} else {
removeMessages(category, dossierNr);
}
}
private void removeMessages(DisBenMessageCategory category, String dossierNr) {
StringBuilder updateStmt = new StringBuilder();
updateStmt.append("DELETE FROM DisBenMessage msg ");
updateStmt.append("WHERE msg.benefitDossier.dossierId = :dossierNr ");
updateStmt.append("AND msg.category = :category ");
Query query = em.createQuery(updateStmt.toString());
query.setParameter("dossierNr", dossierNr);
query.setParameter("category", category);
int updateCount = query.executeUpdate();
LOG.debug("Deleted " + updateCount + " messages.");
}
<persistence-unit name="dmb-jta" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/DisabilityBenefitsDS</jta-data-source>
<properties>
<property name="eclipselink.logging.level" value="INFO"/>
<property name="eclipselink.logging.exceptions" value="true"/>
<property name="eclipselink.logging.logger" value="be.cm.comps.logman.impl.LogManagerSessionLog"/>
<property name="eclipselink.target-server" value="Weblogic_10"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.cache.shared.default" value="false" />
<!-- Global eclipselink Cache -->
<property name="eclipselink.cache.type.default" value="NONE" />
<!-- Specific Entities eclipselink Cache -->
<property name="eclipselink.cache.type.ContactInfoType" value="Full" />
<property name="eclipselink.cache.type.ContactPointServiceType" value="Full" />
<property name="eclipselink.cache.type.Day" value="Full" />
<property name="eclipselink.cache.type.Federation" value="Full" />
<property name="eclipselink.cache.type.Language" value="Full" />
</properties>
</persistence-unit>