-->
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.  [ 5 posts ] 
Author Message
 Post subject: Using Hibernate with Excel
PostPosted: Mon Feb 13, 2006 12:56 pm 
Newbie

Joined: Mon Feb 13, 2006 12:33 pm
Posts: 2
It may seem odd, but I'd like to use hibernate with Excel spreadsheets. I'm trying to work through a simple test, but I'm unable to save any new objects to the spreadsheet.

After turning off transactions, I can select rows, but when I try to create a new object and save it, I do not receive an error, but nothing is saved.

I'm getting a Connection that I create from Session.open() (since I had no luck setting this up through the regular configuration route).

I'm using Sun's sun.jdbc.odbc.JdbcOdbcDriver driver.

The spreadsheet has two columns "message_id" and "message_text" (this example is from Chapter 2 of Hibernate In Action ). I removed the 'next_message_id" column from the example, however.

I'm using the Message class as shown in the book minus the nextMessage property.

Here's the simple mapping file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
   name="hello.Message"
   table="[MESSAGES$]">
   <id
      name="id"
      column="message_id">
      <generator class="increment"/>
   </id>
      
   <property
      name="text"
      column="message_text">
   </property>
  </class>

</hibernate-mapping>


Any ideas on how to make this work? Thank you.


Top
 Profile  
 
 Post subject: Re: Using Hibernate with Excel
PostPosted: Wed Feb 15, 2006 3:45 pm 
Newbie

Joined: Wed Feb 15, 2006 9:22 am
Posts: 7
Location: Florham Park, NJ
I wonder if the transcation is getting messed up.
Since there aren't really any transactions in Excel anyways, try using the property hibernate.connection.autocommit = true.

Can you post some code ?

//Nicholas


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 8:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hibernate depends on JDBC driver support for full and correct operation. Even though what your doing is interesting - the OBDC-JDBC driver is not very good. There are Java based Excel manipulation libs which might be a better option.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 4:35 pm 
Newbie

Joined: Mon Feb 13, 2006 12:33 pm
Posts: 2
david --

Are you referring to POI and such? Or is there a better open-source JDBC driver for Excel?

I looked into 'xlsql' but had some troubles with that as well.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 10:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I was not thinking an any JDBC based libs. There are COM based approaches, direct manipulation appoaches etc. I was thinking of http://www.andykhan.com/jexcelapi/index.html. POI appears quite good as well. There are others around.

http://www.geocities.com/marcoschmidt.geo/java-libraries-excel.html


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