-->
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.  [ 3 posts ] 
Author Message
 Post subject: Error when the object I am loading is null- Please help_
PostPosted: Tue Jan 25, 2005 12:05 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 2:47 pm
Posts: 45
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hivernate 2
Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9
The generated SQL (show_sql=true):
ok
Debug level Hibernate log excerpt:


This is the hibernate sql that I need so far if I tested the sql it's good but some column are null.
Hibernate: select request0_.TEXT_ID as TEXT_ID1_, request0_.PRIORITY as PRIORITY1_, request0_.X_MFG_PO as X_MFG_PO1_, request0_.X_REQ_ID as X_REQ_ID1_, request0_.X_REQ_COMPANY as X_REQ_CO5_1_, request0_.X_REQ_CONTACT as X_REQ_CO6_1_, request0_.X_REQ_ADDRESS1 as X_REQ_AD7_1_, request0_.X_REQ_ADDRESS2 as X_REQ_AD8_1_, request0_.X_REQ_CITY as X_REQ_CITY1_, request0_.X_REQ_PROVINCE as X_REQ_P10_1_, request0_.X_REQ_POSTCODE as X_REQ_P11_1_, request0_.X_REQ_PHONE as X_REQ_P12_1_, request0_.X_REQ_FAX as X_REQ_FAX1_, request0_.X_DRUG_BRAND_NAME as X_DRUG_14_1_, request0_.X_MFG_NAME as X_MFG_NAME1_, request0_.X_DRUG_ROUTE as X_DRUG_16_1_, request0_.X_DRUG_FORM as X_DRUG_17_1_, user1_.REQ_ID as REQ_ID0_, user1_.LAST_NAME as LAST_NAME0_, user1_.DESCRIPTION as DESCRIPT3_0_, user1_.FIRST_NAME as FIRST_NAME0_, user1_.MIDDLE_NAME as MIDDLE_N5_0_, user1_.TITLE as TITLE0_, user1_.CHANGED_ON as CHANGED_ON0_, user1_.ACTIVE as ACTIVE0_, user1_.PSWD as PSWD0_, user1_.SALT as SALT0_, user1_.USERNAME as USERNAME0_, user1_.EXPIRED as EXPIRED0_, user1_.PHONE as PHONE0_, user1_.FAX as FAX0_, user1_.EMAIL as EMAIL0_, user1_.PRIM_LOC as PRIM_LOC0_ from SAMPLES request0_ left outer join X_REQUESTORS user1_ on request0_.X_REQ_ID=user1_.REQ_ID where request0_.TEXT_ID=?


Since some column are null so this is the error message that I am receiving from hibernate when I am trying to load more than one object.
java.lang.NullPointerExceptionntestLoadUserDetail: java.lang.NullPointerException

Here is my xml file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping >

<class name="SAP.BusinessObjects.Request"
table="SAMPLES">

<id name="textid"
type="java.lang.String"
column="TEXT_ID"
length="30">
<generator class="SAP.DAOObjects.SeqGeneratorDrug"/>
</id>

<property name="priority"
type="java.lang.String"
length="50"
column="PRIORITY"/>

<property name="poNumber"
type="java.lang.String"
length="50"
column="X_MFG_PO"/>

<many-to-one name="practitioner"
class="SAP.BusinessObjects.User"
column= "X_REQ_ID" />

<!-- In this particular case, we cannot use the component to
retreive the phone, fax and user name because the first two
belong to the X_Pratictioner tables and the former belongs
to the Sample table with all the sar data. Cause by the
none-normelize database.
<component name="address" class="SAP.BusinessObjects.Address">
<property name="phone"
type="java.lang.String"
length="18"
column="PHONE"/>

<property name="fax"
type="java.lang.String"
length="18"
column="FAX"/>
</component>
</component> -->

<component name="site" class="SAP.BusinessObjects.Site">
<property name="sitename"
type="java.lang.String"
length="20"
not-null="false"
column="X_REQ_COMPANY"/>
<property name="contactname"
type="java.lang.String"
length="50"
column="X_REQ_CONTACT"/>

