-->
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.  [ 1 post ] 
Author Message
 Post subject: Strange introspection paradox
PostPosted: Tue Apr 26, 2005 7:29 am 
Beginner
Beginner

Joined: Tue Aug 10, 2004 8:59 am
Posts: 47
In parts of my code I access the primary keys of my persistent bean entities through introspection. All my entities have a method called getId() containing the primary key, but I have come across a situation in which I cannot retrieve the ID using introspection even though regular method invocation of my getId method retrieves it. I am guessing that Hibernate's use of CGLib is the cause of this paradox, but I am not sure.

The code below invokes a getId method through introspection and gets a null. It then invokes the getId() method directly and gets a non null value. All my entities use the "native" ID generator, and the error only occurs on entities which use joined-subclass inheritance (specified in the HBM files).

If anyone can give me a hint to what could be going on here I would be grateful.

Randahl



object = (P) readMethod.invoke(entity);
if(getPropertyName().equals("id"))
logger.info(
"Reading ID from entity " + entity + " with id " +
entity.getId() + " and class " +
entity.getClass().getName() + " and super class " +
entity.getClass().getSuperclass().getName() +
" using read method " + readMethod.getName() +
" and result " +
"was " + object
);

And the output:

12:52:47,656 INFO [PrimitiveMapping] Reading ID from entity dk.rockit.[...].jpg.JpgGraphic@1d61d83 with id 10297 and class
dk.rockit.[...].jpg.JpgGraphic$$EnhancerByCGLIB$$8668af98 and super class dk.rockit.[...].jpg.JpgGraphic using read method getId and result was null


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

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.