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
|
|