<component name="address" class="SAP.BusinessObjects.Address">
<property name="Address1"
type="java.lang.String"
length="50"
column="X_REQ_ADDRESS1"/>
<property name="Address2"
type="java.lang.String"
length="50"
column="X_REQ_ADDRESS2"/>
<property name="City"
type="java.lang.String"
length="50"
column="X_REQ_CITY"/>
<property name="provinceID"
type="java.lang.String"
length="50"
column="X_REQ_PROVINCE"/>
<property name="PostalCode"
type="java.lang.String"
length="50"
column="X_REQ_POSTCODE"/>
<property name="Phone"
type="java.lang.String"
length="18"
column="X_REQ_PHONE"/>
<property name="Fax"
type="java.lang.String"
length="18"
column="X_REQ_FAX"/>
</component>

</component>

<component name="drugSpecification" class="SAP.BusinessObjects.DrugProduct.DrugSpecification">


<component name="drug" class="SAP.BusinessObjects.DrugProduct.Drug">
<property name="tradeName"
type="java.lang.String"
length="50"
column="X_DRUG_BRAND_NAME"/>

</component>

<component name="manufacturer" class="SAP.BusinessObjects.DrugProduct.Manufacturer">
<property name="name"
type="java.lang.String"
length="254"
column="X_MFG_NAME"/>

</component>

<component name="admroute" class="SAP.BusinessObjects.DrugProduct.RouteOfAdministration">
<property name="frenchName"
type="java.lang.String"
length="50"
column="X_DRUG_ROUTE"/>

</component>

<component name="phform" class="SAP.BusinessObjects.DrugProduct.PharmeceuticalForm">
<property name="englishName"
type="java.lang.String"
length="50"
column="X_DRUG_FORM"/>
</component>
</component>

</class>

</hibernate-mapping>


So what do I miss in my code that allow hibernate to load the data with null column or not.

If you need more info, please ask.
Could you please help??????


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 25, 2005 1:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
great mapping ;) ...but where is the code ? and what about the remaining stack traces ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Error whan I load an object that is null
PostPosted: Tue Jan 25, 2005 2:40 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 2:47 pm
Posts: 45
Sorry for the missing code. Hope that will help.

I did read the rule before asking for help. Hope this time I my request is more clear.

Thanks

Main class

package SAP.BusinessObjects;
/*****************************************************************************************************************************************************
* Class: AttachmentDAO
* Author:
* Created: 7-Sep-04
* Updated by:
*****************************************************************************************************************************************************
* Purpose:
*
*
* Instantiated by:
*
*
* Associated JSP Pages:
*
* Function Updates:
*
******************************************************************************************************************************************************/
import SAP.Utility.InfrastructureException;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import SAP.BusinessObjects.DrugProduct.DrugSpecification;
import SAP.DAOObjects.RequestDAO;

