在我的 Seam/Glassfish/JPA 容器中执行以下操作后:
@ApplicationScoped
public class JpaGlossaryDataAccessObject implements IGlossaryDataAccessObject {
// ...
@Transactional
public void deleteColumn(String glossaryName, String columnName) {
final GlossaryColumn column = getColumn(glossaryName, columnName);
entityManager.remove(column);
}
// ...
}
请求的列已成功从数据库中删除,我可以使用 SQL 工作台进行验证。但是,当随后调用以下方法时:
@ApplicationScoped
public class JpaGlossaryDataAccessObject implements IGlossaryDataAccessObject {
// ...
@Transactional
public List<Glossary> getGlossaries(Collection<String> glossaryNames) {
glossaryNames.retainAll(getGlossaryNames());
return entityManager.createQuery(SELECT_ALL_NAMED_GLOSSARIES, Glossary.class).setParameter(GLOSSARY_NAMES_PARAMETER_INDEX, glossaryNames).getResultList();
}
// ...
}
它基本上返回包含上述列的词汇表,删除的列仍在词汇表对象中!即使它们不再存在于数据库中。怎么会这样?为了使这项工作,我需要执行一些额外的刷新吗?
顺便说一句,我的 beans.xml 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="urn:java:ee"
xmlns:security="urn:java:org.jboss.seam.security" xmlns:permission="urn:java:org.jboss.seam.security.permission"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
<alternatives />
<decorators />
<interceptors>
<class>org.jboss.seam.security.SecurityInterceptor</class>
<class>org.jboss.seam.transaction.TransactionInterceptor</class>
</interceptors>
<security:IdentityImpl>
<s:modifies />
<security:authenticatorClass>ch.diction.webportal.security.seam.authentication.ChallengeResponseIdmAuthenticatorDecorator
</security:authenticatorClass>
</security:IdentityImpl>
</beans>
那么,我错过了什么?
在此先感谢和最好的问候帕斯卡