• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Repala Madhu
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);

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();

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....
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!