-->
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.  [ 2 posts ] 
Author Message
 Post subject: Put Session Variable to Mapped Object
PostPosted: Fri Dec 31, 2004 11:24 am 
Beginner
Beginner

Joined: Fri Dec 26, 2003 3:21 pm
Posts: 23
Location: Jakarta
I create a persisstance object, called LogInformation, I want the createBy and lastUpdateBy value is from session that I create using JSP. I use WebWork to do a save action. This is my code. I got dispose error when try to execute it.

If I remove the line of setCreateBy and setLastUpdateBy, the save execution to database is run well. but the value is null.

anyone can help?

/*
* Created on Dec 25, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.blueoxygen.cimande.role.actions;

import java.util.Calendar;
import org.blueoxygen.util.StringUtils;

import com.opensymphony.webwork.ServletActionContext;

import org.blueoxygen.cimande.LogInformation;
import org.blueoxygen.cimande.role.Role;
import org.blueoxygen.cimande.security.SessionCredentials;
import org.blueoxygen.cimande.security.SessionCredentialsAware;
import org.blueoxygen.cimande.security.User;

/**
* @author frans
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class AddRole extends RoleForm implements SessionCredentialsAware {

private SessionCredentials sessionCredentials;

public String execute() {
Role role = new Role();

if (getName().equalsIgnoreCase(""))
addActionError("Name can't be empty.");
if (getDescription().equalsIgnoreCase(""))
addActionError("Description can't be empty.");

if (hasErrors()) {
return INPUT;
} else {

role.setName(getName());
role.setDescription(getDescription());

// logging information
LogInformation log = new LogInformation();
log.setCreateDate(Calendar.getInstance());
log.setLastUpdateDate(Calendar.getInstance());

String activeUserId;
StringUtils stringUtils = new StringUtils();
activeUserId = ""+stringUtils.decodeBase64(""+ServletActionContext.getRequest().getSession().getAttribute("GA_USER"));

//sessionCredentials.getCurrentUser().setUsername();
log.setCreateBy(activeUserId);
log.setLastUpdateBy(activeUserId);

if (getActiveFlag() == -1) {
log.setActiveFlag(LogInformation.INACTIVE);
} else {
log.setActiveFlag(getActiveFlag());
}

role.setLogInformation(log);

getPersistenceManager().save(role);

return SUCCESS;
}
}

public void setSessionCredentials(SessionCredentials sessionCredentials) {
this.sessionCredentials = sessionCredentials;

}

}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 31, 2004 11:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you don't show any hibernate code and stacktrace nor mappings so how should we help ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.