-->
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.  [ 3 posts ] 
Author Message
 Post subject: adding code to the setters
PostPosted: Wed Mar 03, 2004 7:18 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:49 am
Posts: 21
Hi

I've a question about adding associations inside a settermethod..

Im using Hibernate 2.1.2
MySQL 4.0

Here are the relevant code:

****************************************************

/**
* @hibernate.class discriminator-value="Nonconformance"
* @hibernate.discriminator column="subclass" type="string"
*/

public class Nonconformance {

private long nonconformanceKey;
private Status status;

/**
* @hibernate.id generator-class="native" unsaved-value="0"
*/
public long getNonconformanceKey() {
return nonconformanceKey;
} // end getNonConformanceKey

public void setNonconformanceKey(long _nonconformanceKey) {
nonconformanceKey = _nonconformanceKey;
} // end setNonConformanceKey

..........

/**
* @hibernate.one-to-one class="nonconformance.Status" cascade="all"
*/
public Status getStatus() {
return status;
}

public void setStatus(Status _status)
{
status = _status;
status.setNonconformance(this); //IS THIS LEGAL????

}

*********************************************************

The Status-class:

/**
* @hibernate.class
*/

public class Status {

private long nonconformanceKey;

private Nonconformance nonconformance;

/**
* @hibernate.id generator-class="foreign" unsaved-value="0"
* @hibernate.generator-param name="property"
* value="nonconformance"
*/
public long getNonconformanceKey() {
return nonconformanceKey;
}

public void setNonconformanceKey(long _statusKey) {
nonconformanceKey = _statusKey;
}

................

/**
* @hibernate.one-to-one class="nonconformance.Nonconformance"
* lazy="true" constrained="true"
*/
public Nonconformance getNonconformance() {
return nonconformance;
}

public void setNonconformance(Nonconformance
nonconformance) {
this.nonconformance = nonconformance;
}
}

I know my problem is when i load the nonconformance-object from the database. Saving it is no problem. But I get weird problems trying to load the nonconformance object. I have some similiar relationship, actually identical, and when i comment the status.setNonconformance(this); in the setStatus method, all the others work perfectly fine..

I hope this was understandable..


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 7:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, you should not do something like that.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 7:32 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:49 am
Posts: 21
thanx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.