Hibernate look like not saving the data. I took a look in old similar posts, but I'm using transaction in the right way, it looks...
The most strange is that with oracle it saves alright, and it worked some day with HSQL. ALthough it doesn't save, it returns as it was....
BTW, Im using standalone file based HSQL.
Other question: With hibernate, when I have a field with NULL, it returns an empty string, as with oracle it returns null, how do I make they both work in the same way?
Hibernate version: 3.1
Mapping documents:
<class name="com.yell2.core.enhancer.Component" table="component">
<id name="id" type="long">
<column name="id" not-null="false" />
<generator class="increment" />
</id>
<property name="createdDate" column="created_date" />
<property name="status" column="status" />
<property name="statusMsg" column="status_msg" />
<property name="type" column="type" />
<property name="updatedDate" column="updated_date" />
<property name="value" column="value" type="java.lang.String"
length="5000" />
<set name="children" table="parent_children" cascade="all">
<key column="parent_id" />
<many-to-many class="com.yell2.core.enhancer.Component"
column="child_id" />
</set>
<set name="parents" table="parent_children">
<key column="child_id" />
<many-to-many class="com.yell2.core.enhancer.Component"
column="parent_id" />
</set>
</class>
<session-factory>
<!-- config for HSQL -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:file:.</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="com/yell2/core/enhancer/Component.hbm.xml" />
</session-factory>
Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Long id = (Long) session.save(comp);
tx.commit();
HibernateUtil.closeSession();
Full stack trace of any exception that occurs:
Name and version of the database you are using:
HSQL Database Engine, version: 1.8.0
The generated SQL (show_sql=true):
Hibernate: select max(id) from component
Hibernate: insert into component (created_date, status, status_msg, type, updated_date, value, id) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select component0_.id as id0_0_, component0_.created_date as created2_0_0_, component0_.status as status0_0_, component0_.status_msg as status4_0_0_, component0_.type as type0_0_, component0_.updated_date as updated6_0_0_, component0_.value as value0_0_ from component component0_ where component0_.id=?
test
Hibernate: insert into component (created_date, status, status_msg, type, updated_date, value, id) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into component (created_date, status, status_msg, type, updated_date, value, id) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select component0_.id as id0_0_, component0_.created_date as created2_0_0_, component0_.status as status0_0_, component0_.status_msg as status4_0_0_, component0_.type as type0_0_, component0_.updated_date as updated6_0_0_, component0_.value as value0_0_ from component component0_ where component0_.id=?
Hibernate: select component0_.id as id0_0_, component0_.created_date as created2_0_0_, component0_.status as status0_0_, component0_.status_msg as status4_0_0_, component0_.type as type0_0_, component0_.updated_date as updated6_0_0_, component0_.value as value0_0_ from component component0_ where component0_.id=?05-Jan-2006 10:12:28 org.apache.commons.configuration.ConfigurationFactory$FileConfigurationFactory createObject
INFO: Trying to load configuration yell_config.xml
Debug level Hibernate log excerpt:
|