-->
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.  [ 1 post ] 
Author Message
 Post subject: update record - is this correct?
PostPosted: Mon Oct 11, 2004 8:21 pm 
Regular
Regular

Joined: Fri Oct 08, 2004 4:11 am
Posts: 78
Location: Nottingham, England
Hibernate version:

2.1.1

Mapping documents:

<class name="User" table="usertbl">
<id name="ID" column="user_id" type="integer" unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_user_mytable</param>
</generator>
</id>
<property name="FirstName" column="first_name" type="string" not-null="true"/>
<property name="LastName" column="last_name" type="string" not-null="true"/>
<property name="Address1" column="address1" type="string"/>
<property name="Address2" column="address2" type="string"/>
<property name="Address3" column="address3" type="string"/>
<property name="PostCode" column="postcode" type="string"/>
<property name="Country" column="country" type="string"/>
<property name="Email" column="email" type="string" not-null="true"/>
<property name="HomeTel" column="home_telephone" type="string"/>
<property name="HomeMob" column="mobile_telephone" type="string"/>
<property name="DateJoined" column="date_joined" type="timestamp"/>

<property name="UserName" type="string">
<column name="username" unique-key="UserPassKey"/>
</property>
<property name="UserPassword" type="string">
<column name="userpassword" unique-key="UserPassKey"/>
</property>

<!--<set name="ArtistChoice" lazy="true" cascade="delete" inverse="true">-->
<set name="ArtistChoice" table="choicetbl">
<key column="user_id"/>
<many-to-many column="artist_id" class="test.Artist"/>
</set>
</class>

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

public void updateUser(Object usr){
try {

HibernateUtil Util = new HibernateUtil();
Session session = Util.currentSession();

Transaction transaction = session.beginTransaction();

session.update(usr);
transaction.commit();

Util.closeSession();

}
catch (HibernateException e) {
throw new RuntimeException("Exception in Hibernate:: " + e.getMessage(), e);
}

}

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


My question is simply this, can I update a record with the above code?

regards

Andrew


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.