-->
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.  [ 3 posts ] 
Author Message
 Post subject: "Long id" or "long id"
PostPosted: Sat May 03, 2008 12:19 pm 
Newbie

Joined: Sat May 03, 2008 11:51 am
Posts: 1
I recently started with Hibernate and in most of the examples I've seen so far they do something like:
Code:
private Long id;

but never
Code:
private long id;

I noticed that for other fields they use int and not Integer. So my question: Why do they use Long instead of long and does it actually matter?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 03, 2008 1:08 pm 
Beginner
Beginner

Joined: Fri Apr 11, 2008 1:48 am
Posts: 36
For example Integer is a pure java object (Wrapper class). The benefit is, that you can use some methods on this object and convert it easily to other types without any casting. See here: http://www.janeg.ca/scjp/pkglang/wrapper.html


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 03, 2008 3:27 pm 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
if u use primitive it means that colum in db to which is property mapped has to be not null

if it can be null u should use object Long

in case of id it doesnt matter cause id can not be null in db


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