-->
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: Throwing org.hibernate.TransientObjectException:
PostPosted: Wed Apr 04, 2012 2:34 pm 
Newbie

Joined: Mon Mar 12, 2012 1:38 pm
Posts: 4
@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;

@Entity
@Table(name="WEB_UI_JOB_FUNCTION")
public class JobFunction implements Serializable {
@EmbeddedId
private JobFunctionPK pk;

@Column(name="PANEL_SEQUENCE")
private short panelSequence;

@Column(name="CHANGE_REASON")
private String changeReason;

private String userid;

private Timestamp dtupdate;

@ManyToOne
@JoinColumn(name="FUNCTION_ID" ,insertable=false, updatable=false)
private Function functionId;

@ManyToOne
@JoinColumn(name="JOB_ALIAS",insertable=false, updatable=false )
private Job jobAlias;
@Embeddable
public class JobFunctionPK implements Serializable {
@Column(name="FUNCTION_ID")
private String functionId2;

@Column(name="JOB_ALIAS")
private String jobAlias2;

private static final long serialVersionUID = 1L;

public JobFunctionPK() {
super();
}

public String getFunctionId2() {
return this.functionId2;
}

public void setFunctionId2(String functionId2) {
this.functionId2 = functionId2;
}

public String getJobAlias2() {
return this.jobAlias2;
}

public void setJobAlias2(String jobAlias2) {
this.jobAlias2 = jobAlias2;
}

Hi, above are my model classes

when running the below query..its thorwing the following exception
"org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.ibm.shuttle.model.Job"

query:
public JobFunction search(String jobAlias, String serverAlias, String jobTitle,String jobType){
JobFunction fun=null;
//jobfun=(JobFunction)baseService.findById(JobFunction.class, jobType);
Server server = null;
if (serverAlias != null) {
server = serverService.findById(serverAlias);

}
LOG.info("--jobAlias->" + jobAlias + "--serverAlias-->" + serverAlias
+ "--jobTitle-->" + jobTitle );
Session session = PersistenceSessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(Job.class);

if (jobAlias != null) {
criteria.add(Restrictions.eq("jobAlias", jobAlias));
}
if (jobTitle != null) {
criteria.add(Restrictions.eq("jobTitle", jobTitle));
}

if (serverAlias != null) {
criteria.add(Restrictions.eq("serverAlias", server));
}

List<Job> jobList = criteria.list();
Job job = new Job();
job.setJobList(jobList);
//System.out.println("jobList-->"+jobList.getJobAlias());

if(jobList != null){
System.out.println("in joblist!=null");
Criteria criteria1 = session.createCriteria(JobFunction.class);

if (jobType != null) {
criteria1.add(Restrictions.eq("pk.functionId2", jobType));
}
criteria1.add(Restrictions.eq("jobAlias",job));
fun = (JobFunction)criteria1.list();
fun.getPk().getJobAlias2();
}
return fun;
}
Can any1 pl help me out??Thanks in adv


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.