Joined: Mon Mar 12, 2012 1:38 pm Posts: 4
|
Hi Can any one give me sample on locking using hibernte or java?? I need to create a lock on jobalias column for the below table ,which wld be row level locking. andd how to release the lock.so that other user can perform something functionally /update .
import java.io.Serializable; import java.sql.Timestamp; import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table;
import com.ibm.shuttle.services.JobService;
/** * Entity class which binds to "WEB_UI_JOB" table. * */
@Entity @Table(name="WEB_UI_JOB") public class Job implements Serializable { @Id @Column(name="JOB_ALIAS") private String jobAlias;
@Column(name="JOB_TITLE") private String jobTitle;
@Column(name="JOB_PURPOSE") private String jobPurpose;
@Column(name="JOB_DESCRIPTION") private String jobDescription;
@Column(name="JOB_STRING") private String jobString;
@Column(name="TARGET_PATH") private String targetPath;
@Column(name="FTP_FILENAME") private String ftpFilename;
@Column(name="FTP_JOB_ALIAS") private String ftpJobAlias;
@Column(name="CAPTURE_RUN") private String captureRun;
@Column(name="CAPTURE_RC") private String captureRc;
@Column(name="CAPTURE_OUTPUT") private String captureOutput;
@Column(name="JOB_SYNCH_TYPE") private String jobSynchType;
@Column(name="EXPECTED_RUN_TIME") private short expectedRunTime;
@Column(name="CHANGE_REASON") private String changeReason; @Column(name = "USERID") private String userid; @Column(name = "DTUPDATE") private Timestamp dtupdate;
@ManyToOne @JoinColumn(name="SERVER_ALIAS") private Server serverAlias;
@OneToMany(mappedBy="jobAlias") private Set<JobHist> webUiJobHistCollection;
@OneToMany(mappedBy="jobAlias") private Set<JobFunction> webUiJobFunctionCollection;
@OneToMany(mappedBy="jobAlias") private Set<JobLock> webUiJobLockCollection;
private static final long serialVersionUID = 1L;
public Job() { super(); }
public String getJobAlias() { return this.jobAlias; }
public void setJobAlias(String jobAlias) { this.jobAlias = jobAlias; }
public String getJobTitle() { return this.jobTitle; }
public void setJobTitle(String jobTitle) { this.jobTitle = jobTitle; }
public String getJobPurpose() { return this.jobPurpose; }
public void setJobPurpose(String jobPurpose) { this.jobPurpose = jobPurpose; }
public String getJobDescription() { return this.jobDescription; }
public void setJobDescription(String jobDescription) { this.jobDescription = jobDescription; }
public String getJobString() { return this.jobString; }
public void setJobString(String jobString) { this.jobString = jobString; }
public String getTargetPath() { return this.targetPath; }
public void setTargetPath(String targetPath) { this.targetPath = targetPath; }
public String getFtpFilename() { return this.ftpFilename; }
public void setFtpFilename(String ftpFilename) { this.ftpFilename = ftpFilename; }
public String getFtpJobAlias() { return this.ftpJobAlias; }
public void setFtpJobAlias(String ftpJobAlias) { this.ftpJobAlias = ftpJobAlias; }
public String getCaptureRun() { return this.captureRun; }
public void setCaptureRun(String captureRun) { this.captureRun = captureRun; }
public String getCaptureRc() { return this.captureRc; }
public void setCaptureRc(String captureRc) { this.captureRc = captureRc; }
public String getCaptureOutput() { return this.captureOutput; }
public void setCaptureOutput(String captureOutput) { this.captureOutput = captureOutput; }
public String getJobSynchType() { return this.jobSynchType; }
public void setJobSynchType(String jobSynchType) { this.jobSynchType = jobSynchType; }
public short getExpectedRunTime() { return this.expectedRunTime; }
public void setExpectedRunTime(short expectedRunTime) { this.expectedRunTime = expectedRunTime; }
public String getChangeReason() { return this.changeReason; }
public void setChangeReason(String changeReason) { this.changeReason = changeReason; }
public String getUserid() { return this.userid; }
public void setUserid(String userid) { this.userid = userid; }
public Timestamp getDtupdate() { return this.dtupdate; }
public void setDtupdate(Timestamp dtupdate) { this.dtupdate = dtupdate; }
public Server getServerAlias() { return this.serverAlias; }
public void setServerAlias(Server serverAlias) { this.serverAlias = serverAlias; }
public Set<JobHist> getWebUiJobHistCollection() { return this.webUiJobHistCollection; }
public void setWebUiJobHistCollection(Set<JobHist> webUiJobHistCollection) { this.webUiJobHistCollection = webUiJobHistCollection; }
public Set<JobFunction> getWebUiJobFunctionCollection() { return this.webUiJobFunctionCollection; }
public void setWebUiJobFunctionCollection(Set<JobFunction> webUiJobFunctionCollection) { this.webUiJobFunctionCollection = webUiJobFunctionCollection; }
public Set<JobLock> getWebUiJobLockCollection() { return this.webUiJobLockCollection; }
public void setWebUiJobLockCollection(Set<JobLock> webUiJobLockCollection) { this.webUiJobLockCollection = webUiJobLockCollection; } public String getStatus(){ String joblogLine=null;String status=null; JobService jobService=new JobService(); joblogLine=jobService.jobLogline(jobAlias); if((joblogLine!=null)|| (!joblogLine.equals(""))) status=jobService.parseJobLogLine(joblogLine); else{ status="NEW"; } return status; } }
|
|