-->
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.  [ 6 posts ] 
Author Message
 Post subject: petsoar hsql example
PostPosted: Mon Dec 29, 2003 1:53 pm 
Newbie

Joined: Tue Sep 09, 2003 3:52 pm
Posts: 4
Hello all,

I am trying to follow along the Petsoar example in chapter 15 of Wiley's Java Open Source Programming. The example uses hibernate and the hypersonic database. I've attempted to follow exactly as instructed but am getting the error:

java.sql.SQLException: Table not found: PETS in statement [SELECT COUNT(*) FROM PETS]

It was my understanding that the line

new SchemaUpdate(config).execute(false);
// in init() of HibernatePersistenceManager, see p. 283

should have put the table into the in-memory hypersonic database.

My hibernate.cfg.xml and Pet.hbm.xml files are pasted below. If anyone can suggest the probable source of my error, please advise. Thank you.

-Brian


<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:.</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">4</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</property>
<mapping resource="org/petsoar/pets/Pet.hbm.xml"/>
</session-factory>

</hibernate-configuration>



<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="org.petsoar.pets.Pet"
table="PETS"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="PETID"
type="long"
unsaved-value="0"
>
<generator class="increment">
</generator>
</id>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Pet.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 1:58 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Since HSQL is in-memory, the schema isn't persisted out of memory (hum). So SchemaUpdate cannot find the appropriate table.
Give a try to jdbc:hsqldb:test (file persistence)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 2:46 pm 
Newbie

Joined: Tue Sep 09, 2003 3:52 pm
Posts: 4
>> Give a try to jdbc:hsqldb:test (file persistence)

Emmanual, OK - on your suggestion I changed jdbc:hsqldb:. to jdbc:hsqldb:test in the hibernate.cfg.xml file. No other config or code changes.

My new error I get as a result is

java.sql.SQLException: No data is available

I'm not sure how to proceed (or to back that out) just yet, suggestions welcome.

-Brian


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 5:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Follow instructions in http://www.hibernate.org/ForumMailinglists/HowToAskForHelp
Can't help you with so few information

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2003 7:28 am 
Newbie

Joined: Tue Sep 09, 2003 3:52 pm
Posts: 4
I found my problem - it wasn't a Hibernate issue - it use a misuse of ResultSet (calling rs.getInt(1) before rs.next() produces that SQLException "No data is available" error).

new SchemaUpdate(config).execute(false) seems to work properly with in-memory Hypersonic database.

Brian


Top
 Profile  
 
 Post subject: SchemaUpdate and Hypersonic version
PostPosted: Thu Jan 01, 2004 8:07 pm 
Newbie

Joined: Tue Sep 09, 2003 3:52 pm
Posts: 4
FYI...

I take back the statement in a prior post that

new SchemaUpdate(config).execute(false)

works properly with Hypersonic.

For whatever reason, for me SchemaUpdate.execute only works if I use Hypersonic 1.7.2 RC1. Using the stable release 1.7.1 results in SQLException "Table not found" errors. Even using the RC1 version there still is a problem (maybe only an annoyance?) of ERROR level log messages being omitted by Hibernate if the schema is already up-to-date.


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