* @see webwork.action.ActionSupport#doExecute()
*/
protected String doExecute( )
throws Exception
{
Transaction tx = null;
Session s = getHibernateSession( );
String customerId = _customer.getUserId( );
try
{
tx = s.beginTransaction( );
/* Make sure that the user-id is unique */
try
{
Customer c = ( Customer ) s.load( Customer.class, customerId );
if ( !c.getUserId( ).equalsIgnoreCase( _customer.getUserId( ) ) )
{
addError( "customer", getText( "duplicate_account" ) );
return ERROR;
}
}
catch ( ObjectNotFoundException o ) {}
/* Make sure that the email is unique */
String oql = "FROM cst IN CLASS " + Customer.class + " WHERE cst.email=?";
Collection col = s.find( oql, _customer.getEmail( ), Hibernate.STRING );
if ( col.size( ) > 0 )
{
Customer c = ( Customer ) col.iterator( ).next( );
if ( !c.getUserId( ).equalsIgnoreCase( customerId ) )
{
addError( "customer", getText( "duplicate_email" ) );
return ERROR;
}
}
save( _customer, s );
tx.commit( );
return SUCCESS;
}
catch ( Exception e )
{
_log.error( "Unexpected error", e );
if ( tx != null )
{
tx.rollback( );
}
throw e;
}
finally