そのため、MongoDB で Hibernate OGM (4.1.0.Beta4) を使用しようとしていますが、この問題に遭遇して混乱しているため、作成したエンティティのリストを取得し、そのリストを循環しようとしています。それぞれを削除します。
コンテキスト パス:/TestApp サーブレット パス:/rest パス情報:/deleteallplease クエリ文字列:null スタック トレース org.jboss.resteasy.spi.UnhandledException: javax.ejb.EJBException: java.lang.IllegalArgumentException: デタッチされたインスタンスを削除しています.jpa.model.TestEntity#402881e546fa0f740146fa10cf210000 org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) org.jboss.resteasy. core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) org. jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.サービス (ServletContainerDispatcher.java:220) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java: 51) javax.servlet.http.HttpServlet.service(HttpServlet.java:790) io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest( ServletSecurityRoleHandler.java:61) io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) io.undertow.server. handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52) io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java: 45) io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) io.undertow.security.handlers. SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) io.undertow. servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) ) io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) io.undertow.server.Connectors.executeRootHandler(Connectors.java:168) io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java :687) java.util.concurrent.ThreadPoolExecutor.runWorker(不明なソース) java.util.concurrent.ThreadPoolExecutor$Worker.run(不明なソース) java.lang.Thread.run(不明なソース)
これは私の残りのサービスから呼び出されます
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class TestService {
@Inject
private TestRepository testRepo;
@GET
@Path("/deleteallplease")
public String deleteAllTests(){
for( TestEntity rp : testRepo.findAll() ){
testRepo.delete( rp );
}
return "done done done";
}
}
TestRepo クラス
@Stateless
@LocalBean
public class TestRepository {
@Inject
private EntityManager em;
@Inject
private Logger log;
public List<TestEntity> findAll() {
return em.createQuery("FROM TestEntity", TestEntity.class).getResultList();
}
persistence.xml
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary" >
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<class>com.test.TestEntity</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.ogm.datastore.provider" value="mongodb"/>
<property name="hibernate.ogm.datastore.database" value="db"/>
<property name="hibernate.ogm.datastore.host" value="127.0.0.1"/>
<property name="hibernate.ogm.datastore.port" value="59541"/>
<property name="hibernate.ogm.datastore.username" value="user"/>
<property name="hibernate.ogm.datastore.password" value="password"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
</properties>
</persistence-unit>
</persistence>
私が混乱している主な点は、エンティティのリストを取得し、それらを削除しようとしましたが、それらはすでに切り離されていますか? したがって、明らかに基本的なものも欠落しています.mongoはトランザクションではないため、mongo-ogmとJTAがうまく機能していないのではないかと疑っていますが、ogmがそれを抽象化してくれると思いました。