-->
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.  [ 2 posts ] 
Author Message
 Post subject: Using primitive types versus reference types
PostPosted: Mon Jan 03, 2005 4:58 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
I've noticed in some of the example code that reference types are used instead of primitives. For example, for an auto-increment id value like the following.

private Integer id;

public Integer getId() {
return id;
}

instead of,

private int id;

public int getId() {
return id;
}

I'm wondering if there are any advantages/disadvantages to using reference types instead of primitive types? I'm guessing that the main advantage is that you can easily distinguish whether the property has a null value in the database.

I'm wondering if I should just use reference types for everything? Does anyone have any recommendations?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 6:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I usually use the reference type since null is a natural value for unsaved entities.

But it happens that you are very concerned about your entity memory footprint and thus use a primitive type.

Actually it's up to you if your can find a defaut value for unsaved-value in you business case.

_________________
Emmanuel


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