hey, i have some problems with setting up hibernate, maily this one:
ive created a hibernate.cfg.xml for my project which looks like this
Quote:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"./meta/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create-drop</property>
<property name="current_session_context_class">thread</property>
<!-- Connection -->
<property name="connection.driver_class">
org.hsqldb.jdbcDriver
</property>
<property name="connection.url">
jdbc:hsqldb:file:ticketLineDatabase
</property>
<property name="dialect">
org.hibernate.dialect.HSQLDialect
</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="hibernate.show_sql">true</property>
<!-- mapping files -->
<mapping resource="hbm/Address.hbm.xml" />
</session-factory>
</hibernate-configuration>
as you can see there is one entity which is meant to store a street address
starting up hibernate, inserting addresses etc works fine, when i shut it down no errors occur
i would expect the ticketLineDatabase.script file for the hsql database to be generated but hibernate simply reads it in and eventually makes changes to it and then upon termination seems to restore it as it was before the application was started
i tried manually entering a create table ... statement in the .script file and putting it at the end of it, when i run my java app and open the file again hibernate has moved the create table statement to the top
but why doesnt it save "insert ... into..." and "create table .." (if it hasnt exited before) into the .script file on its own?
i have tried every other option for hbm2ddl.auto (create-drop, create, update) but its all the same
ive also tried using an ant exportschema task which worked but that only exports the create table statements and when i run my actual application with eclipse the insert statements wont be saved anyway - however i dont want to use ant at all actually so id rather stick to eclipse-only functionality
so if anyone has any suggestions id be glad to hear them
2 more things which bother me
- hibernate logs the log4j output twice for every single INFO etc for some reason?
- when i run the application it searches for the hibernate.cfg.xml file in the root/bin folder rather then root/ - why is that?
my hibernate versoin is 3, log4j 1.2.15 and hsql 1.8.0.9 i believe