-->
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.  [ 6 posts ] 
Author Message
 Post subject: inverse relationships generated by hbm2java
PostPosted: Fri Sep 30, 2005 5:39 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Hibernate version:
hibernate3.jar & hibernate-tools.jar from JBossIDE-N200509280156-ALL

part of Waterbdy.hbm.xml
Code:
        <set name="sites" inverse="true">
            <key>
                <column name="llid_no" length="13" not-null="true" />
            </key>
            <one-to-many class="Site" />
        </set>

Generated domain models are behaving differently regarding the value of the attribute known as ejb3 ;-)

For the above mapping, note that Site (the many side) is the relationship owner . If I deploy this all is well. However, if I leave out the mapping document, and set the attribute known as ejb3 to true, here is the generated java ...

Code:
   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
   @JoinColumn(name = "llid_no")
   public Set<gov.blm.ak.arims.generated.Site> getSites() {
      return this.sites;
   }


This relationship behaves much differently - taking transient Waterbdy instances into a persistent state w/ an update tries to delete all related Sites - whereas the mapping document instructs H to ignore this. This is fixed if I manually make the following change to the @OneToMany annotation:

Code:
@OneToMany(mappedBy="site", cascade = CascadeType.ALL, fetch = FetchType.LAZY)


1.) Is it correct to say that mappedBy="site" for @OneToMany is analogous to inverse="true" in the set element in the hbm.xml ? I say this because the following is in the dox.

Code:
To declare a side as not responsible for the relationship, the attribute mappedBy is used

2.) If so, shouldn't the tool generate 'mappedBy' if inverse="true" ?

3.) Can someone please reconcile these two discrepencies in the documentation?

Code:
The rules you have to remember are straightforward: All bi-directional associations need one side as inverse. In a one-to-many association it has to be the many-side


Code:
Since many to one are (almost) always the owner side of a bidirectional relationship


why the almost? how the almost?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 6:35 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
also, I realize this stuff isn't relased yet, but it appears unique= false for all of the @Id properties .


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 01, 2005 2:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hi,

please remember that the hbm2java ejb3 generator is under heavy development thus it will not cover all siyuations from day one ;)

that said its good to get information about which features are missing, but those i would really prefer to have in jira instead of here.

regarding appedby/inverse then your assumptions are mostly correct - mappedby and inverse are in practice the exact same thing and normally they are equilavent in the way you describe.

the issue is just that mappeby explicitly points to the "other" side where as inverse does not - so inverse does not rquire another side. it is more a hint and hibernate actually doesnt care what the other side is and thus their might not be an "other" side.

And thus hbm2java must make assumptions and guess what the the other side is exactly...and that is not always possible.

We are actually considering adding mappedby to the DTD just to allow the tools to be stronger (but the core doesnt care)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 01, 2005 3:09 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
I will try to be a little less hesitant about jira from now on. it's just that there are so many issue trackers in OS w/ a poor signal to noise ratio.

Your point about the subtle differences of @inverse and mappedBy is something I had not thought of.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 01, 2005 3:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes and we also do have our share of signal to noise ratio.

But now where we have something in active development and you are so nice to poke to it and discover areas that is not yet covered I would like it to go to jira so we can track it...when it gets to much i'll say that too...but for now - put obvious missing features/bugs regarding the tools into the jira.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 27, 2007 12:11 pm 
Newbie

Joined: Thu Sep 27, 2007 10:48 am
Posts: 5
I was never hesitant about jira.. I had no reason.. it has so many features and i got along with it just great until now.. but who knows..

Features

* Manage bugs, features, tasks, improvements or any issue
* A clean and powerful user interface that is easy to understand for both business and technical users
* Map your business processes to custom workflows
* Track attachments, changes, components and versions
* Full text searching and powerful filtering (customisable, saveable, shareable and subscribeable!)
* Customisable dashboards and real-time statistics
* Enterprise permissioning and security
* Easily extended to and integrated with other systems (including email, RSS, Excel, XML and source control)
* Highly configurable notification options
* Runs on almost any hardware, OS and database platform
* Web service enabled for programmatic control (SOAP, XML-RPC and REST interfaces)


_________________
“Change the changeable, accept the unchangeable, and remove yourself from the unacceptable.” ~ Denis Waitley
[url=http://www.tryforsalebyowner.com/tips_for_selling.html
]fsbo home selling tip[/url]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.