Я пытаюсь экспортировать следующие объекты с помощью JSONB:
Класс Prozessschritt:
import lombok.*;
import javax.persistence.*;
import java.util.List;
/** Data class for process chain steps */
@Data
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@RequiredArgsConstructor
public class ProzessSchritt {
/** On delete set to invalid */
@NonNull
private boolean isValidData = true;
/** The process step id */
@NonNull
@Id
private int psID;
/** Whether or not the process step has been uploaded */
private boolean uploaded;
/** The transport job to be carried out */
@OneToOne
private TransportAuftrag transportAuftrag;
/** The process step's log */
@NonNull
@OneToMany(fetch = FetchType.LAZY)
private List<ProzessSchrittLog> prozessSchrittLog;
/** The process step template the process step was created from */
@NonNull
@ManyToOne(fetch = FetchType.LAZY)
private ProzessSchrittVorlage prozessSchrittVorlage;
/** Die Zugewiesenen Proben fuer diesen Schritt */
@OneToMany(fetch = FetchType.LAZY)
private List<Probe> zugewieseneProben;
/** The process step state automaton template the automaton was created from (containing all possible states) */
@NonNull
@OneToOne(fetch = FetchType.LAZY)
private ProzessSchrittZustandsAutomat prozessSchrittZustandsAutomat;
}
Мой метод экспорта, список, содержащий все объекты, вызывается инициализация компонента:
/**
* List of all process steps
*/
private List<ProzessSchritt> psListe;
@PostConstruct
public void init() {
psListe = getAll();
}
/**
* JSON export
*/
public String toJson() {
JsonbConfig config = new JsonbConfig()
.withFormatting(true);
// Create Jsonb with custom configuration
Jsonb jsonb = JsonbBuilder.create(config);
String result = jsonb.toJson(psListe);
log.info("Export von den Auftraegen\n" + result);
return result;
}
И я получаю следующую ошибку:
Причина: org.hibernate.SessionException: Сессия закрыта. Параметр «только для чтения / изменяемый» доступен только в том случае, если прокси-сервер [de.unibremen.sfb.model.Standort # -486533119] связан с открытым сеансом. в орг. hibernate@5.3.13.Final//org.hibernate.proxy.AbstractLazyInitializer.errorIfReadOnlySettingNotAvailable (AbstractLazyInitializer. java: 348) в орг. hibernate@5.3.13.Final//org.hibernate.proxy.AbstractLazyInitializer.setReadOnly (AbstractLazyInitializer. java: 362) в орг. hibernate@5.3.13.Final//org.hibernate.proxy.AbstractLazyInitializer.setSession (AbstractLazyInitializer. java: 136) в орг. hibernate@5.3.13.Final//org.hibernate.proxy.AbstractLazyInitializer. (AbstractLazyInitializer. java: 77) в орг. hibernate@5.3.13.Final//org.hibernate.proxy.pojo.BasicLazyInitializer. (BasicLazyInitializer. java: 43) в орг. hibernate@5.3.13.Final//org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor. (ByteBuddyInterceptor. java: 37) в орг. hibernate@5.3.13.Final//org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyFactory.getProxy (ByteBuddyProxyFactory. java: 77) в орг. hibernate@5.3.13.Final//org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy (AbstractEntityTuplizer. java: 713) в орг. hibernate@5.3.13.Final//org.hibernate.persister.entity.AbstractEntityPersister.createProxy (AbstractEntityPersister. java: 4872) в орг. hibernate@5.3.13.Final//org.hibernate.event.internal.DefaultLoadEventListener.createProxy (DefaultLoadEventListener. java: 445) в орг. hibernate@5.3.13.Final//org.hibernate.event.internal.DefaultLoadEventListener.createProxyIfNecessary (DefaultLoadEventListener. java: 436) в орг. hibernate@5.3.13.Final//org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad (DefaultLoadEventListener. java: 344) в орг. hibernate@5.3.13.Final//org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad (DefaultLoadEventListener. java: 127) в орг. hibernate@5.3.13.Final//org.hibernate.event.internal.DefaultLoadEventListener.onLoad (DefaultLoadEventListener. java: 93) в орг. hibernate@5.3.13.Final//org.hibernate.internal.SessionImpl.fireLoadNoChecks (SessionImpl. java: 1288) в орг. hibernate@5.3.13.Final//org.hibernate.internal.SessionImpl.internalLoad (SessionImpl. java: 1160) в орг. hibernate@5.3.13.Final//org.hibernate.type.EntityType.resolveIdentifier (EntityType. java: 682) в орг. hibernate@5.3.13.Final//org.hibernate.type.EntityType.resolve (EntityType. java: 464) в орг. hibernate@5.3.13.Final//org.hibernate.type.ManyToOneType.resolve (ManyToOneType. java: 239) в орг. hibernate@5.3.13.Final//org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity (TwoPhaseLoad. java: 205) в орг. hibernate@5.3.13.Final//org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity (TwoPhaseLoad. java: 160) в орг. hibernate@5.3.13.Final//org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad (AbstractRowReader. java : 252) в орг. hibernate@5.3.13.Final//org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp (AbstractRowReader. java: 215) в орг. hibernate@5.3.13.Final//org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults (ResultSetProcessorImpl. java: 133) в орг. hibernate@5.3.13.Final//org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad (AbstractLoadPlanBasedLoader. java: 107) в орг. . hibernate@5.3.13.Final//org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize (AbstractLoadPlanBasedCollectionInitializer. java: 87) в орг. hibernate@5.3.13.Final//org.hibernate.persister.collection.AbstractCollectionPersister.initialize (AbstractCollectionPersister. java: 692) в орг. hibernate@5.3.13.Final//org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection (DefaultInitializeCollectionEventListener. java: 75) в орг. hibernate@5.3.13.Final//org.hibernate.internal.SessionImpl.initializeCollection ( SessionImpl. java: 2277) в орг. hibernate@5.3.13.Final//org.hibernate.collection.internal.AbstractPersistentCollection $ 4.doWork (AbstractPersistentCollection. java: 585) в орг. hibernate@5.3.13.Final//org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded (AbstractPersistentCollection. java: 263) в орг. hibernate@5.3.13.Final//org.hibernate.collection.internal.AbstractPersistentCollection.initialize (AbstractPersistentCollection. java: 581) в орг. hibernate@5.3.13.Final//org.hibernate.collection.internal.AbstractPersistentCollection.read (AbstractPersistentCollection. java: 148) в орг. hibernate@5.3.13.Final//org.hibernate.collection.internal.PersistentBag.iterator (PersistentBag. java: 366) в org.eclipse.yasson // org.eclipse.yasson. internal.serializer.CollectionSerializer.serializeInternal (CollectionSerializer. java: 38) в org.eclipse.yasson // org.eclipse.yasson.internal.serializer.CollectionSerializer.serializeInternal (CollectionSerializer. java: 27) в org.eclip .yasson // org.eclipse.yasson.internal.serializer.AbstractContainerSerial izer.serialize (AbstractContainerSerializer. java: 64) в org.eclipse.yasson // org.eclipse.yasson.internal.serializer.AbstractContainerSerializer.serializerCaptor (AbstractContainerSerializer. java: 96) в org.eclipse.y org.eclipse.yasson.internal.serializer.ObjectSerializer.marshallProperty (ObjectSerializer. java: 110) в org.eclipse.yasson // org.eclipse.yasson.internal.serializer.ObjectSerializer.serializeInternal (ObjectSerializer. 65) ... еще 138