public class Request {
private int id;
private int RequestID;
private String textid;
private String priority;
private String poNumber;
private String totalRequested;
private String totalCalculated;
private String signatureConfirmation;
private String requestComplete;
private DrugSpecification drugSpecification = new DrugSpecification();
private DrugSpecification clonedSpecification = new DrugSpecification();
private Site site = new Site();
private Set patients= new HashSet();
private User practitioner = new User();
private RequestDAO requestDAO= new RequestDAO();


// ***METHODS*************************************************** //
/**
* Sets object attribute to string
* Used for testing purposes
* * @return String
*/
public String toString() {
return "REQUEST--"
+ "ID: '"
+ getId()
+ "', "
+ "Priority: '"
+ this.getPriority()
+ "', "
+ "SignatureConfirmation: '"
+ this.getSignatureConfirmation()
+ "', "
+ "RequestComplete: '"
+ this.getRequestComplete()
+ "', "
+ "Specification: '"
+ this.getDrugSpecification().toString()
+ "', "
+ "Site: '"
+ this.getSite().toString()
+ "', "
+"Practitioner: '"
+ this.getPractitioner().toString()
+ "', "
+ "PONumber: '"
+ this.getPoNumber()
+ "', "
+ "TotalRequested: '"
+ this.getTotalRequested()
+ "', "
+ "TotalCalculated: '"
+ this.getTotalCalculated();
}


/**
* Method create.
* Purpose: Create a new Request
*/
public void create() {
requestDAO.create(this);
}
/**
* Method getItemById.
* Returns object based on it's primary key (id)
* @param id
* @param lock
* @return Request
*/
public Request getItemById(String id, boolean lock) throws InfrastructureException {
//Load a Request based on it's id
return (Request) requestDAO.getItemById(id, lock);
}
/**
* Method findAll.
* Returns a collection of all Patients in the database
* @return Collection
*/
public Collection findAll() throws InfrastructureException {
return requestDAO.findAll();
}
/**
* addPatient: Add patient obj to request.
* @return int
*/
public void addPatient(Patient patient) {
patient.setNumber(patients.size() + 1);
patient.addRequest(this);
patient.buildPatientRequestID();
patients.add(patient);
}
/**
* Method createPatientForRequest.
* Create a new patient object & add it to the Request object patients set
* @param init
* @param dob
* @param gender
* @param indication
* @param newPatient
* @param dosAndDur
* @param quantity
* @param amountChange
* @param startOfUsage
* @param medRat
* @param choiceRat
* @param dataRat
*/
public void createPatientForRequest(
String init,
String dob,
String gender,
String indication,
String newPatient,
String dosAndDur,
String quantity,
String amountChange,
String startOfUsage,
String medRat,
String choiceRat,
String dataRat) {
Patient patient=
new Patient(
init,
dob,
gender,
indication,
newPatient,
dosAndDur,
quantity,
amountChange,
startOfUsage,
medRat,
choiceRat,
dataRat);
addPatient(patient);
}

/**
/**
* Method cloneSpecification: clones the drug specification for
* comparison purposes later on
*/
public void cloneSpecification(){
clonedSpecification= (DrugSpecification) drugSpecification.clone();
}

/**
* Method specificationHasChanged: determinines whether the drugSpecification has changed
* @return boolean
*/
public boolean specificationHasChanged(){
if (drugSpecification.equals(clonedSpecification))
return false;
else
return true;
}

/**
* Method search: search for request based on a string parameter
* @param searchString
* @return List
*/
public List search(String searchString) {
return requestDAO.search(searchString);
}
// ***GETTERS AND SETTERS*************************************** //
/**
* Returns the drugSpecification.
* @return DrugSpecification
*/
public DrugSpecification getDrugSpecification() {
return drugSpecification;
}
/**
* Returns the id.
* @return int
*/
public int getId() {
return id;
}
/**
* Returns the patients.
* @return Set
*/
public Set getPatients() {
return patients;
}
/**
* Returns the priority.
* @return String
*/
public String getPriority() {
return priority;
}
/**
* Returns the requestComplete.
* @return boolean
*/
public String getRequestComplete() {
return requestComplete;
}
/**
* Returns the requestID.
* @return int
*/
public int getRequestID() {
return RequestID;
}
/**
* Returns the sAPUser.
* @return User
*/
public User getPractitioner() {
return practitioner;
}
/**
* Returns the signatureConfirmation.
* @return boolean
*/
public String getSignatureConfirmation() {
return signatureConfirmation;
}
/**
* Returns the site.
* @return Site
*/
public Site getSite() {
return site;
}
/**
* Sets the drugSpecification.
* @param drugSpecification The drugSpecification to set
*/
public void setDrugSpecification(DrugSpecification drugSpecification) {
this.drugSpecification= drugSpecification;
}
/**
* Sets the id.
* @param id The id to set
*/
public void setId(int id) {
this.id= id;
}
/**
* Sets the patients.
* @param patients The patients to set
*/
public void setPatients(Set patients) {
this.patients= patients;
}
/**
* Sets the priority.
* @param priority The priority to set
*/
public void setPriority(String priority) {
this.priority= priority;
}
/**
* Sets the requestComplete.
* @param requestComplete The requestComplete to set
*/
public void setRequestComplete(String requestComplete) {
this.requestComplete= requestComplete;
}
/**
* Sets the requestID.
* @param requestID The requestID to set
*/
public void setRequestID(int requestID) {
RequestID= requestID;
}
/**
* Sets the sAPUser.
* @param sAPUser The sAPUser to set
*/
public void setPractitioner(User practitioner) {
this.practitioner= practitioner;
}
/**
* Sets the signatureConfirmation.
* @param signatureConfirmation The signatureConfirmation to set
*/
public void setSignatureConfirmation(String signatureConfirmation) {
this.signatureConfirmation= signatureConfirmation;
}
/**
* Sets the site.
* @param site The site to set
*/
public void setSite(Site site) {
this.site= site;
}


public String getTextid() {
return textid;
}

* Sets the textid.
* @param textid The textid to set
*/
public void setTextid(String textid) {
this.textid = textid;
}

/**
* Returns the poNumber.
* @return String
*/
public String getPoNumber() {
return poNumber;
}
/**
* Returns the totalCalculated.
* @return String
*/
public String getTotalCalculated() {
return totalCalculated;
}
/**
* Returns the totalRequested.
* @return String
*/
public String getTotalRequested() {
return totalRequested;
}
/**
* Sets the poNumber.
* @param poNumber The poNumber to set
*/
public void setPoNumber(String poNumber) {
this.poNumber= poNumber;
}
/**
* Sets the totalCalculated.
* @param totalCalculated The totalCalculated to set
*/
public void setTotalCalculated(String totalCalculated) {
this.totalCalculated= totalCalculated;
}
/**
* Sets the totalRequested.
* @param totalRequested The totalRequested to set
*/
public void setTotalRequested(String totalRequested) {
this.totalRequested= totalRequested;
}

}


