app/models/Users.java
public Map<String, Object> userSignUpWithRawQuery(final SignUpDTO requestDTO) throws Exception {
		SqlRow newUser = null;
		Map<String, Object> signUpResponse = new HashMap<>();
		Ebean.beginTransaction();
		
		try{
			// Validate inputs
			if(requestDTO.userName.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_USER_NAME.toString());
			}
			if(requestDTO.email.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_EMAIL.toString());
			}
			String hashedPassword = null;
			if(requestDTO.password.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_PASSWORD.toString());
			} else {
				hashedPassword = SecureDigester.digest(requestDTO.password);
			}
			// Check if user already exists
			SqlRow existingUser = findUserByEmailWithRawQuery(requestDTO.email);
			if(existingUser != null) {
				throw new YmlException(EnumMessages.USER_WITH_EMAIL_ALREADY_SIGNED_UP.toString());
			}
			String query = "INSERT INTO users (user_name,password,email,created_date) VALUES(:user_name,:password,:email,:created_date)";
			SqlUpdate insertUser = Ebean.createSqlUpdate(query);
			insertUser.setParameter("user_name", requestDTO.userName).setParameter("password", hashedPassword)
			.setParameter("email", requestDTO.email).setParameter("created_date", new Date().getTime());
			int rows = Ebean.execute(insertUser);
			
			if(rows > 0) {
				newUser = findUserByEmailWithRawQuery(requestDTO.email);
				// Create session for user
				UserSession userSession = new UserSession();
				String sessionToken = userSession.createSessionRawQuery(newUser.getLong(ApiResponseKeys.DB_ID.toString()));
				signUpResponse.put(ApiResponseKeys.USER_ID.toString(), newUser.getString(ApiResponseKeys.DB_ID.toString()));
				signUpResponse.put(ApiResponseKeys.USER_NAME.toString(), newUser.getString(ApiResponseKeys.DB_USER_NAME.toString()));
				signUpResponse.put(ApiResponseKeys.EMAIL.toString(), newUser.getString(ApiResponseKeys.DB_EMAIL.toString()));
				signUpResponse.put(ApiResponseKeys.SESSION_TOKEN.toString(), sessionToken);
			}
			Ebean.commitTransaction();
		} finally {
			if (Ebean.currentTransaction() != null) {
				Ebean.currentTransaction().rollback();
			}

		}
		return signUpResponse;
	}
/**
	 * Insert user for sign up 
	 * @throws Exception 
	 */
Insert user for sign up
@throws Exception
Insert user for sign up @throws Exception
public Map<String, Object> userSignUpWithRawQuery(final SignUpDTO requestDTO) throws Exception {
		SqlRow newUser = null;
		Map<String, Object> signUpResponse = new HashMap<>();
		Ebean.beginTransaction();
		try{
			if(requestDTO.userName.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_USER_NAME.toString());
			}
			if(requestDTO.email.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_EMAIL.toString());
			}
			String hashedPassword = null;
			if(requestDTO.password.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_PASSWORD.toString());
			} else {
				hashedPassword = SecureDigester.digest(requestDTO.password);
			}
			SqlRow existingUser = findUserByEmailWithRawQuery(requestDTO.email);
			if(existingUser != null) {
				throw new YmlException(EnumMessages.USER_WITH_EMAIL_ALREADY_SIGNED_UP.toString());
			}
			String query = "INSERT INTO users (user_name,password,email,created_date) VALUES(:user_name,:password,:email,:created_date)";
			SqlUpdate insertUser = Ebean.createSqlUpdate(query);
			insertUser.setParameter("user_name", requestDTO.userName).setParameter("password", hashedPassword)
			.setParameter("email", requestDTO.email).setParameter("created_date", new Date().getTime());
			int rows = Ebean.execute(insertUser);
			if(rows > 0) {
				newUser = findUserByEmailWithRawQuery(requestDTO.email);
				UserSession userSession = new UserSession();
				String sessionToken = userSession.createSessionRawQuery(newUser.getLong(ApiResponseKeys.DB_ID.toString()));
				signUpResponse.put(ApiResponseKeys.USER_ID.toString(), newUser.getString(ApiResponseKeys.DB_ID.toString()));
				signUpResponse.put(ApiResponseKeys.USER_NAME.toString(), newUser.getString(ApiResponseKeys.DB_USER_NAME.toString()));
				signUpResponse.put(ApiResponseKeys.EMAIL.toString(), newUser.getString(ApiResponseKeys.DB_EMAIL.toString()));
				signUpResponse.put(ApiResponseKeys.SESSION_TOKEN.toString(), sessionToken);
			}
			Ebean.commitTransaction();
		} finally {
			if (Ebean.currentTransaction() != null) {
				Ebean.currentTransaction().rollback();
			}
		}
		return signUpResponse;
	}
public Map < String , Object > userSignUpWithRawQuery ( final SignUpDTO requestDTO ) throws Exception { SqlRow newUser = null ; Map < String , Object > signUpResponse = new HashMap < > ( ) ; Ebean . beginTransaction ( ) ; try { if ( requestDTO . userName . isEmpty ( ) ) { throw new YmlException ( EnumMessages . ENTER_USER_NAME . toString ( ) ) ; } if ( requestDTO . email . isEmpty ( ) ) { throw new YmlException ( EnumMessages . ENTER_EMAIL . toString ( ) ) ; } String hashedPassword = null ; if ( requestDTO . password . isEmpty ( ) ) { throw new YmlException ( EnumMessages . ENTER_PASSWORD . toString ( ) ) ; } else { hashedPassword = SecureDigester . digest ( requestDTO . password ) ; } SqlRow existingUser = findUserByEmailWithRawQuery ( requestDTO . email ) ; if ( existingUser != null ) { throw new YmlException ( EnumMessages . USER_WITH_EMAIL_ALREADY_SIGNED_UP . toString ( ) ) ; } String query = "INSERT INTO users (user_name,password,email,created_date) VALUES(:user_name,:password,:email,:created_date)" ; SqlUpdate insertUser = Ebean . createSqlUpdate ( query ) ; insertUser . setParameter ( "user_name" , requestDTO . userName ) . setParameter ( "password" , hashedPassword ) . setParameter ( "email" , requestDTO . email ) . setParameter ( "created_date" , new Date ( ) . getTime ( ) ) ; int rows = Ebean . execute ( insertUser ) ; if ( rows > 0 ) { newUser = findUserByEmailWithRawQuery ( requestDTO . email ) ; UserSession userSession = new UserSession ( ) ; String sessionToken = userSession . createSessionRawQuery ( newUser . getLong ( ApiResponseKeys . DB_ID . toString ( ) ) ) ; signUpResponse . put ( ApiResponseKeys . USER_ID . toString ( ) , newUser . getString ( ApiResponseKeys . DB_ID . toString ( ) ) ) ; signUpResponse . put ( ApiResponseKeys . USER_NAME . toString ( ) , newUser . getString ( ApiResponseKeys . DB_USER_NAME . toString ( ) ) ) ; signUpResponse . put ( ApiResponseKeys . EMAIL . toString ( ) , newUser . getString ( ApiResponseKeys . DB_EMAIL . toString ( ) ) ) ; signUpResponse . put ( ApiResponseKeys . SESSION_TOKEN . toString ( ) , sessionToken ) ; } Ebean . commitTransaction ( ) ; } finally { if ( Ebean . currentTransaction ( ) != null ) { Ebean . currentTransaction ( ) . rollback ( ) ; } } return signUpResponse ; }
Insert user for sign up
 @throws Exception
Insert user for sign up @throws Exception
// Validate inputs // Check if user already exists // Create session for user