-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Tools won't Generate @SecondaryTable
PostPosted: Tue Sep 14, 2010 3:50 am 
Newbie

Joined: Tue Sep 14, 2010 3:23 am
Posts: 3
Hi,

I'm using Hibernate Tools (nightly build 3.4.0) to reverse engineer my Database. Overall, it works smoothly, but I'm having trouble when trying to Map a Secondary Table to my Entities. I'll explain myself better:

I have a principal Table called ORDER_PART and a secondary Table called ORDER_PART_DETAIL that I use to persist optional data such as Files and Images. So, I'd like Hibernate Tools to generate a single Entity concerning this two tables, relying on the @SecondaryTable technique.

For example:

Code:
@Entity
@Table(name = "ORDER_PART")
@SecondaryTable(name = "ORDER_PART_DETAIL", pkJoinColumns =  {...})
public class OrderPart implements java.io.Serializable {...}


Is it posible to tell Hibernate Tools to generate this kind of relationship?

Maybe, some manual configuration on reveng.xml?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Hibernate Tools won't Generate @SecondaryTable
PostPosted: Wed Sep 22, 2010 4:16 am 
Newbie

Joined: Tue Sep 14, 2010 3:23 am
Posts: 3
Anybody?


Top
 Profile  
 
 Post subject: Re: Hibernate Tools won't Generate @SecondaryTable
PostPosted: Thu Sep 23, 2010 5:42 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
If I read the Hibernate book right, @SecondaryTable is a JPA-only option.
I think Hibernate Tools is using the .hbm.xml data model, so I guess it's not available.

(This is supported by the fact that the HT Ant task sources do not contain SecondaryTable anywhere, not in Java and not in the template.)

In the book, I have seen this construction:
Code:
<join table="ITEM_SHIPMENT" optional="true">
  <key column="SHIPMENT_ID"/>
  <many-to-one name="auction" column="ITEM_ID" not-null="true" unique="true"/>
</join>
inside the <class> element.

I'd activate .hbm.xml generation, modify the generated .hbm.xml to use the above idiom, then re-generate and see if the <join> survives.
If yes, you have a chance of finding the appropriate options for reveng.xml; if no, you can stop worrying and start looking for an alternative design.


Top
 Profile  
 
 Post subject: Re: Hibernate Tools won't Generate @SecondaryTable
PostPosted: Sat Sep 25, 2010 11:25 am 
Newbie

Joined: Tue Sep 14, 2010 3:23 am
Posts: 3
Joachim,

Finally, I've found out that this design technique (the Secondary table) is quite irrelevant in my particular case, as I tried to use it to insert the heavy fields (Clob and Blob) into a separate table, in order to fine tune my Database schema partitioning and backup routines.
So far, I've discovered that Oracle automatically creates another fisical table to store this kind of content, even if the final users don't notice it, as Oracle just shows the logical representation as a unique table.

Thank you so much anyway.


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