-->
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: Hibernate does not require getters and setters?
PostPosted: Sat Apr 02, 2005 5:54 pm 
Newbie

Joined: Sun Oct 03, 2004 11:51 am
Posts: 2
Location: Stuttgart Germany
Hibernate version:
3.0

Hi,

I'm quite new to hibernate and I thought that I need to use a „getter“ to read the attribute from the database. At lest I had this behavior as I saved (the important part from) a swing JPanel as a UserType. If I now retrieving the JPanel Object the attributes aren't loaded until I call the “getter”. I would like to retrieve the Object and just show it.

However, now I read the “Versant Spam” article with the line “Hibernate does not require getters and setters, as is clearly described in many places on the Hibernate website.”
I can't find it. Maybe anybody can give me the URL.

Thank you!

Richard


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 02, 2005 5:56 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Check the reference documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 3:42 pm 
Newbie

Joined: Sun Oct 03, 2004 11:51 am
Posts: 2
Location: Stuttgart Germany
Hi Christian,

Do you mind to be a little bit more specific? I can't find it. There are just a few words about setter in “1.2. First persistent class”. But the statement “(Hibernate can also access fields directly, if needed)” don't fit to the example where every fiend has a setter/getter.

The next time where setter appears is in “8.1. Dependent objects” which isn't what I'm interested in.

So, can you give me a hint? Thanks!

Richard


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 5:34 pm 
Beginner
Beginner

Joined: Tue Jun 29, 2004 3:44 pm
Posts: 43
Hibernate is very happy to use getters and setters for accessing data. If your persistent object has them for the fields you need, you don't need to worry about this at all.

If you need to persist a field that does not have a getter/setter, you can use the access="field" property attribute to access the field (through reflection, I think).

If your object is being saved correctly, but the fields aren't being initialized when retrieved, you want to look into 'lazy loading' and ways of turning it off.


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.