Hello.
I have 3 tables in DB. 2 for entities and one for the relations between them. I have 2 java classes:
WHen I try to call a controller method:Code:private static final long serialVersionUID = 1L; @Id @SequenceGenerator(name = "treatment_code_id_seq", sequenceName = "treatment_code_id_seq", allocationSize = 1) private long id; @Column(name = "code") private String code; @Column(name = "description") private String description; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "category_code_relation", joinColumns = @JoinColumn(name = "code_id"), inverseJoinColumns = @JoinColumn(name = "category_id")) private List<CPTCodeCategory> categories; ...
I receive the hibernate exception:Code:treatmentCode.getCategories()
As I understand the problem with initialization the list. What may be wrong here?Code:ERROR: org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: org.mbs.billing.model.cpt.TreatmentCode.types, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.mbs.billing.model.cpt.TreatmentCode.types, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentBag.toString(PersistentBag.java:483) at java.lang.String.valueOf(String.java:2826) at java.io.PrintStream.println(PrintStream.java:771) at org.apache.tomcat.util.log.SystemLogHandler.println(SystemLogHandler.java:269) at org.mbs.billing.controller.roadmap.impl.PhaseCompositionHelperImpl.getCategoryList(PhaseCompositionHelperImpl.java:307) ...
Thank you in advance.


Reply With Quote