-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with saving objects
PostPosted: Sun May 14, 2006 2:46 pm 
Newbie

Joined: Sun May 14, 2006 2:22 pm
Posts: 7
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...


Top
 Profile  
 
 Post subject: close SessionFactory
PostPosted: Mon May 15, 2006 12:49 pm 
Newbie

Joined: Sun May 14, 2006 2:22 pm
Posts: 7
OK, I found the solution to my problem. I didn't close the SessionFactory. Perhaps someone should add this to the FAQ...


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