Second class Raise the error if the object is null

* Purpose:
*
*
* Instantiated by:
*
*
* Associated JSP Pages:
*
* Function Updates:
*
******************************************************************************************************************************************************/

package SAP.BusinessObjects;


import SAP.DAOObjects.UserDAO;
import SAP.Utility.CalendarUtil;
import Security.PasswordValidation;
import Security.SecurityServices;
import Security.LoginException;
import java.util.*;

public class User {
private String userid;
private int userRoleID;
private String firstname;
private String lastname;
private String middlename;
private String title;
private String description;
private String licence;
private String languagePreference;
private Date currentdate;
private Address address;
private Site site;
private Password pswd;
private boolean active;
private boolean authenticated;
private boolean isExist;
private boolean isRepeated;
private UserDAO dao;
//private PasswordValidation validpassword;



/**
* Sets object attributes to string
* Used for testing purposes
*/
public String toString() {
return "USER--"
+ "ID: '"
+ this.getUserid()
+ "', "
+ "LAST NAME: '"
+ this.getLastname()
+ "', "
+ "FIRST NAME: '"
+ this.getFirstname()
/* + "', "
+ "Password:"
+ pswd.getPassword()
+ "', "
+ "Active"
+ this.isActive()
+ "', "
+ "Username"
+ pswd.getUsername()
+ "', "
+ "Address"
+ this.getSite().getAddress().getAddress1() */
;
}




/*****************************************************************************************************************************************************
* Function: SAPSystemUser
* Author: bdempsey
* Created: 7-Sep-04
* Updated by: dfini
*****************************************************************************************************************************************************
* Purpose:
*
*
* Variables:
*
*
* Function Inputs:
*
*
* Return Value:
*
*
* Called by:
*
*
* Modules Called:
*
*
* Function Updates:
*
******************************************************************************************************************************************************/

//No-arg constructor
public User() {}

// ************************************************************************************
//
// Get and Set properties
//
// ************************************************************************************

/**
* Returns the userRoleID.
* @return int
*/
public int getUserRoleID() {
return userRoleID;
}


/**
* Sets the userRoleID.
* @param userRoleID The userRoleID to set
*/
public void setUserRoleID(int userRoleID) {
this.userRoleID = userRoleID;
}

/**
* Returns the approved.
* @return boolean
*/
public boolean isActive() {
return this.active;
}

/**
* Sets the active.
* @param active The active to set
*/
public void setActive(boolean active) {
this.active = active;
}

/**
* Returns the authenticated.
* @return boolean
*/
public boolean isAuthenticated() {
return this.authenticated;
}

/**
* Returns the isRepeated.
* @return boolean
*/
public boolean isRepeated() {
return isRepeated;
}


/**
* Returns the languagePreference.
* @return char
*/
public String getLanguagePreference() {
return languagePreference;
}



/**
* Sets the approved.
* @param approved The approved to set
*/
public void setApproved(boolean active) {
this.active = active;
}

/**
* Sets the authenticated.
* @param authenticated The authenticated to set
*/
public void setAuthenticated(boolean authenticated) {
this.authenticated = authenticated;
}

/**
* Sets the languagePreference.
* @param languagePreference The languagePreference to set
*/
public void setLanguagePreference(String languagePreference) {
this.languagePreference = languagePreference;
}


/**
* Returns the systemUserID.
* @return int
*/
public String getUserid() {
return userid;
}

/**
* Sets the systemUserID.
* @param systemUserID The systemUserID to set
*/
public void setUserid(String userid) {
this.userid = userid;
}

/**
* Returns the description.
* @return String
*/
public String getDescription() {
setDescription(getTitle() + " " + getFirstname() + " " + getMiddlename() + " " + getLastname());
return description;
}

/**
* Returns the licence.
* @return String
*/
public String getLicence() {
return licence;
}

/**
* Returns the middlename.
* @return String
*/
public String getMiddlename() {
return middlename;
}

/**
* Returns the title.
* @return String
*/
public String getTitle() {
return title;
}

/**
* Sets the description.
* @param description The description to set
*/
public void setDescription(String description) {
this.description = description;
}

/**
* Sets the licence.
* @param licence The licence to set
*/
public void setLicence(String licence) {
this.licence = licence;
}

/**
* Sets the middlename.
* @param middlename The middlename to set
*/
public void setMiddlename(String middlename) {
this.middlename = middlename;
}

/**
* Sets the title.
* @param title The title to set
*/
public void setTitle(String title) {
this.title = title;
}

public String getFirstname() {
return firstname;
}

public void setFirstname(String firstname) {
this.firstname = firstname;
}

public String getLastname() {
return lastname;
}

public void setLastname(String lastname) {
this.lastname = lastname;
}

public void setIsRepeated(boolean isRepeated){
this.isRepeated = isRepeated;
}

public boolean getIsRepeated(){
return isRepeated;
}

public Site getSite(){
return site;
}

public void setSite(Site site){
this.site=site;
}

public UserDAO getDao() {
return dao;
}

public void setDao(UserDAO dao) {
this.dao = dao;
}

/**
* Returns the address.
* @return Address
*/
public Address getAddress() {
return address;
}

/**
* Sets the address.
* @param address The address to set
*/
public void setAddress(Address address) {
this.address = address;
}


/**
* Returns the currentdate.
* @return Date
*/
public Date getCurrentdate() {
return currentdate;
}

/**
* Sets the currentdate.
* @param currentdate The currentdate to set
*/
public void setCurrentdate(Date currentdate) {
this.currentdate = currentdate;
}

/**
* Returns the pswd.
* @return Password
*/
public Password getPswd() {
return pswd;
}

/**
* Sets the pswd.
* @param pswd The pswd to set
*/
public void setPswd(Password pswd) {
this.pswd = pswd;
}


/**
* Returns the validpassword.
* @return PasswordValidation
*/
/* public PasswordValidation getValidpassword() {
return validpassword;
}*/

/**
* Sets the validpassword.
* @param validpassword The validpassword to set
*/
/* public void setValidpassword(PasswordValidation validpassword) {
this.validpassword = validpassword;
}
*/

// ************************************************************************************
//
// Functions
//
// ************************************************************************************

/*****************************************************************************************************************************************************
* Function:
* Author: dfini
* Created: 2005/01/05
* Updated by:
*****************************************************************************************************************************************************
* Purpose: Log the user into the system
*
*
* Variables:
*
*
* Function Inputs: id as the primary key
*
*
* Return Value: user profile
*
*
* Called by:
*
*
* Modules Called: Login.jsp
*
*
* Function Updates:
*
******************************************************************************************************************************************************/

public void login(String username, String password) throws Exception{

try{
//Get an instance of the SecurityServices object.
SecurityServices ss = SecurityServices.getInstance();

//Get the user profile upon the username.
List result = getUserProfile(username);

//Read the result details
Iterator iter= result.iterator(); iter.hasNext();
User user = (User) iter.next();

//User request the authorization to loggin into the system
if (user.isActive()){
if (ss.attemptLogin(username) > 4){
//inactive the user
this.pswd.setUsername( username);
this.active = false;

//UserDAO Initialization
this.dao = new UserDAO();

//Update the user account
dao.Update(this);

//notify the user that their account has been locked
ss.emailNotification(address.getEmail(), this.pswd.getUsername());

//generate an error for the user
throw new LoginException("You have made more than 4 attempts to login. " +
" <BR> Your account has been deactivated for " +
"security purposes. <br>Please contact the " +
"administrator to reactive your account.");
}else{
if((password == null)|| (password == "")){
// First login attempt. TO DO
throw new LoginException("This is the first login. Client must determine how the password should be implemented.");
}else{
//Password must be compared.
byte [] bsalt = ss.getByteFromString(user.pswd.getSalt());
byte [] bpswd = ss.getByteFromString(user.pswd.getPassword());

setAuthenticated(ss.isUserAuthenticated(bsalt,password ,bpswd));
// this.authenticated = ss.isUserAuthenticated(bsalt,password ,bpswd);

// login successfull.. continue
if(this.authenticated){
ss.removeAttemptsLogin(username);
} else{
// login failed..
throw new LoginException("Username/Password does not match.");
}
}
}
}else {
throw new Exception("Your account is not activated. <BR>" +
"Please contact the administrator to activate your account.");
}

}catch (Exception ex) {
throw new Exception ( ex);
}
}


/**
* Method getItemById.
* Returns a object based on it's primary key (id)
* @param id
* @param lock
* @return User
*/
public User getItemById(String userid, boolean lock) {
this.dao = new UserDAO();
return (User) dao.getItemById(userid, lock);
}

/**
* Method findAll.
* Returns a collection of all Users in the database
* @return Collection
*/
public Collection findAll() {
this.dao = new UserDAO();
return dao.findAll();
}

/*****************************************************************************************************************************************************
* Function:
* Author: bdempsey
* Created: 7-Sep-04
* Updated by: dfini (2004/01/05)
*****************************************************************************************************************************************************
* Purpose: Get the user profile upon the username identification
*
*
* Variables:
*
*
* Function Inputs: username
*
*
* Return Value: user profile
*
*
* Called by: Login()
*
*
* Modules Called: UserDAO
*
*
* Function Updates:
*
******************************************************************************************************************************************************/
private List getUserProfile(String username) throws Exception{
this.dao = new UserDAO();
return dao.findByUsername(username);
}


/*******************************************************************************
* Created by: dfini
* Date : 2005-01-19
*
* Purpose : Checked if a user upon the username can be found in the
* database
*
* Methods : Login, registration, and forgot password
* ********************************************************************************/

public boolean isExist(String username)throws Exception{

this.dao = new UserDAO();
List result = dao.findByUsername(username);
return ! result.isEmpty();
}


/*****************************************************************************************************************************************************
* Function:
* Author: bdempsey
* Created: 8-Sep-04
* Updated by:
*****************************************************************************************************************************************************
* Purpose:
*
*
* Variables:
*
*
* Function Inputs:
*
*
* Return Value:
*
*
* Called by:
*
*
* Modules Called:
*
*
* Function Updates:
*
******************************************************************************************************************************************************/
public void delete() {
//should we delete the contact record as well.. need to verify this with DAN Sept 8, 2004
//ContactInformation.delete();
//UserDAO.delete(this);
}



/*****************************************************************************************************************************************************
* Function:
* Author: dfini
* Created: Dec 2004
* Updated by:
*****************************************************************************************************************************************************
* Purpose:
*
*
* Variables:
*
*
* Function Inputs:
*
*
* Return Value:
*
*
* Called by:
*
*
* Modules Called:
*
*
* Function Updates:
*
******************************************************************************************************************************************************/


public void save() throws Exception
{
boolean bReturn=false;

//UserDAO Initialization
this.dao = new UserDAO();
CalendarUtil cal = new CalendarUtil();

try{

//Create or update data
if(this.userid==null){

//Set the current date for saving purpose.
this.setCurrentdate(cal.getCurrentdate());

//This setup is mandatory to avoid raising a database problem due to the none-normalization
//of the database.
pswd.setPasswordid(0);

//If the user insert a password then this password must be
//validated.
if((this.pswd.getPassword()!= null)&&(this.pswd.getPassword()!="")){bReturn = validatePassword();}

//Passing the user class as an object for saving purpose as well as the password object.
if((this.pswd.getPassword() !=null)&&(bReturn==true)){
//Set the password current date for saving purpose.
this.pswd.setCreateddate(cal.getCurrentdate());
this.pswd.save();
dao.Create(this);
}else if(this.pswd.getPassword() ==null){
dao.Create(this);
}

}else{
if((this.isAuthenticated()) && (this.pswd.getPassword() != null)&&(this.pswd.getPassword()!="")){
//Get an instance of the SecurityServices object.
SecurityServices ss = SecurityServices.getInstance();
//Must compare the password insert into the registration form
//with the one saved in the database.
byte [] bsalt = ss.getByteFromString(this.pswd.getSalt());
byte [] bpswd = ss.getByteFromString(this.pswd.getPassword());
this.isRepeated = ss.isUserAuthenticated(bsalt,this.pswd.getPassword(),bpswd);
}
}

if ((this.isRepeated == true) && (this.pswd.getPassword() != null)&&(this.pswd.getPassword()!="")){
//Passing the user class as an object for update purpose.
dao.Update(this);
}else if ((this.isRepeated ==false) && (pswd.getPassword() != null)&&(pswd.getPassword()!="")){
bReturn = validatePassword();
if(bReturn){
//Set the password current date for saving purpose.
this.pswd.setCreateddate(cal.getCurrentdate());
this.pswd.save();
//Passing the user class as an object for update purpose.
dao.Update(this);
}

}

}catch (Exception ex) {
throw new Exception (ex);
}
}

private boolean validatePassword() throws Exception{
boolean bReturn = false;

try{
//Get an instance of the Password Validation object.
PasswordValidation pv = new PasswordValidation();

//Password rules validation.
bReturn=pv.minCharacter(this.pswd.getPassword(), 8);
if(bReturn){bReturn=pv.isAlphaNumeric(this.pswd.getPassword());}

//Checked if the password was used during the last 12 months.
if(bReturn){bReturn=this.pswd.checkIfNotExist(this.pswd.getUsername(), this.pswd.getPassword());}

//Set the password expired date.
CalendarUtil cal = new CalendarUtil();
if(bReturn){this.pswd.setExpireddate(cal.getExpiredDate(182));}

if(bReturn){createPassword(this.pswd.getPassword());}

}catch (Exception ex){throw (ex);}

return bReturn;
}


private void createPassword (String password) throws Exception
{
//Get an instance of the SecurityServices object.
SecurityServices ss = SecurityServices.getInstance();

//Create the hash password.
ss.createPassword(password);

//Get the hash password and the salt used to create the hash password.
pswd.setPassword(ss.getPassword());
pswd.setSalt(ss.getSalt());
}


}


