-->
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 Update record Hibernate 3.1
PostPosted: Thu Jun 21, 2007 6:54 am 
Newbie

Joined: Thu Jun 21, 2007 6:45 am
Posts: 1
Hello thank you all

I have a problem with update Hibernate 3.1.

I have a Table (not primary key) in SQL Server 2000 and the Hibernate map is

<hibernate-mapping>
<class name="com.myeclipse.hibernate.Dati" table="DATI" schema="dbo" catalog="TestHibernate">
<composite-id name="id" class="com.myeclipse.hibernate.DatiId" unsaved-value="any">
<key-property name="nome" type="java.lang.String">
<column name="NOME" length="50" />
</key-property>
<key-property name="cognome" type="java.lang.String">
<column name="COGNOME" length="50" />
</key-property>
<key-property name="via" type="java.lang.String">
<column name="VIA" length="50" />
</key-property>
<key-property name="numero" type="java.lang.Integer">
<column name="NUMERO" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>

I use this source for update the column NUMERO:

DatiDAO dDAO = new DatiDAO();
List ls = dDAO.findByProperty("id.numero", 5);
dDAO.getSession().close();
if(ls.size() >0) {
for (int i=0 ; i<ls.size(); i++) {
Dati up = ((Dati)ls.get(i));
DatiId upId = up.getId();
upId.setNumero(10);
up.setId(upId);
DatiDAO dDAO1 = new DatiDAO();
Transaction tx = dDAO1.getSession().beginTransaction();
dDAO.getSession().update(upId);
tx.commit();
dDAO1.getSession().close();
}
}

The problem is that i haven't error or exception but i haven't update in my table

Please help me

Thankyou everyone


Top
 Profile  
 
 Post subject: Re : Problem Update record Hibernate 3.1
PostPosted: Thu Jun 21, 2007 12:04 pm 
Newbie

Joined: Mon Dec 11, 2006 12:54 am
Posts: 14
Hi,

First try to use hibernate's session.save(dDAO1 ) inside your loop after setting proper/required values to dDAO1 .

Create the transaction at the start of your code.
Then outside your for loop do tx.commit()


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.