-->
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: DATE manipulation in SQL
PostPosted: Thu Sep 30, 2004 12:40 pm 
Beginner
Beginner

Joined: Wed Jan 28, 2004 2:06 am
Posts: 33
The query does not return anything. Can anybody help me with this ?

This is the code

String queryStr = "from PasswordExpiration passObj " +
" where ( passObj.lastUpdateTimeOfAttribute + :expirePeriod - :notificationPeriod ) >= :todaysdate
" ;
Query query = session.createQuery(queryStr);
Date d = new Date();
Timestamp ts = new Timestamp(d.getTime());
query.setTimestamp("todaysdate",ts);
int expirePeriod = def.getTaAttrPolicy().getDaysToExpire();
int warnPeriod = def.getTaAttrPolicy().getDaysToWarn();

query.setInteger("expirePeriod", expirePeriod);
query.setInteger("notificationPeriod", warnPeriod);
results = query.list();

The class is

/**
* @hibernate.class table="PasswordExpiration"
*/
public class PasswordExpiration implements Serializable {

private int id = 0;
private int passAttrDefId;
private Timestamp lastUpdateTimeOfAttribute;
private Timestamp lastUpdateTime;
private String userName;
private int userId;

/**
* @hibernate.id column="passwordExpId" type="int"
* generator-class="com.trulogica.truaccess.idgen.util.HibernateIdGenerator"
* unsaved-value="0"
* @hibernate.generator-param name="TableName" value="PasswordExpiration"
*/
public int getId() {
return id;
}

public void setId(int _id) {
id = _id;
}

/**
* @hibernate.property column="passAttrDefId" type="int" not-null="true"
*/
public int getPassAttrDefId() {
return passAttrDefId;
}

public void setPassAttrDefId(int _passAttrDefId) {
passAttrDefId = _passAttrDefId;
}

/**
* @hibernate.property column="lastUpdateTime" type="timestamp" not-null="true"
*/
public Timestamp getLastUpdateTime() {
return lastUpdateTime;
}

public void setLastUpdateTime(Timestamp _lastUpdateTime) {
lastUpdateTime = _lastUpdateTime;
}

/**
* @hibernate.property column="lastUpdateTimeOfAttribute" type="timestamp" not-null="true"
*/
public Timestamp getLastUpdateTimeOfAttribute() {
return lastUpdateTimeOfAttribute;
}

public void setLastUpdateTimeOfAttribute(Timestamp _lastUpdateTimeOfAttribute) {
lastUpdateTimeOfAttribute = _lastUpdateTimeOfAttribute;
}
/**
* @hibernate.property column="userId" type="int" not-null="true"
*/
public int getUserId() {
return userId;
}

public void setUserId(int _userId) {
userId = _userId;
}
/**
* @hibernate.property column="userName" type="string" not-null="true"
*/
public String getUserName(){
return userName;
}

public void setUserName(String _userName) {
userName = _userName;
}
public String toString()
{
StringBuffer lBuffer = new StringBuffer();
lBuffer.append("username: >").append(userName).append(",\n");
lBuffer.append("userId: >").append(userId).append(",\n");
lBuffer.append("lastUpdateTime: >").append(lastUpdateTime).append(",\n");
lBuffer.append("lastUpdateTimeOfAttribute: >").append(lastUpdateTimeOfAttribute).append(",\n");
lBuffer.append("passAttrDefId: >").append(passAttrDefId).append(",\n");
lBuffer.append("primaryid : >").append(id);
return lBuffer.toString();


}
}


Any help is appreciated


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.