Hibernate stack

Jan 25, 2005 1:26:35 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.6
Jan 25, 2005 1:26:35 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.max_fetch_depth=1, hibernate.cglib.use_reflection_optimizer=true, hibernate.jdbc.use_streams_for_binary=true, hibernate.connection.pool_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N'}
Jan 25, 2005 1:26:35 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using java.io streams to persist binary types
Jan 25, 2005 1:26:35 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jan 25, 2005 1:26:35 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 25, 2005 1:26:35 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Jan 25, 2005 1:26:35 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\Patient.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.Patient -> SAR_PATIENT
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\Drug.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.Drug -> DRUG
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\Manufacturer.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.Manufacturer -> DRUG_MANUFACTURER
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\DrugSpecification.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.DrugSpecification -> DRUG_SPECIFICATION
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\PharmeceuticalForm.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.PharmeceuticalForm -> DRUG_FORM
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\RouteOfAdministration.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.RouteOfAdministration -> DRUG_ROUTE
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\DrugStrength.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.DrugStrength -> DRUG_STRENGTH
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\DrugConcentration.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.DrugConcentration -> DRUG_CONCENTRATION
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\DrugProduct\DrugIndication.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.DrugProduct.DrugIndication -> DRUG_INDICATION
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\User.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.User -> X_REQUESTORS
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\Site.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.Site -> X_SITES
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\Password.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.Password -> PASSWORD_HISTORYS
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\TextList.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.TextList -> LIST_ENTRYS
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: SAP\BusinessObjects\SAR.hbm.xml
Jan 25, 2005 1:26:36 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: SAP.BusinessObjects.Request -> SAMPLES
Jan 25, 2005 1:26:36 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.Site, InvocationTargetException: null
Jan 25, 2005 1:26:37 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.Drug, InvocationTargetException: null
Jan 25, 2005 1:26:37 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.Manufacturer, InvocationTargetException: null
Jan 25, 2005 1:26:37 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.RouteOfAdministration, InvocationTargetException: null
Jan 25, 2005 1:26:37 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.PharmeceuticalForm, InvocationTargetException: null
Jan 25, 2005 1:26:37 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.DrugSpecification, InvocationTargetException: null
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: SAP.BusinessObjects.DrugProduct.Drug.specifications -> DRUG_SPECIFICATION
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jan 25, 2005 1:26:37 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.Oracle9Dialect
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximim outer join fetch depth: 1
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
Jan 25, 2005 1:26:37 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jan 25, 2005 1:26:37 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 0
Jan 25, 2005 1:26:37 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@oimt_oracle_dev:1526:dev1
Jan 25, 2005 1:26:37 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sapadm, password=fidsap}
Jan 25, 2005 1:26:37 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
Jan 25, 2005 1:26:37 PM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Jan 25, 2005 1:26:37 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jan 25, 2005 1:26:37 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.Drug, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.DrugConcentration, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.Patient, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.TextList, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.DrugSpecification, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.Manufacturer, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.RouteOfAdministration, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.Site, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.PharmeceuticalForm, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.DrugIndication, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.Request, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.util.ReflectHelper getBulkBean
INFO: reflection optimizer disabled for: SAP.BusinessObjects.DrugProduct.DrugStrength, InvocationTargetException: null
Jan 25, 2005 1:26:38 PM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Hibernate: select request0_.TEXT_ID as TEXT_ID1_, request0_.PRIORITY as PRIORITY1_, request0_.X_MFG_PO as X_MFG_PO1_, request0_.X_REQ_ID as X_REQ_ID1_, request0_.X_REQ_COMPANY as X_REQ_CO5_1_, request0_.X_REQ_CONTACT as X_REQ_CO6_1_, request0_.X_REQ_ADDRESS1 as X_REQ_AD7_1_, request0_.X_REQ_ADDRESS2 as X_REQ_AD8_1_, request0_.X_REQ_CITY as X_REQ_CITY1_, request0_.X_REQ_PROVINCE as X_REQ_P10_1_, request0_.X_REQ_POSTCODE as X_REQ_P11_1_, request0_.X_REQ_PHONE as X_REQ_P12_1_, request0_.X_REQ_FAX as X_REQ_FAX1_, request0_.X_DRUG_BRAND_NAME as X_DRUG_14_1_, request0_.X_MFG_NAME as X_MFG_NAME1_, request0_.X_DRUG_ROUTE as X_DRUG_16_1_, request0_.X_DRUG_FORM as X_DRUG_17_1_, user1_.REQ_ID as REQ_ID0_, user1_.LAST_NAME as LAST_NAME0_, user1_.DESCRIPTION as DESCRIPT3_0_, user1_.FIRST_NAME as FIRST_NAME0_, user1_.MIDDLE_NAME as MIDDLE_N5_0_, user1_.TITLE as TITLE0_, user1_.CHANGED_ON as CHANGED_ON0_, user1_.ACTIVE as ACTIVE0_, user1_.PSWD as PSWD0_, user1_.SALT as SALT0_, user1_.USERNAME as USERNAME0_, user1_.EXPIRED as EXPIRED0_, user1_.PHONE as PHONE0_, user1_.FAX as FAX0_, user1_.EMAIL as EMAIL0_, user1_.PRIM_LOC as PRIM_LOC0_ from SAMPLES request0_ left outer join X_REQUESTORS user1_ on request0_.X_REQ_ID=user1_.REQ_ID where request0_.TEXT_ID=?


testLoadUserDetail
java.lang.NullPointerExceptionntestLoadUserDetail: java.lang.NullPointerException


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

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.