-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Annotations: cannot find Column exception
PostPosted: Tue Mar 21, 2006 12:09 pm 
Newbie

Joined: Sun Jan 22, 2006 3:27 pm
Posts: 11
Hibernate version:3.2.0 Alpha
Hibernate Annotations version 3.1 Beta8
Name and version of database: HSQL DB

Hi

I am getting the above exception and have made sure that all the annotation mappings conform to the guide. It appears as if the table is not being created and I don't know why.

Please help

Fernando

I enclose:
1. The exception log
2. The password class that contains hte annotations and the saveAndUpdate method
3. The hibernateUtil class that returns the Session.




########### exception log
--------------------Configuration: peacTest - JDK version 1.5.0_02 <Default> - <Default>--------------------
19:27:51,756 WARN AnnotationBinder:155 - Package not found or wo package-info.java: PeacTest_Annotations
19:27:52,687 WARN JDBCExceptionReporter:71 - SQL Error: -28, SQLState: S0022
19:27:52,687 ERROR JDBCExceptionReporter:72 - Column not found: VERSION in statement [insert into Password (datePasswordSet, userEncryptedPassword, reasonIfPasswordExpired, managerEncryptedPassword, managerNameForPasswordOveride, employee_OR_Customer, numberTimesPasswordFailed, datePasswordExpires, version, userName, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, null)]
org.hibernate.exception.SQLGrammarException: could not insert: [PeacTest_Annotations.Password]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1986)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2405)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:544)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:533)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:529)
at PeacTest_Annotations.Password.savePasswordObject(Password.java:738)
at PeacTest_Annotations.Password.main(Password.java:1119)
Caused by: java.sql.SQLException: Column not found: VERSION in statement [insert into Password (datePasswordSet, userEncryptedPassword, reasonIfPasswordExpired, managerEncryptedPassword, managerNameForPasswordOveride, employee_OR_Customer, numberTimesPasswordFailed, datePasswordExpires, version, userName, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, null)]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:442)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1948)
... 16 more

Process completed.


########## Class with all properties and the save method
package PeacTest_Annotations;


/** @author Fernando de Nobrega 22 January 2006
*/

//hibernate
import java.io.Serializable;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.hibernate.hql.*;
import javax.persistence.*;

import java.util.*;
import java.util.Date;
import java.io.*;




