Hibernate version: 3.1.1
Mapping documents: Concept.hbm.xml and hibernate.cfg.xml
+++++++++++++++++++++++++++++++++++++++++
<?xml version='1.0'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.HSQLDialect
</property>
<property name="connection.driver_class">
org.hsqldb.jdbcDriver
</property>
<property name="connection.username">
sa
</property>
<property name="connection.password"></property>
<property name="connection.url">
jdbc:hsqldb:file:///Z:/prog/webPortal/db/MyTestDB;shutdown=true
</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping resource="de\fzi\ipe\webPortal\taxonomy\Concept.hbm.xml"/>
</session-factory>
</hibernate-configuration>
++++++++++++++++++++++++++++++++++++++++++++
<hibernate-mapping>
<class name="de.fzi.ipe.webPortal.taxonomy.Concept" table="tbl_concepts">
<id name="id">
<generator class="sequence">
<param name="sequence">concept_id_seq</param>
</generator>
</id>
<property name="name" type="java.lang.String">
<column name="name"/>
</property>
<set name="children" table="tbl_super_and_children" inverse="true">
<key column="super_id" not-null="true"/>
<many-to-many class="de.fzi.ipe.webPortal.taxonomy.Concept" column="child_id"/>
</set>
<set name="superConcepts" table="tbl_super_and_children" inverse="true">
<key column="child_id" not-null="true"/>
<many-to-many class="de.fzi.ipe.webPortal.taxonomy.Concept" column="super_id"/>
</set>
</class>
</hibernate-mapping>
++++++++++++++++++++++++++++++++++++++++++
Code between sessionFactory.openSession() and session.close():
Session sess = sessionFactory.openSession();
Transaction trans = sess.beginTransaction();
lid = (Long) sess.save(c);
trans.commit();
sess.close();
Name and version of the database you are using:
HSQLDB version: 1.8.0
Content of the hsqldb MyDatabase.script:
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE SEQUENCE CONCEPT_ID_SEQ AS INTEGER START WITH 1
CREATE MEMORY TABLE TBL_CONCEPTS(ID BIGINT NOT NULL PRIMARY KEY,NAME VARCHAR(255))
CREATE MEMORY TABLE TBL_SUPER_AND_CHILDREN(SUPER_ID BIGINT NOT NULL,CHILD_ID BIGINT NOT NULL,CONSTRAINT FKF12BB3CCB4F95E6D FOREIGN KEY(CHILD_ID) REFERENCES TBL_CONCEPTS(ID),CONSTRAINT FKF12BB3CCEE52D3AE FOREIGN KEY(SUPER_ID) REFERENCES TBL_CONCEPTS(ID))
CREATE MEMORY TABLE DUAL_CONCEPT_ID_SEQ(ZERO INTEGER)
ALTER TABLE TBL_CONCEPTS ADD CONSTRAINT FK6DAC1A6CA794E118
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 20
SET SCHEMA PUBLIC
INSERT INTO DUAL_CONCEPT_ID_SEQ VALUES(0)
Problem:
My problem here is that the Object c is not being persistet after I saved it (as you can see from the hsqldb script file). (There is no exception thrown and the log file looks OK.) I am new to hibernate but I read the tutorial, FAQ and API. Probably I made a stupid mistake, like when I forgot the "shutdown=true" in the hibernate.cfg.xml. Please help me...
|