-->
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.  [ 5 posts ] 
Author Message
 Post subject: Simple question about mapping
PostPosted: Wed Nov 22, 2006 9:52 am 
Newbie

Joined: Thu Nov 16, 2006 12:42 pm
Posts: 7
Hi all,

I am new to Hibernate.

I have a simple question i hope somebody can help me with.

I am using Spring MVC and Hibernate(great combination).

I have a mapping with three objects:

Code:
  <class name="ValidationResult" table="validation_result">
     <id name="validationResultId" type="long" column="validation_result_id"></id>
     <property name="aiaValue" column="aia_value" />
     <property name="creationDate" type="timestamp" column="creation_date" />
     <property name="policyNr" column="polnr" />
    <component name="validationRule" class="ValidationRule">
        <property name="ruleId" column="rule_id" />
        <property name="ruleVersion" column="rule_version" />
    </component>
  </class>
 
  <class name="ValidationRule" table="validation_result">
     <id name="ruleId" type="long" column="rule_id"></id>
    <many-to-one name="validationParameter" column="parameter_id" class="ValidationParameter"
                 lazy="false" cascade="none" not-null="true" />     
     <property name="rulesetId" column="ruleset_id" />
     <property name="ruleVersion" column="rule_version" />
  </class>

  <class name="ValidationParameter" table="validation_parameter">
     <id name="parameterId" type="long" column="parameter_id"></id>
        <property name="Uom" column="uom" />
  </class> 


I also have the three objects as POJOs in my application.

So the objects are ValidationResult, ValidationRule and ValidationParameter.

But i have only the DAO and Service layer for one object which is ValidationResult.

So what i want is to retrieve all three objects, by only querying for the ValidationResult. The mapping has the correct relations defined.

Can Hibernate do that, when the two other objects are only defined as POJOs, and in the Hibernate mapping, but they have no Service layer or DAO layer ?

I do not want to query for ValidationRule or ValidationParameter, it only makes sense when querying for ValidationResult to retrieve all three objects.

Or do i need to make a DAO and Service layer for all three objects ?

Best Regards
Cemil


Top
 Profile  
 
 Post subject: Re: Simple question about mapping
PostPosted: Wed Nov 22, 2006 10:12 am 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
Cemil,

if I understand it correctly you have ValidationResult which contains an instance of ValidationRule which contains a Set of ValidationParameters.

If you don't want to access ValidationRule or ValdiationParameter separatly from ValidationResult then you only need 1 DAO: for ValidationResult. Loading a ValidationResult will also load the included ValidationRule & ValidationParameters. (If you allways need the latter 2 when loading ValidationResult, maybe best to sette lazy to false.
regards,
Stijn


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 10:28 am 
Newbie

Joined: Thu Nov 16, 2006 12:42 pm
Posts: 7
Hi TheStijn

Thanks for the quick reply.

That was just the answer i was looking for. :)

And you understood me correctly.

Best Regards
Cemil


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 10:52 am 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
no worries

don't forget the credits (rate the reply)

tx,
Stijn


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 6:27 am 
Newbie

Joined: Thu Nov 16, 2006 12:42 pm
Posts: 7
Hi TheStijn,

Sorry about the rating part.

I just did it.

I just found out about it now :)

Best Regards
Cemil


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

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.