-->
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.  [ 7 posts ] 
Author Message
 Post subject: Superclass property not visible when doing session.load()
PostPosted: Fri Mar 25, 2005 11:00 am 
Beginner
Beginner

Joined: Mon Feb 23, 2004 5:11 pm
Posts: 39
I am trying to upgrade from H2 to H3. I followed the migration guide. I am using the Classic Session (for now).

Consider the following (simplified) classes:

Code:
public class BaseEntity implements Serializable {
    private Long id;

    public final Long getId() {
        return id;
    }

    public final void setId(Long id) {
        this.id = id;
    }
}

public class Customer extends BaseEntity {
    private String name;

    public String getName() {
        return name;
    }
    public void setName(String n) {
        name = n;
    }
}



I inserted a Customer record into the database and I have the id. Now, in a new session, I do

session.load(Customer.class, (Long)tempid);


This actually loads the customer object and I could even print the name property. But when I do cust.getId() I get null. Very weired. I added the following method in the Customer class that simply invoked super.getId();

Code:
public Long getSuperId() {
       return super.getId()
}


Now, if I do cust.getSuperId(), i see the actual id. In short, I load the Customer object from the database, then
cust.getId() returns null, while
cust.getSuperId() returns the id.

I am completely lost. This issue is not just with the id property, it affects all the properties in the super class. This used to work just fine in H2. Any pointers?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 25, 2005 12:16 pm 
Beginner
Beginner

Joined: Mon Feb 23, 2004 5:11 pm
Posts: 39
I thought may be this was happening due to the zillion jars I have in my application's class path. So I started with an empty class path and added the jars as required to run my simple test. Here is my class path.Please note the 3 jars in bold did not come shipped with H3. I had to add them myslef.

j2sdk1.4.2_03 libraries
my source folders
hibernate mapping file folders
hibernate2.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
dom4j-1.5.2.jar
junit-3.8.1.jar
log4j-1.2.9.jar
common-beanutils.jar
classes12.jar (oracle driver)

cglib-full-2.0.2.jar
ehcache.jar
jta.jar
commons-lang-2.0.jar

I still see the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 25, 2005 12:19 pm 
Beginner
Beginner

Joined: Mon Feb 23, 2004 5:11 pm
Posts: 39
Minor typo in my previous posting its hibernate3.jar not hibernate2.har


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 25, 2005 12:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Your class was not lazy="true" and it is now since this is the new default.
This is not an answer though.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 25, 2005 12:25 pm 
Beginner
Beginner

Joined: Mon Feb 23, 2004 5:11 pm
Posts: 39
I removed the final keyword from the method signature and it worked!!!!!!. Obviously, something is not right (may be in the CGLIB). For now I am going to remove the final key word in all super class methods. But it will be nice if this could be fixed.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 26, 2005 5:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is explained in the doc. A lazy class need not to be final nor have final properties. This is due to the very nature of proxying

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 6:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
maybe we should error/throw on this situation ?

_________________
Max
Don't forget to rate


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