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: Public Members in the POJO?
PostPosted: Fri Jul 03, 2009 11:37 am 
Newbie

Joined: Thu Dec 20, 2007 1:49 pm
Posts: 9
I'm in the process of converting a JDBC database layer to Hibernate, and many of the POJOs have public members. I've come across a strange issue with this, however.

I have a POJO similar to the one below:

public class pojo
{
@Id
public int id;

@Column(name="member")
public String member;

public String getMember()
{
return member;
}
}

if i call pojo.member, I get a null, however, if I call pojo.getMember() then it succeeds... Is there a reason for this?


Top
 Profile  
 
 Post subject: Re: Public Members in the POJO?
PostPosted: Fri Jul 03, 2009 11:59 am 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
When you first retrieve an entity it may only be populated with the Id.

When you make a call to access a property Hibernate will go off to get the rest of the details.

If you output the type of the POJO you may find that it is actually a proxy.


--
Stephen Souness


Top
 Profile  
 
 Post subject: Re: Public Members in the POJO?
PostPosted: Fri Jul 03, 2009 12:03 pm 
Newbie

Joined: Thu Dec 20, 2007 1:49 pm
Posts: 9
Sounie wrote:
When you first retrieve an entity it may only be populated with the Id.

When you make a call to access a property Hibernate will go off to get the rest of the details.

If you output the type of the POJO you may find that it is actually a proxy.


--
Stephen Souness


I didn't actually realize that the entire object is lazy loaded. I figured it was just for collections.

Is there any way to specify the fetch type globally, or is it always lazy?


Top
 Profile  
 
 Post subject: Re: Public Members in the POJO?
PostPosted: Wed Jul 08, 2009 6:39 am 
Newbie

Joined: Fri May 29, 2009 2:21 am
Posts: 12
By default, we have lazy=true but we can set this globally also, like below:

Example:

<hibernate-mapping
schema="AUCTION"
default-lazy="false"
default-access="field"
auto-import="false">
<class ...>
...
</class>
</hibernate-mapping>


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.