-->
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: Excel to Hibernate
PostPosted: Tue Apr 24, 2007 2:42 am 
Newbie

Joined: Wed Mar 07, 2007 3:26 am
Posts: 16
Location: Hyderabad,India
HI Friends i need the sample code which contains how to import and export data to/from excel sheet in hibernate.please any body help its urgent!!!!!!!

_________________
sam


Top
 Profile  
 
 Post subject: How much do you know about the XLS?
PostPosted: Tue Apr 24, 2007 3:37 am 
Newbie

Joined: Tue Aug 08, 2006 3:53 am
Posts: 17
Location: Tanznaia
I don't know about sample code (that would take some time that I don't have) but I can offer some suggestions...

The main issue is: how much do you know about the Excell file?

If it's a single worksheet with a straighforward table of data where you know each column's format completely, then no problem. Just export the spreadsheet to CSV, create a POJO with getter/setter methods for each column in the table and give it a readFromCSVLine(String csv) method. Then call session.save(obj); Job done. For simple, known objects it could be coded up in about half an hour.

At this point I have to ask wether it's actually worth using hibernate for this, or if you could just insert records into the database directly. Same effect, cut out the pointless pojo. If the pojo is to have some other functionality as well (maybe data validation at a minimum?) then use it, otherwise it's a bit pointless.

There is also a feature of hibernate for dynamic objects - I believe this basically means manipulating name/value pairs directly - but I have never used this feature so perhaps someone else could comment.

If it's format is not known then this is a much bigger project. You must be dynamically loading the hibernate mappings for your unknown objects and having some method of tieing in one are of the spreadsheet (probably a whole sheet) with a particular class type. Then you'd need to do come cleverness - either have each pojo inherit from a base class with your readFromExcellRange(Range...) or get creative with reflection.

I hope this helps.

Regards,

Ben.


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.