Hi,
I'm updating my code (a web application) to use Hibernate 3. At some point when my app starts up, I get this stack trace:
Code:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection (org.gridlab.gridsphere.services.core.portal.PortalConfigSettings.attributes) - no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:179)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:47)
at org.hibernate.collection.PersistentMap.get(PersistentMap.java:122)
at org.gridlab.gridsphere.services.core.portal.PortalConfigSettings.getAttribute(PortalConfigSettings.java:77)
The class PortalConfigSettings looks like the following and the code fails in the getAttributes method shown:
Code:
public class PortalConfigSettings {
private String oid = null;
private boolean canCreateAccount = false;
private Set defaultGroups = null;
private String defaultTheme = null;
private Map attributes = new HashMap();
...
// setter and getters
// code fails in here!!
public String getAttribute(String name) {
return (String) attributes.get(name);
}
}
My mapping file looks like:
Code:
<hibernate-mapping>
<class name="org.gridlab.gridsphere.services.core.portal.PortalConfigSettings
"
table="portalconfigsettings">
<id
name="oid"
column="gsoid"
type="java.lang.String"
length="32"
>
<generator class="uuid.hex"/>
</id>
<property name="CanUserCreateAccount" type="boolean" column="canusercreateacct"/>
<property name="DefaultTheme" type="string" column="defaulttheme"/>
<set name="DefaultGroups" cascade="all">
<key column="defaultgroup_oid"/>
<one-to-many class="org.gridlab.gridsphere.portlet.impl.SportletGr
oup"/>
</set>
<map name="attributes" table="portalconfigattributes">
<key column="gsoid"/>
<index column="attribute" type="string"/>
<element column="value" type="string"/>
</map>
</class>
</hibernate-mapping>
Any idea why this worked in 2.1, or what I need to do to make it work in Hibernate 3?
Thanks very much, Jason