Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to avoid persisting a child object, which is already there in database?

 
Repala Madhu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, i am using EJB 3.0

I have a scenario, where i don't want to persist a child object with @OneToOne annotation.

@Entity(name = "Alarm")
@Table(name = "ALARM")
public class Alarm extends AppMO
{
public Alarm()
{

}
/**
* Constructor - called by the factory.
* @param name Name of this object.
*/
public Alarm(String name, String MOType, String neName)
{
super( name, MOType, neName);
}

@Basic
@OneToOne
private Severity severity = null;

public Severity getSeverity() {
return severity;
}

public void setSeverity(Severity severity) {
this.severity = severity;
}
}


In the above entity, i am setting a Severity object, which is already there in database.
Alarm alarm = new Alarm();
alarm.setSeverity(severity);

Here the alarm is new object. And the alarm object i am sending from my web client.
So, here i don't want to load/find the severity object on to the manager. With out doing this, how can i persist alarm object in database which be having the severity after successful persistent.


Thanks in advance for all the helps....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic