-->
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.  [ 1 post ] 
Author Message
 Post subject: Association clarification
PostPosted: Wed Apr 20, 2005 5:00 pm 
Newbie

Joined: Wed Mar 23, 2005 2:32 pm
Posts: 12
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


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

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.