-->
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: How do Hibernate set identifier where its setter is private?
PostPosted: Tue Nov 02, 2004 8:52 am 
Newbie

Joined: Fri Oct 08, 2004 10:11 pm
Posts: 6
I am just curious.

I make my id setter into private, which is not accessible from other classes.

But still hibernate is able to set the id into new value after the object get persisted.

Any body knows how to do this? i guess it's reflection. but i really have no idea. Any one with any idea?

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 9:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
reflection


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 12:44 pm 
Newbie

Joined: Fri Oct 08, 2004 10:11 pm
Posts: 6
how do that happen actually?
could someone post some code for illustration?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 3:37 pm 
Regular
Regular

Joined: Thu Dec 11, 2003 4:14 pm
Posts: 86
Location: Hibernate 3 + annotations, Oracle 9i, PostgreSQL 8.0, Java 1.5.0
Not sure if hibernate uses this technique, but using reflection you can "break" into the object.

Field m = any_class.getField(xxx);
m.setAccessible(true);

If you do not have a SecurityManager installed which avoids this operation you can access such a field even if it is private.


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.