/**
*
*/
@javax.persistence.Entity()
//@Table(name="passwordObj")
public class Password {

///////////////////////////////////////
// attributes




private Long id;
private Integer version;
private String userName;
private Date datePasswordSet;


private String userEncryptedPassword;

/*Can be the following options:
* - "More than three incorrect"
+"\npassword attempts"
* - "Your password as time lapsed."
*
*/
private String reasonIfPasswordBlocked;

private String managerEncryptedPassword;
private String managerNameForPasswordOveride;
private String employee_OR_customer;
private List oldEncryptedPasswordsArrayList;
private int numberTimesPasswordFailed;
private Date datePasswordExpires;
private boolean passwordAboutToExpireWithinPrefPeriod;

private GregorianCalendar gregorianDatePasswordExpires;

private GregorianCalendar gregorianDatePasswordSet;

private String blankEncrypted = new Encryptor().encrypt("BLANK");

private String blockedEncrypted = new Encryptor().encrypt("BLOCKED");

private String usedEncrypted = new Encryptor().encrypt("USED");

private String manusedEncrypted = new Encryptor().encrypt("MANUSED");


///////////////////////////////////////
// operations


@Version
//@Column(name="versionNo")
public Integer getVersion() { return version; }

public void setVersion(Integer version){this.version = version; }



public Password() {

}

/*performs All the password checks on a User log on and returns specific
*true if password passes unequivically or throws exceptions iwth specific
*messages that signify different reponses.
*
*@param passwordObject the password object for this user
*@param enteredEncryptedPassword the encrypted password entered by the
* user to log onto hte system. May
* be an employee or customer.
*
*@return returns true if password is valid with no warnings attached.
* Else will throw one of the following excepions:
* 1) PasswordInformationNotificationException if the password is
* valid but requires some warning for the user. The warning
* is included in the message of hte exception.
* 2) PasswordFailedException if hte password has failed for
* some reason. The reason for the failure is included in
* the message of hte exception.
*
*/
public boolean performPasswordChecksOnUserLogOn(
String enteredEncryptedPassword) throws LogOnException {

String msg = null;

//return error msg if composition of password is invalid
if (isPasswordCompositionValid(enteredEncryptedPassword) == false) {
msg = "Password comprises of invalid characters.\n"
+"Please use characters ranging '1' to '9', 'a' to 'z'\n"
+"and 'A' to 'Z' to make up a password at least "
+CompanyPreferences.minimumLengthOfValidPasswords
+" characters long"
+"\n (1b)";
throw new PasswordFailedException(msg);
}

//If managerEncryptedPassword = usedEncrypted which means
//that user has not changed their password from the
//manager's
if(managerEncryptedPassword.equals(usedEncrypted)) {
msg = "You may not use the temporary password more than once."
+"\nPlease contact your system administrator\n"
+"for a temporary over ride password."
+" (1)";
throw new PasswordFailedException(msg);
}

//If manager temporary password is in effect
if( ! managerEncryptedPassword.equals(blankEncrypted) &&
! managerEncryptedPassword.equals(usedEncrypted)) {

//If temporary password IS time lapsed
if(hasPasswordTimeExpired() == true ) {
userEncryptedPassword = blockedEncrypted;
managerEncryptedPassword = blankEncrypted;
userEncryptedPassword = blockedEncrypted;
reasonIfPasswordBlocked = "Your password has time lapsed.";
numberTimesPasswordFailed = 0;
msg = " Your temporary password has time lapsed. "
+"\nPlease contact your system administrator\n"
+"for a temporary over ride password."
+" (1a)";
throw new PasswordFailedException(msg);
}

//If passwords match say ok
if(managerEncryptedPassword.equals(enteredEncryptedPassword)) {
//managerEncryptedPassword = usedEncrypted;
userEncryptedPassword = manusedEncrypted;
numberTimesPasswordFailed = 0;
msg = "You have successfully used the temporary password.\n"
+"Please change the temporary password to one \nof your choice"
+"(during the current work session) \n"
+"as you will not be able to log on by using it again."
+" (2)";
throw new PasswordInformationNotificationException(msg);
} else {
//if Passwords do not match:
++numberTimesPasswordFailed;
//if failed attempts is < 3: still not blocked
if(numberTimesPasswordFailed < 3) {
msg = "The password you have entered is incorrect.\n"
+"You have entered an incorrect password "
+ numberTimesPasswordFailed
+" time/s. \nAfter "
+CompanyPreferences.
numberTimesPasswordCanBeEnteredIncorrectly
+" incorrect password attempts access will"
+" be blocked."
+" (3)";
throw new PasswordFailedException(msg);
} else {
//if failed attempts > 3:
managerEncryptedPassword = blankEncrypted;
userEncryptedPassword = blockedEncrypted;
numberTimesPasswordFailed = 0;
msg = "Access is blocked. "
+"\nYou have entered more than "
+CompanyPreferences.
numberTimesPasswordCanBeEnteredIncorrectly +
" \nconsecutive incorrect password/s."
+"\nPlease contact the system administrator\n"
+"for a temporary over ride password."
+" (4)";
throw new PasswordFailedException(msg);
}
}
}

//If access blocked and managerTemporaryPassword = blankEncrypted
//which means that the manger has not yet enteres a temporary password
if(userEncryptedPassword.equals(blockedEncrypted) &&
managerEncryptedPassword.equals(blankEncrypted)) {
msg = "Access is blocked. "
+"\nPlease contact the system administrator\n"
+"for a temporary over ride password."
+" (5)";
throw new PasswordFailedException(msg);
}
//If user password IS time lapsed
if(hasPasswordTimeExpired () == true ) {
userEncryptedPassword = blockedEncrypted;
managerEncryptedPassword = blankEncrypted;
reasonIfPasswordBlocked = "Your password has time lapsed.";

if(employee_OR_customer.equals("employee")) {
msg = " Your password has time lapsed. "
+"\nPlease request a manager\n"
+"for a temporary over ride password."
+" (6)";
throw new PasswordFailedException(msg);
}
if(employee_OR_customer.equals("customer")) {
msg = " Your password has time lapsed. "
+"\nPlease contact our office \n"
+"for a temporary over ride password."
+" (7)";
throw new PasswordFailedException(msg);
} else {
throw new LogOnException("System error: please contact"
+" your system administrator");
}
}

//If password within warning period
String timeLapseWarning = testIfPasswordAboutToExpireWithinPrefPeriod();
if(timeLapseWarning.substring(0,2).equals("ok")) {
timeLapseWarning = "";
}

//If entered password matches to stored password
if(userEncryptedPassword.equals(enteredEncryptedPassword)) {
numberTimesPasswordFailed = 0;
//Password matches OK and no warning required
if(timeLapseWarning.length() == 0) {
return true;
}
//Password matches OK but time lapse warning required
msg = timeLapseWarning + " (8)";
throw new PasswordInformationNotificationException(msg);
} else {
numberTimesPasswordFailed++;
//Incorrect User Password: failed attempts < 3 times
if(numberTimesPasswordFailed < 3) {
msg = "The password you have entered is incorrect.\n"
+"You have entered an incorrect password "
+ numberTimesPasswordFailed +"\n"
+" time/s. After "
+CompanyPreferences.
numberTimesPasswordCanBeEnteredIncorrectly
+" incorrect password attempts access will"
+" be blocked."
+"(9)";
throw new PasswordFailedException(msg);
} else {
//Incorrect User Password: failed attempts more than 3 times
userEncryptedPassword = blockedEncrypted;
managerEncryptedPassword = blankEncrypted;
reasonIfPasswordBlocked = "More than three incorrect"
+"password attempts";
numberTimesPasswordFailed = 0;
msg = "Access is blocked. "
+"\nYou have entered more than "
+CompanyPreferences.
numberTimesPasswordCanBeEnteredIncorrectly +
" \nconsecutive incorrect password/s."
+"\nPlease contact the system administrator\n"
+"for a temporary over ride password."
+"(10)";
throw new PasswordFailedException(msg);
}
}
}//End of performPasswordChecksOnUserLogOn() method

/* *@param passwordObject the password object for this user
*@param enteredEncryptedPassword the new encrypted password that the
* user wants to change their password to.
* May be an employee or customer.
*
*
*@return returns true if password is valid with no warnings attached.
* Else will throw one of the following excepions:
* 1) PasswordInformationNotificationException if the password is
* valid but requires some warning for the user. The warning
* is included in the message of hte exception.
* 2) PasswordFailedException if hte password has failed for
* some reason. The reason for the failure is included in
* the message of hte exception.
*/

public boolean userChangesOwnPassword(Password passwordObject,
String enteredNewUserEncryptedPassword) throws LogOnException {

String msg = null;
String userName = passwordObject.getUserName();

//check for illegal states for a password change:
//user password blocked & managerOverridden blank.
// means that user has not yet gone to manager to get
// temporary password.
if(managerEncryptedPassword.equals(blankEncrypted) &&
userEncryptedPassword.equals(blockedEncrypted)) {
msg = "Access is blocked. "
+"\nPlease contact the system administrator."
+" (13)";
throw new PasswordFailedException(msg);
}

//Normal states:
// - managerEncryptedPassword = blankEncrypted and
// userEncryptedPassword = valid password and
// which means that the user is changing their
// password while they still have a valid password.
// OR
// - managerEncryptedPassword is a valid password and
// userEncryptedPassword = manusedEncrypted
// which means that user has successfully entered
// the manager's temporary password and is still
// in the same work session.
if(managerEncryptedPassword.equals(blankEncrypted) &&
(!userEncryptedPassword.equals(blockedEncrypted) &
!userEncryptedPassword.equals(manusedEncrypted) )
||
(!managerEncryptedPassword.equals(blankEncrypted) &
userEncryptedPassword.equals(manusedEncrypted)) ) {

//Return error msg if password has been used before
if(oldEncryptedPasswordsArrayList.contains(
enteredNewUserEncryptedPassword) == true) {
msg = "This password has been used before.\n"
+"Please create a unique password."
+"(11)";
throw new PasswordFailedException(msg);
}

//return error msg if composition of password is invalid
if (isPasswordCompositionValid(enteredNewUserEncryptedPassword) == false) {
msg = "Password comprises of invalid characters.\n"
+"Please use characters ranging '1' to '9', 'a' to 'z'\n"
+"and 'A' to 'Z' to make up a password at least "
+CompanyPreferences.minimumLengthOfValidPasswords
+" characters long"
+"\n (12)";
throw new PasswordFailedException(msg);
}

//Password OK thus make all changes for an accepted password
userEncryptedPassword = enteredNewUserEncryptedPassword;
managerEncryptedPassword.equals(blankEncrypted);
oldEncryptedPasswordsArrayList.add(userEncryptedPassword);
numberTimesPasswordFailed = 0;
datePasswordSet = new Date();
calcDatePasswordExpires();
return true;
}

//check for states that indicate system corruption
if( !managerEncryptedPassword.equals(blankEncrypted) &&
userEncryptedPassword.equals(blockedEncrypted)
||
!managerEncryptedPassword.equals(blankEncrypted) &&
!userEncryptedPassword.equals(blockedEncrypted) &&
!userEncryptedPassword.equals(manusedEncrypted) ) {
msg = "System error.\nPlease call your system administrator. (14)";
throw new PasswordFailedException(msg);
}

msg = "System error.\nPlease call your system administrator. (15)";
throw new PasswordFailedException(msg);
}//End of userChangesOwnPassword() method


/* *@param passwordObject the password object for the user whose
* passowrd is being changed
*@param enteredEncryptedPassword the new temporary encrypted password
* that the manager has chosen for the
* user who may be an employee or
* customer.
*
*@return returns true if password is valid with no warnings attached.
* Else will throw one of the following excepions:
* 1) PasswordInformationNotificationException if the password is
* valid but requires some warning for the user. The warning
* is included in the message of hte exception.
* 2) PasswordFailedException if hte password has failed for
* some reason. The reason for the failure is included in
* the message of hte exception.
*/
public boolean managerEntersTemporaryPassword(Password passwordObject,
String enteredNewTemporaryEncryptedPassword,
String managerUserNamme)
throws LogOnException {

String msg = null;
String userName = passwordObject.getUserName();

//check for illegal states for a password change:
//none

//return error msg if composition of password is invalid
if (isPasswordCompositionValid(
enteredNewTemporaryEncryptedPassword) == false) {
msg = "Password comprises of invalid characters.\n"
+"Please use characters ranging '1' to '9', 'a' to 'z'\n"
+"and 'A' to 'Z' to make up a password at least "
+CompanyPreferences.minimumLengthOfValidPasswords
+" characters long"
+"\n (16)";
throw new PasswordFailedException(msg);
}

//process password change
userEncryptedPassword = blockedEncrypted;
managerEncryptedPassword = enteredNewTemporaryEncryptedPassword;
managerNameForPasswordOveride = managerUserNamme;
numberTimesPasswordFailed = 0;
datePasswordSet = new Date();
calcDatePasswordExpires();
oldEncryptedPasswordsArrayList.add(enteredNewTemporaryEncryptedPassword);
return true;
}//End of managerEntersTemporaryPassword() method


public void calcDatePasswordExpires() {

//return if no time delays required
if(datePasswordSet == null) {
datePasswordExpires = null;
return;
}
if(employee_OR_customer.equals("employee") &&
CompanyPreferences.forceEmployeesToChangePasswords == false) {
datePasswordExpires = null;
return;
}
if(employee_OR_customer.equals("customer") &&
CompanyPreferences.forceCustomersToChangePasswords == false) {
datePasswordExpires = null;
return;
}

//Set date objects
gregorianDatePasswordSet = new GregorianCalendar();
gregorianDatePasswordSet.setTime(datePasswordSet);
gregorianDatePasswordExpires = gregorianDatePasswordSet;

//For employee time delays
if(employee_OR_customer.equals("employee")) {
gregorianDatePasswordExpires = gregorianDatePasswordSet;
gregorianDatePasswordExpires.add(
GregorianCalendar.MONTH,
CompanyPreferences.
numberMonthsIntervalForEmployeesToChangePasswords);
}

//For customer time delays
if(employee_OR_customer.equals("customer")) {
gregorianDatePasswordExpires = gregorianDatePasswordSet;
gregorianDatePasswordExpires.add(
GregorianCalendar.MONTH,
CompanyPreferences.
numberMonthsIntervalForCustomersToChangePasswords);
}

//Convert GregorianCalendar to Date objects
datePasswordExpires = gregorianDatePasswordExpires.getTime();
}// End of calcDatePasswordExpires() method



private void setPasswordObjIntoMemory(Password passwordObject) {
id = passwordObject.getId();
userName = passwordObject.getUserName();
datePasswordSet = passwordObject.getDatePasswordSet();
userEncryptedPassword = passwordObject.getUserEncryptedPassword();
reasonIfPasswordBlocked = passwordObject.getReasonIfPasswordExpired();
managerEncryptedPassword = passwordObject.getManagerEncryptedPassword();
managerNameForPasswordOveride = passwordObject.getManagerNameForPasswordOveride();
employee_OR_customer = passwordObject.getEmployee_OR_Customer();
oldEncryptedPasswordsArrayList = passwordObject.getOldEncryptedPasswordsArrayList();
numberTimesPasswordFailed = passwordObject.getNumberTimesPasswordFailed();
calcDatePasswordExpires(); //sets datePasswordExpires
}//End of setPasswordObjIntoMemory() method



/*
*@return returns password object object or null if userName incorrect
*/
public Password getPasswordObject(String userName) {
//OSOSOSOSOSOSO HIBERNATE COSE OSOSOSOSOS
Password passwordObject = new TestPassword().getPasswordObj_Cust();
if(passwordObject == null) {
return null;
}

setPasswordObjIntoMemory(passwordObject);
return passwordObject;
}



private boolean isPasswordCompositionValid(String newEncryptedPassword) {
String decryptedPassword = new Decryptor().decrypt(newEncryptedPassword);
boolean doesContainNumeral = false;
boolean doesContainAlpha = false;
if(decryptedPassword.length()
< CompanyPreferences.minimumLengthOfValidPasswords) {
return false;
}

//Loop through decrypted password
for(int cnt = 0; cnt < decryptedPassword.length(); cnt++) {
char character = decryptedPassword.charAt(cnt);
//check if contains illegal character
if( ! ( (character >= '1' & character <= '9') ||
(character >= 'a' & character <= 'z') ||
(character >= 'A' & character <= 'Z') ) ) {
return false;
}

//check if contains at least one digit 1-9
if( (character >= '1' & character <= '9')) {
doesContainNumeral = true;
}

//check if contains at least one digit 1-9
if( (character >= 'a' & character <= 'z') ||
(character >= 'A' & character <= 'Z') ) {
doesContainAlpha = true;
}
}
if(doesContainNumeral == false || doesContainAlpha == false){
return false;
}
return true;
}//End of isPasswordCompositionValid() method
/**
* Does ...
*
*
* @return
* - "ok" = user password nulled and manager temporary password accepted
*
* - "Password comprises of invalid characters.\n"
* +"Please use characters ranging '1' to '9', 'a' to 'z'\n"
* +"and 'A' to 'Z'." = illegal characters used
*
* - "incorrect user name"
*/
public String temporaryUserPasswordByManager(String managerUserName,
String managerEncryptedOverridePassword,
String userNameBeingOverridden) {

Password passwordObject = getPasswordObject(userName);
//test for valid userName
if(passwordObject == null) {
return "incorrect user name";
}

//Check valid composition of password
if (isPasswordCompositionValid(managerEncryptedOverridePassword) == false) {
return "Password comprises of invalid characters.\n"
+"Please use characters ranging '1' to '9', 'a' to 'z'\n"
+"and 'A' to 'Z'.";
}

//Make all changes for accepted password
datePasswordSet = new Date();
calcDatePasswordExpires();
managerEncryptedPassword = managerEncryptedOverridePassword;
numberTimesPasswordFailed = 0;
managerNameForPasswordOveride = managerUserName;
reasonIfPasswordBlocked = null;
userEncryptedPassword = null;
return "ok";
}//end of temporaryUserPasswordByManager



/**
* Does ...
*
*
* @return
*/
public boolean hasPasswordTimeExpired() {
//System.out.println ("IN PASSWORD - datePasswordSet = "+
// datePasswordSet);
//System.out.println ("IN PASSWORD - datePasswordExpires = "+
//datePasswordExpires);
Date today = new Date();

if(today.compareTo(datePasswordExpires) >= 0) {
return true;
}
return false;
} // end hasPasswordTimeExpired



/**
* Does ...
*
*
* @return
*/
public boolean hasTemporaryManagersPasswordTimeExpired() {





/* Date dateManagersTemporaryPasswordExpires = null;
Date today = new Date();

if(datePasswordSet == null) {
datePasswordExpires = null;
return false;
}

//Set date objects
gregorianDatePasswordSet = new GregorianCalendar();
gregorianDatePasswordSet.setTime(datePasswordSet);

//calc expired date
gregorianDatePasswordExpires = gregorianDatePasswordSet;
gregorianDatePasswordExpires.add(
GregorianCalendar.DAY_OF_YEAR,
CompanyPreferences.
numberDaysIntervalForUsersToUseManagersTemporaryPasswords);

//Convert GregorianCalendar to Date objects
dateManagersTemporaryPasswordExpires = gregorianDatePasswordExpires.getTime();


//System.out.println ("IN PASSWORD - datePasswordSet = "+
// datePasswordSet);
//System.out.println ("IN PASSWORD - datePasswordExpires = "+
//datePasswordExpires);
//return if no time delays required


if(today.compareTo(dateManagersTemporaryPasswordExpires) >= 0) {
return true;
}
*/
return false;


} // end hasTemporaryManagersPasswordTimeExpired() method


/**
* Does ...
*
*
* @return Returns a string with the following options
* - "ok" = password ill not lapse within period set by company
* - "Your password will lapse by" + -------- +"."
* +"\nPlease change it as soon as possible."
*/
public String testIfPasswordAboutToExpireWithinPrefPeriod() {
GregorianCalendar gregorianTodayPlusWarningPeriod
= new GregorianCalendar();
gregorianTodayPlusWarningPeriod.add(
GregorianCalendar.DAY_OF_YEAR,
CompanyPreferences.
warningToUser_numberDaysBeforePasswordExpiry);

if( gregorianDatePasswordExpires.compareTo(
gregorianTodayPlusWarningPeriod) < 0) {
return " Your password will lapse by"
+ gregorianTodayPlusWarningPeriod +"."
+"\nPlease change it as soon as possible.";
}
return "ok";
} // end testIfPasswordAboutToExpireWithinPrefPeriod

@Transient
public boolean isPasswordAboutToExpireWithinPrefPeriod() {
return passwordAboutToExpireWithinPrefPeriod;
}



public void setPasswordAboutToExpireWithinPrefPeriod
(boolean isPasswordAboutToExpireWithinPrefPeriod) {
passwordAboutToExpireWithinPrefPeriod
= isPasswordAboutToExpireWithinPrefPeriod;
}
/**
* Does ...
*
*
* @param passwordObject
* @return returns password ID number generated by database
*/
public Long savePasswordObject(Password passwordObject1) {
Session sess = null;
Transaction tx = null;
try {

sess = HibernateUtil.getSessionFactory().openSession();
tx = sess.beginTransaction();

//setPasswordObjIntoMemory(passwordObject1);

sess.save(passwordObject1);
sess.flush();
tx.commit();

} catch (Exception ex) {
tx.rollback();
ex.printStackTrace();
}
finally {
sess.close();
}



//System.out.println ("IN PASSOWRD Serializabl id = " + id);
return id;
} // end savePasswordObject


/**
* Does ...
*
*
* @return
*/
@Id
@GeneratedValue
public Long getId() {
return id;
} // end getId

/**
* Does ...
*
*
* @param _id
*/
public void setId(Long _id) {
id = _id;
} // end setId
/**
* Does ...
*
*
* @return
*/
@Basic
public String getUserName() {
return userName;
} // end getUserName

/**
* Does ...
*
*
* @param _userName
*/
public void setUserName(String _userName) {
userName = _userName;
} // end setUserName


/**
* Does ...
*
*
* @return
*/
public Date getDatePasswordSet() {
return datePasswordSet;
} // end getDatePasswordSet

/**
* Does ...
*
*
* @param _datePasswordSet
*/
public void setDatePasswordSet(Date _datePasswordSet) {
datePasswordSet = _datePasswordSet;
} // end setDatePasswordSet

/**
* Does ...
*
*
* @return
*/

public String getUserEncryptedPassword() {
return userEncryptedPassword;
} // end getUserEncryptedPassword

/**
* Does ...
*
*
* @param _userEncryptedPassword
*/
public void setUserEncryptedPassword(String _userEncryptedPassword) {
userEncryptedPassword = _userEncryptedPassword;
} // end setUserEncryptedPassword

/**
* Does ...
*
*
* @return
*/
public String getReasonIfPasswordExpired() {
return reasonIfPasswordBlocked;
} // end getReasonIfPasswordExpired

/**
* Does ...
*
*
* @param _reasonIfPasswordBlocked
*/
public void setReasonIfPasswordExpired(String _reasonIfPasswordBlocked) {
reasonIfPasswordBlocked = _reasonIfPasswordBlocked;
} // end setReasonIfPasswordExpired

/**
* Does ...
*
*
* @return
*/
public String getManagerEncryptedPassword() {
return managerEncryptedPassword;
} // end getManagerEncryptedPassword

/**
* Does ...
*
*
* @param _managerEncryptedPassword
*/
public void setManagerEncryptedPassword(String _managerEncryptedPassword) {
managerEncryptedPassword = _managerEncryptedPassword;
} // end setManagerEncryptedPassword





/**
* Does ...
*
*
* @return
*/
public String getManagerNameForPasswordOveride() {
return managerNameForPasswordOveride;
} // end getManagerNameForPasswordOveride

/**
* Does ...
*
*
* @param _managerNameForPasswordOveride
*/
public void setManagerNameForPasswordOveride(String _managerNameForPasswordOveride) {
managerNameForPasswordOveride = _managerNameForPasswordOveride;
} // end setManagerNameForPasswordOveride


/**
* Does ...
*
*
* @return
*/
public String getEmployee_OR_Customer() {
return employee_OR_customer;
} // end getEmployee_OR_Customer

/**
* Does ...
*
*
* @param _employee_OR_customer
*/
public void setEmployee_OR_Customer(String _employee_OR_customer) {
employee_OR_customer = _employee_OR_customer;
} // end setEmployee_OR_Customer

/**
* Does ...
*
*
* @return
*/
@org.hibernate.annotations.CollectionOfElements
public List<String> getOldEncryptedPasswordsArrayList() {
return oldEncryptedPasswordsArrayList;
} // end getOldPasswordsVecto

/**
* Does ...
*
*
* @param _oldEncryptedPasswordsArrayList
*/
public void setOldEncryptedPasswordsArrayList(List _oldEncryptedPasswordsArrayList) {
oldEncryptedPasswordsArrayList = _oldEncryptedPasswordsArrayList;
} // end setOldPasswordsArrayList

/**
* Does ...
*
*
* @return
*/
public int getNumberTimesPasswordFailed() {
return numberTimesPasswordFailed;
} // end getOldPasswordsVecto

/**
* Does ...
*
*
* @param _numberTimesPasswordFailed
*/
public void setNumberTimesPasswordFailed(int _numberTimesPasswordFailed) {
numberTimesPasswordFailed = _numberTimesPasswordFailed;
} // end setnumberTimesPasswordFailed

/**
* Does ...
*
*
* @return
*/
public Date getDatePasswordExpires() {
return datePasswordExpires;
} // end getdatePasswordExpires

/**
* Does ...
*
*
* @param _datePasswordExpires
*/
public void setDatePasswordExpires(Date _datePasswordExpires) {
datePasswordExpires = _datePasswordExpires;
} // end setdatePasswordExpires


/**
* Does ...
*
*
* @return
*/
@Transient
public String getManusedEncrypted() {
return manusedEncrypted;
} // end getManusedEncrypted

/**
* Does ...
*
*
* @param _gregorianDatePasswordExpires
*/
public void setManusedEncrypted(String _manusedEncrypted) {
manusedEncrypted = _manusedEncrypted;
} // end setManusedEncrypted


/**
* Does ...
*
*
* @return
*/
@Transient
public String getUsedEncrypted() {
return usedEncrypted;
} // end getUsedEncrypted

/**
* Does ...
*
*
* @param _gregorianDatePasswordExpires
*/
public void setUsedEncrypted(String _usedEncrypted) {
usedEncrypted = _usedEncrypted;
} // end setUsedEncrypted


/**
* Does ...
*
*
* @return
*/
@Transient
public String getBlockedEncrypted() {
return blockedEncrypted;
} // end getBlockedEncrypted

/**
* Does ...
*
*
* @param _gregorianDatePasswordExpires
*/
public void setBlockedEncrypted(String _blockedEncrypted) {
blockedEncrypted = _blockedEncrypted;
} // end setBlockedEncrypted

/**
* Does ...
*
*
* @return
*/
@Transient
public String getBlankEncrypted() {
return blankEncrypted;
} // end getBlankEncrypted

/**
* Does ...
*
*
* @param _gregorianDatePasswordExpires
*/
@Transient
public void setBlankEncrypted(String _blankEncrypted) {
blankEncrypted = _blankEncrypted;
} // end setBlankEncrypted




/**
* Does ...
*
*
* @return
*/
@Transient
public GregorianCalendar getGregorianDatePasswordSet() {
return gregorianDatePasswordSet;
} // end getGregorianDatePasswordSet

/**
* Does ...
*
*
* @param _gregorianDatePasswordExpires
*/
public void setGregorianDatePasswordSet(GregorianCalendar _gregorianDatePasswordSet) {
gregorianDatePasswordSet = _gregorianDatePasswordSet;
} // end setGregorianDatePasswordSet


/**
* Does ...
*
*
* @return
*/
@Transient
public GregorianCalendar getGregorianDatePasswordExpires() {
return gregorianDatePasswordExpires;
} // end getGregorianDatePasswordExpires

/**
* Does ...
*
*
* @param _gregorianDatePasswordExpires
*/
public void setGregorianDatePasswordExpires(GregorianCalendar _gregorianDatePasswordExpires) {
gregorianDatePasswordExpires = _gregorianDatePasswordExpires;
} // end setGregorianDatePasswordExpires



public static void main(String [] args ) {
Password passwordObj = new TestPassword().getPasswordObj_Emp();


passwordObj.savePasswordObject(passwordObj);
}




} // end Password class declaration


########## Hibernate util class to get session
import org.hibernate.cfg.*;
import org.hibernate.hql.*;
import javax.persistence.*;
import javax.persistence.Entity;

import PeacTest_Annotations.*;


public class HibernateUtil implements Serializable {

private static final SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new AnnotationConfiguration()
.addPackage("PeacTest_Annotations") //the fully qualified package name
.addAnnotatedClass(PeacTest_Annotations.Password.class)
.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("XXXXX FDN XXXInitial SessionFactory creation failed." + ex);

throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}

##############


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

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.