• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pls help javax.persistence. PersistenceException: org. hibernate.PropertyValueExc

 
Val Sw
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a function which adds fields of an entity, when I try to add on update screen it gives the following error, same thing works fine on create screen.

Error message:
--------------------------------------
Hibernate:
select
MET_TREATMENT_SEQ.nextval
from
dual
16:11:54,908 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1abb373
javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.entity.Treatment.reagent
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
-------------------------------------

a) This link calls quantExperimentHome.addTreatmentLink
<h:commandLink action="#{quantExperimentHome.addTreatmentLink}"
value="Add treatments" immediate="true">
<f aram name="re_hashcode" value="#{info.hashCode()}"/>
</h:commandLink>

quantExperimentHome.addTreatmentLink method
-------------------------------------------
public String addTreatmentLink(){
javax.faces.context.FacesContext facesContext = (new org.jboss.seam.faces.FacesContext()).getContext();
javax.servlet.http.HttpServletRequest hsr=(javax.servlet.http.HttpServletRequest)facesContext.getCurrentInstance().getExternalContext().getRequest();
String reagentHashcode=hsr.getParameter("re_hashcode");
for(int i=0;i<reagent1.length;i++){
if(reagent1[i].hashCode()==Integer.parseInt(reagentHashcode)){
reagent1[i].getTreatment().add(new Treatment());
break;
}
}
return "added";
}

b) Entities :
Reagent entity
--------------
public class Reagent
implements Equals, HashCode, ToString
{
protected List<Treatment> treatment;
protected QuantExperiment quantExperiment;

@OneToMany(cascade = {CascadeType.ALL}, mappedBy="reagent")
@OrderBy
public List<Treatment> getTreatment() {
if (treatment == null) {
treatment = new ArrayList<Treatment>();
}
return this.treatment;
}

public void setTreatment(List<Treatment> treatment) {
for(Treatment t : treatment){
t.setReagent(this);
}
this.treatment = treatment;
}
@ManyToOne(optional=false)
public QuantExperiment getQuantExperiment() {
return quantExperiment;
}

Treatment entity
----------------
public class Treatment
implements Equals, HashCode, ToString
{
protected Reagent reagent;

@ManyToOne(optional=false)
public Reagent getReagent() {
return reagent;
}
public void setReagent(Reagent reagent) {
this.reagent = reagent;
}
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Val Sw", please check your private messages for an important administrative matter.

Also, please use real words when posting to the forums. Abbreviations such as "pls" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!