Hi there
I'm working on a hibernate application of someone else's design, and this is the first time I've used this technology!
The application maps to a series of database tables, and represents them as java objects with realtionships between them that mirror the database itself. This I understand. What I'm trying to do now is to establish a relationship between these objects that is not explicitily defined in the database - a parent/child relationship - which I have to work it out from the data.
So, I'd like to create a new field in the main class (Name) that stores an instance of the class itself.
My attempt to do this was pretty straightforward, I simply declared a new field with getters and setters, like so:
Code:
private Name parentName;
public void setParentName(Name parentName) {
this.parentName= parentName;
}
public Name getParentName() {
return parentName;
}
When I run this however, the program falls over, with the compiler saying it can't determine a type for this object. So instead of the object I tried to create a simple String variable instead. In this case it objected because the variable wasn't mapped to a field in the database. But that's not what I want to do in this case - I want to create a new variable that I populate on the fly.
So can anyone tell me what I'm doing wrong? I presume it's possible to include non-mapped variables in my objects. How can I convince hibernate not to worry that there isn't a field in the database mapped to this one?
thanks in advance!