I can't get it right..
my code:
USERACCOUNT CLASS with method to insert/update user
Code:
public UserAccount insertUserAccount(UserAccount transferUser)
{
Session session = null;
Transaction transaction = null;
try
{
session = HibernateDAOFactory.currentSession();
transaction = session.beginTransaction();
session.saveOrUpdate(transferUser);
transaction.commit();
insertBoolean = true;
HibernateDAOFactory.closeSession();
}
catch(HibernateException he)
{
log.error(he);
if(transaction != null)
{
log.debug("Rolling back transaction");
try
{
transaction.rollback();
insertBoolean = false;
}
catch (HibernateException hte)
{
log.error("Error on rolling back transaction");
}
}
he.printStackTrace(); }
catch(Exception e)
{
log.error("Unhandled exception");
log.error(e);
}
return (insertBoolean == true) ? transferUser : null;
}
USERACCOUNT.HBM.XMLCode:
<hibernate-mapping>
<class name="UserAccount" table="USERACCOUNT">
<id name="id" column="userID" type="int" unsaved-value="null">
<generator class="increment" />
</id>
<property name="firstname" type="string" />
<property name="lastname" type="string" />
<property name="address" type="string" />
<property name="zipcode" type="string" />
<property name="city" type="string" />
<property name="telephone" type="string" />
<property name="email" type="string" />
<property name="username" type="string" />
<property name="password" type="string" />
<property name="old_password" type="string" />
<property name="last_login" type="date" />
<property name="status" type="string" />
<property name="companyID" type="int" />
</class>
</hibernate-mapping>
Is it possible to provide me with some kind of example?