-->
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: The Hibernate NEVER save
PostPosted: Tue Oct 25, 2005 6:58 am 
Newbie

Joined: Thu Jul 21, 2005 10:17 am
Posts: 17
Hibernate version:3.1 RC2

Mapping documents:

<?xml version="1.0" ?>
<!DOCTYPE hibernate-mapping (View Source for full doctype...)>
- <hibernate-mapping default-cascade="none" default-access="property" default-lazy="true" auto-import="true">
- <!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine

-->
- <class name="hibernate.Cfg" table="cfg" mutable="true" abstract="false" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" select-before-update="false" optimistic-lock="version">
- <id name="CfId" type="java.lang.Integer">
<column name="Cf_Id" scale="4" precision="0" not-null="true" unique="true" sql-type="int unsigned" />
<generator class="increment" />
</id>
- <property name="CfCampo" type="java.lang.String" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false">
<column name="Cf_Campo" scale="100" precision="0" not-null="true" sql-type="varchar" />
</property>
- <property name="CfBoolean" type="java.lang.Integer" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false">
<column name="Cf_Boolean" scale="1" precision="0" not-null="true" sql-type="int unsigned" />
</property>
- <property name="CfString" type="java.lang.String" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false">
<column name="Cf_String" scale="255" precision="0" not-null="true" sql-type="varchar" />
</property>
- <property name="CfText" type="java.lang.String" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false">
<column name="Cf_Text" scale="65535" precision="0" not-null="true" sql-type="text" />
</property>
- <property name="CfBlob" type="blob" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false">
<column name="Cf_Blob" scale="255" precision="0" not-null="false" sql-type="longblob" />
</property>
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Transaction tx = session.beginTransaction();

List<Cfg> cfg = (cfg) session.createSQL("from Cfg o");

for (Cfg cf : cfg) {
// all the names are setted to "maumau" and i will change to "joselito"
cfg.setName("joselito");
}

tc.commit();

Full stack trace of any exception that occurs:
Never save the data if not PUT the session.flush on end. why ? the List are attached on session , hibernate not detect the change ? I'm using the Hibernate as Service on Jboss 4.0.2

Name and version of the database you are using:
MySQL 5.0.15 RELASE

The generated SQL (show_sql=true):
none.

Debug level Hibernate log excerpt:
? what ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 1:45 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
there is no method on the Session api called createSQL .

you are starting a transaction called tx and committing a transaction called tc.

whether you create a Query through createQuery or createSQLQuery, you will have to call Query.list() in order for H to return a list of Cfg . Otherwise, the list will be emtpty, the body of the for loop will not fire, and there is nothing to send back to the DB.


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.