-->
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: Use of HashMap v/s private variables in Persistent classes
PostPosted: Tue May 18, 2004 12:54 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Though this is more of a design question I wanted the reccomedation. I can design persistent class in 2 ways:

1. Have private attributes similar to the Java bean convention
2. Have a HashMap and write suitable getter and setter methods that put or get from the map.

The advantage that I see is as follows:
1. Development time - Would be relatively less
2. If I add new columns I would just add new getters and setters with keys.

Which is a reccomended approach.

Thanks,

anand


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 2:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
1 is the way to go, 2 is really strange because you loose type safety and evertyhing.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 2:49 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Thanks. For Persistent object I guess following JavaBean conventions is the best approach.

However say I have DTOs then would it make sense to have the 2nd approach. I could have a super class that would centralize access and provide method to cast the values into their respective types.

I guess it's a trade off between time taken and complexity that would decide it.

-Anand


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.