-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: could not initialize proxy - the owning Session was closed
PostPosted: Wed Jul 27, 2005 9:39 am 
Newbie

Joined: Wed Jul 27, 2005 9:27 am
Posts: 3
Hello. First, Excuse me, but my English is very bad.

I have a problem with hibernate. I have two tables with a relationship many-to-one. But when i try to get the object access at the class who makes the comp_id, it show me the next error.

ERROR: error.application.unhandled.exception
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Throwable.<init>(Throwable.java)
at org.hibernate.exception.NestableRuntimeException.<init>(NestableRuntimeException.java:100)
at org.hibernate.LazyInitializationException.<init>(LazyInitializationException.java:18)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java)
at es.gedasgrp.tpi.business.model.TawAnuncio$$EnhancerByCGLIB$$e262ba6a.Fields(<generated>)
at es.gedasgrp.tpi.business.businesscomponents.Auditoria.AbAuditable.getPKDifferences(AbAuditable.java)
at es.gedasgrp.tpi.business.businesscomponents.Auditoria.AbAuditable.getDifferences(AbAuditable.java)
at es.gedasgrp.tpi.business.businesscomponents.Auditoria.Auditoria.logAudit(Auditoria.java)
at es.gedasgrp.tpi.business.businesscomponents.ColourBusinessComponent.setColour(ColourBusinessComponent.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodA

I read that the problem is the tag lazy of the hbm.cfg but i put true and false but it don´t work.

Can anybody help me?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 12:02 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
You need to provide more information on what you are doing.
The error means exactly what it says. You try to access an object after the Hibernate session has been closed.

Anyway, I think you should read the documentation again, if you've already read it.

Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 4:33 pm 
Newbie

Joined: Wed Jul 27, 2005 9:27 am
Posts: 3
Ok.

i need to make a comparator of the data of a table. Then i need to get all fields that compose the table.
But i don´t know what class of java file i have. then i make an abstract class of wich inherits the classes that make hibernate. These classes have a method that they inherits from the abstract class is like this:

public abstracclass getObject(Field f) {
return (abstracclass) f.get(this);
}

the java files that generates hibernate are:

class table1 class table1pk class table2
{ { {
private table1pk comp_id; private table2; String c3
private String c1; get..
private String c2; set..
get.. } }
set..
}


I´ve no problem when i try to acces to fields c1,c2 and comp_id, but when i try to get the field table2 of table1pk it give me an object that don´t belong to class table2, it is an object of type
table2$$encheritCGLIB$$ (or something like this) that have the information i need,but i can´t get it. And when i want to make something with this object, i obtain the previous error.

I hope to have explained better the problem, and again pardon by my English

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 3:49 am 
Newbie

Joined: Wed Jul 27, 2005 9:27 am
Posts: 3
pardon but the code is not seen well in the previous post




Code:

public class table1
{
private table1pk comp_id;
private String c1;

get...
set..
}

public class table1pk
{
private table2 t2;
get...
set..
}

public class table2
{
String c2
get...
set..
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.