-->
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: a question about the source, constants type.
PostPosted: Wed Sep 20, 2006 1:56 am 
Newbie

Joined: Tue Aug 01, 2006 1:44 am
Posts: 4
Location: Guangzhou, China
Hi all,
I hava a question when reading the source of Hibernate, why are all the constants encapsulated into classes, for instance, FlushMode.AUTO, the value return is an instance of Flush class. can't it do the job by simply using a String? thanks for your answer:)

Arnold


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 2:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I'ts called encapsulation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 4:18 am 
Newbie

Joined: Tue Aug 01, 2006 1:44 am
Posts: 4
Location: Guangzhou, China
max wrote:
I'ts called encapsulation.

hi max, I understand it's encapsulation, are there some more benefits of returning the constants in it's own type rather than returning a built-in type. many thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 4:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
there are no builtin type for our fetchmode, entitymode etc.

So if you just pass a string around you don't get relevant type checking (every mode is a string, but not all strings represent a mode)
plus all your method signatures just say "String" instead of "FetchMode"
which is much more usefull.

_________________
Max
Don't forget to rate


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.