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.  [ 5 posts ] 
Author Message
 Post subject: Narrowing proxy to class... this operation breaks ==
PostPosted: Tue Nov 29, 2005 7:20 am 
Newbie

Joined: Fri Sep 16, 2005 8:05 am
Posts: 7
Hi,

I'm having a problem with warnings of the type
Code:
Narrowing proxy to class org.psygrid.data.model.hibernate.DataSet - this operation breaks ==

appearing in the logs.

First off, I can categorically say that there is no explicit casting in the code! Just thought I['d get that out of the way to start with ;-)

The situation is this. I am using Hibernate as the back-end for a web-service, and as such need to work in a disconnected way. So, for a web-service method to retrieve an object from the database, the relevant object is obtained using Hibernate, then all of its properties are copied (still in the session) to an equivalent DTO bean that can be returned by the web-service method.

OK, so the problem occurs when I am trying to retrieve a single Record object from the database. Within a Hibernate session I retrieve the Record object then calls its toDTO method which constructs the equivalent DTO bean that will be returned by the web-service method. The Record class extends the ElementInstance class (see abridged code snippet below) so calls super.toDTO. Now, each ElementInstance has a reference to an Element object. DataSet extends Element, and in the case of a Record the reference is actually to a DataSet.

Code:
public class Element{
    private List<Element> children = new ArrayList<Element>();

    public void toDTO(org.psygrid.data.model.dto.Element dtoE, Map<Persistent, org.psygrid.data.model.dto.Persistent> dtoRefs, RetrieveDepth depth){

    }
}

public class DataSet extends Element {
    public org.psygrid.data.model.dto.DataSet toDTO(Map<Persistent, org.psygrid.data.model.dto.Persistent> dtoRefs, RetrieveDepth depth){
        super.toDTO(dtoDS, dtoRefs, depth);
    }
}

public class ElementInstance {
    private Element element;
    private List<ElementInstance> children = new ArrayList<ElementInstance>();
    public void toDTO(org.psygrid.data.model.dto.ElementInstance dtoEI, Map<Persistent, org.psygrid.data.model.dto.Persistent> dtoRefs, RetrieveDepth depth){
        super.toDTO(dtoEI, dtoRefs, depth);
        if ( null != this.element ){
            dtoEI.setElement(this.element.toDTO(dtoRefs, depth));
        }
    }
}

public class Record extends ElementInstance {

    public void toDTO(org.psygrid.data.model.dto.Record dtoR, Map<Persistent, org.psygrid.data.model.dto.Persistent> dtoRefs, RetrieveDepth depth){
        super.toDTO(dtoR, dtoRefs, depth);
    }
}


The warning seems to be caused by the line

Code:
dtoEI.setElement(this.element.toDTO(dtoRefs, depth));


in the ElementInstance class, in the case where the ElementInstance is actually a Record, so the Element is actually a DataSet.

Anybody got any ideas?

cheers, Rob

Hibernate version:
3.1beta3

Mapping documents (partial):

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class table="t_persistents" name="org.psygrid.data.model.hibernate.Persistent">
    <id name="id" column="c_id">
      <generator class="native"/>
    </id>
    <version unsaved-value="undefined" name="version" column="c_version"/>
    <joined-subclass name="org.psygrid.data.model.hibernate.Element" table="t_elements">
      <key column="c_id"/>
      <property name="name" column="c_name"/>
      <list cascade="all-delete-orphan" name="children">
        <key not-null="false" column="c_parent_id"/>
        <list-index column="c_index"/>
        <one-to-many class="org.psygrid.data.model.hibernate.Element"/>
      </list>
      <joined-subclass name="org.psygrid.data.model.hibernate.DataSet" table="t_datasets">
        <key column="c_id"/>
        <property name="versionNo" column="c_version"/>
        <property name="published" column="c_published" not-null="true"/>
      </joined-subclass>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.ElementInstance" table="t_elem_insts">
      <key column="c_id"/>
      <set cascade="all" name="children">
        <key not-null="false" column="c_parent_id"/>
        <one-to-many class="org.psygrid.data.model.hibernate.ElementInstance"/>
      </set>
      <many-to-one column="c_element_id" cascade="none" class="org.psygrid.data.model.hibernate.Element" not-null="true" name="element"/>
      <many-to-one column="c_record_id" class="org.psygrid.data.model.hibernate.Record" not-null="false" name="record"/>
      <joined-subclass name="org.psygrid.data.model.hibernate.Record" table="t_records">
        <key column="c_id"/>
        <many-to-one unique="true" column="c_identifier_id" cascade="none" class="org.psygrid.data.model.hibernate.Identifier" not-null="true" name="identifier"/>
      </joined-subclass>
    </joined-subclass>
  </class>
</hibernate-mapping>


Name and version of the database you are using:
MySQL 4.1.15

Debug level Hibernate log excerpt:

Code:
10:20:49,609 DEBUG TwoPhaseLoad:104 - resolving associations for [org.psygrid.data.model.hibernate.DataSet#903]
10:20:49,610 DEBUG CollectionLoadContext:141 - creating collection wrapper:[org.psygrid.data.model.hibernate.Element.children#903]
10:20:49,610 DEBUG DefaultLoadEventListener:153 - loading entity: [org.psygrid.data.model.hibernate.DataSet#903]
10:20:49,611 DEBUG DefaultLoadEventListener:196 - entity proxy found in session cache
10:20:49,613  WARN StatefulPersistenceContext:614 - Narrowing proxy to class org.psygrid.data.model.hibernate.DataSet - this operation breaks ==


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 6:12 am 
Newbie

Joined: Fri Sep 16, 2005 8:05 am
Posts: 7
Can anybody help me out with this? Please?

(Yes, yes, a blatant bump post, I know ;-)

cheers, Rob


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 6:55 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
If your posting (or a question you are refering to) was not answered by anybody, the possible reasons are:

- http://www.hibernate.org/ForumMailingli ... AskForHelp
- You did not submit enough information
- Nobody knows the answer or has the free time to answer

What you can do now:

- Do the things listed in After Posting
- Add missing and/or more information
- Consider commercial support for guaranteed expert response times

This is a high-traffic forum run by volunteers with hundreds of postings made every day. The community works because people try to help others in their free time. Nobody is paid for this service or has to pay.

You should not expect a timely response and you should not rely on a public community forum for critical cases.

All community members should respect the rules of this forum and treat others like they would prefer to be treated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2009 2:22 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
Have a look at:
http://forum.hibernate.org/viewtopic.php?p=2404391


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2009 2:23 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
Have a look at:
http://forum.hibernate.org/viewtopic.php?p=2404391


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.