Верблюд jpa бесконечно глубокий XML

Я использую компонент camel-jpa, чтобы получить некоторые данные из базы данных postgres, а затем упаковать их в xmal и поместить в очередь jms.

Мой маршрут выглядит следующим образом:

DataFormat jaxb = new JaxbDataFormat("some.package.patstatextractor.entities");
from("jpa://some.package.patstatextractor.entities.Tls201Appln?"
                    + "consumer.resultClass=some.package.patstatextractor.entities.Tls201Appln" + "&consumeDelete=false"
                    + "&consumer.nativeQuery=" + constructQuery(year)).routeId("" + year)
            .marshal(jaxb)
            .to("activemq:patstat:test");

У моей сущности Tls201Appln есть дочерняя коллекция, и ребенок ссылается на родителя следующим образом

Tls201Appln:
 @OneToMany(mappedBy = "applnId",fetch=FetchType.EAGER)
    private Set<Tls211PatPubln> tls211PatPublnCollection;

Tls211PatPubln:
 @XmlTransient
    @JoinColumn(name = "appln_id", referencedColumnName = "appln_id")
    @ManyToOne
    private Tls201Appln applnId;

Есть несколько детей от родителя, приведенный выше пример. Я пометил ссылки на parent от потомка как @XmlTransient, чтобы избежать вложенных циклов.

Однако я получаю следующую ошибку при сортировке...

    java.io.IOException: javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: eu.jrc.tim.patstat.application.Tls201Appln[ applnId=424600225 ] -> eu.jrc.tim.patstat.application.Tls203ApplnAbstr[ applnId=424600225 ] -> eu.jrc.tim.patstat.application.Tls201Appln[ applnId=424600225 ]]
    at org.apache.camel.converter.jaxb.JaxbDataFormat.marshal(JaxbDataFormat.java:178) ~[camel-jaxb-2.20.0.jar:2.20.0]
    at org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:69) ~[camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) [camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) [camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97) [camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.component.jpa.JpaConsumer.processBatch(JpaConsumer.java:200) [camel-jpa-2.20.0.jar:2.20.0]
    at org.apache.camel.component.jpa.JpaConsumer$1.doInTransaction(JpaConsumer.java:132) [camel-jpa-2.20.0.jar:2.20.0]
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) [spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.apache.camel.component.jpa.JpaConsumer.poll(JpaConsumer.java:106) [camel-jpa-2.20.0.jar:2.20.0]
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174) [camel-core-2.20.0.jar:2.20.0]
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101) [camel-core-2.20.0.jar:2.20.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_144]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_144]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_144]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: javax.xml.bind.MarshalException: null
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95) ~[na:1.8.0_144]
    at org.apache.camel.converter.jaxb.JaxbDataFormat.marshal(JaxbDataFormat.java:216) ~[camel-jaxb-2.20.0.jar:2.20.0]
    at org.apache.camel.converter.jaxb.JaxbDataFormat.marshal(JaxbDataFormat.java:168) ~[camel-jaxb-2.20.0.jar:2.20.0]
    ... 20 common frames omitted
Caused by: com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: eu.jrc.tim.patstat.application.Tls201Appln[ applnId=424600225 ] -> eu.jrc.tim.patstat.application.Tls203ApplnAbstr[ applnId=424600225 ] -> eu.jrc.tim.patstat.application.Tls201Appln[ applnId=424600225 ]
    at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:249) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.XMLSerializer.pushObject(XMLSerializer.java:537) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:631) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:158) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:360) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:158) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:360) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:341) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494) ~[jaxb-impl-2.2.11.jar:2.2.11]
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323) ~[jaxb-impl-2.2.11.jar:2.2.11]
    ... 24 common frames omitted

Кто-нибудь сталкивался с этим раньше. Кажется, идет от потребителя верблюда jpa.

0 ответов

Другие вопросы по тегам