Joined: Wed Mar 24, 2004 11:13 am Posts: 15 Location: Norcross, GA
|
Hibernate 2.1.2, Spring 1.0.RC1, MSSQLServer, JDK 1.4.2_01.
If I have a domain class like
public class Vacation{
private int visitNumber;
Collection places; // Place
}
public class Place{
private Country belongsTo;
private String description;
private int daysStayed;
}
The country class is mapped to an "immutable" lookup table.
public class Country{
private String id;
private String name;
}
I have mapped Vacation to have a set of Place objects.
I have mapped Country as a many-to-one class within Place with Cascade='none'. This is because Country table is a lookup table that can never be modified from the Place class.
When I try to persist Vacation object, I get
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: Country
I believe I might be using the many-to-one in the wrong context here since my Country object is supposed to be immutable.
____________________________________________________________
Are there any alternatives other than refactoring Place class like
public class Place{
private String countryID;
private String description;
private int daysStayed;
}
and removing the many-to-one mapping in Place to the Country class.
___________________________________________________________
Thanks
Madhu
|
|