-->
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.  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: running junit tests in ant with hsqldb
PostPosted: Fri Jan 16, 2004 8:08 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
I am attempting to run some simple junit tests in ANT with hsqldb.
I seem to have hit the usual issue with beginners of how to configure hibernate.

I am using the ThreadLocalSession pattern with the following way of getting the session factory...

SessionFactory factory = new Configuration().configure().buildSessionFactory();

Should I use a hibernate.cfg.xml or a hibernate.properties file?
Or does it not matter?
How do I start hsqldb?
I guess that I do not want to be using JNDI as I an not in an app server.

When I have this simple thing running then I would like to submit it as a simple pattern to the hibernate website. The existing pattern [
Documentation > Community Area > Testing with Ant & Junit] does not give info on how to configure hibernate.

Ta,
Stuart.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 8:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Let's see if my great new Tutorial helps anyone :) http://www.gloegl.de/5.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 8:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Particularly http://www.gloegl.de/8.html#A4


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 8:35 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
I take a look at the tutorial and get back.
First page looks good. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 9:56 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
Very nice intro.
Simple data model.
And most importantly a hibernate.cfg.xml file that actually works!
The only other error I had was to try and use the id generator type of 'native' which I guess that hsqldb does not like.
You have saved me hours of headache.


Are you going to provide a link to this from the hibernate wiki/community area?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:03 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
I see that you are using coWiki to produce your website.
Is it good?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Quote:
The only other error I had was to try and use the id generator type of 'native' which I guess that hsqldb does not like.


You should be able to use "native" with hsql, what is the error?

Quote:
I see that you are using coWiki to produce your website.
Is it good?


Yes, it is really nice (The Hibernate hompage uses it, so it must be good :) however it has very harsh requirements (works on PHP5 only)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:36 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
I was wondering what hibernate used to do their pages.
Do you know if the hibernate website is hosted on the sourceforge servers?

I changed back to using native and it works. I must have had some other issue.

As we are running hsql (in process) is it possible to see what SQL gets sent to the database?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Quote:
As we are running hsql (in process) is it possible to see what SQL gets sent to the database?

Yes. Set hibernate.show_sql = true or set log4j.logger.net.sf.hibernate.SQL=debug in your log4j.properties

If you need bind parameters too, set log4j.logger.net.sf.hibernate.type=debug


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
PS: In my sample cfg.xml this is allready enabled, so you should see the generated SQL on stdout.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:56 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
Hmmmm
In not. And even when I set the default logging level to DEBUG there is still no SQL output. I see lots of other debug info.

Have hibernate changed the logger name?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 11:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I am sure this works ... you must be doing something wrong ... log4j.properties at the wrong place? show_sql should work too, this simply prints to standard out.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 11:26 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
cfg.xml file is as below...

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>

<!-- properties -->
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:data/test</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="dialect">net.sf.hibernate.dialect.HSQLDialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
net.sf.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>


In std out I get the following...


[junit] (hbm2ddl.SchemaUpdate 97 ) Running hbm2ddl schema update
[junit] (hbm2ddl.SchemaUpdate 105 ) fetching database metadata
[junit] (hbm2ddl.SchemaUpdate 119 ) updating schema
[junit] (cfg.Configuration 584 ) processing one-to-many association
mappings
[junit] (cfg.Configuration 593 ) processing one-to-one association p
roperty references
[junit] (cfg.Configuration 618 ) processing foreign key constraints
[junit] (hbm2ddl.SchemaUpdate 136 ) schema update complete

And no SQL output.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 11:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Oh, you want the schema DDL to be in the output, just say that :) log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 11:45 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
still nothing


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 21 posts ]  Go to page 1, 2  Next

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.