Hibernate 3.0 rc1.
I have the following tables, where monitor has a reference to model.
Monitor : ID,NAME,MODEL_ID
Model: MODEL_ID, NAME
I already have a pre-populated list of models e.g model_id=1,name=ACME etc.
To create a new monitor: id=1,name='Test',model_id=1, I have the following code.
Model model = new Model();
model.setModelId(new Long(1));
For brevity I have omitted the begin,commit and close transaction.
Monitor entity = new Monitor();
entity.setName("Test");
entity.setModel(model);
Which results in the correct data of id=1,name=Test,model_id=1 and the model data is unchanged.
My questions are
1. How does Hibernate know not to update the model data information? You can reference me to a page in the reference guide.
2. Is there another way where I can omit creation of a Model object.
TIA
|