Hey,
Can any one tell the when objects get persisted in database using Hibernate annotations?
public class LocalizedString {
private static boolean dealerSites; // if true, then read from db else values
@CollectionOfElements
@MapKey(columns = { @Column(name = "locale", nullable = false)})
private Map<Locale, String> values;
public LocalizedString(LocalizedString localizedString)
{
setValues(new HashMap<Locale, String>(localizedString.getValues()));
}
public void setValues(Map<Locale, String> values)
{
this.values = values;
}
public Map<Locale, String> getValues()
{
if (dealersites == true)
{
//read from db
}
}
}
If when dealersites is true & a new LocalizedString getting created (& a call to setValues), then getValues if called (it will be read from database) , it will return NULL, or in the mean time values set via setValues will get stored in database?
So, when the object gets persisted in database - when no furhter reference to object / as soon as any change in the object is made?
Thanks,
Sucheta.
|