-->
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.  [ 7 posts ] 
Author Message
 Post subject: Reverse Engineering "views" using Ant tasks
PostPosted: Tue Jan 09, 2007 6:08 am 
Newbie

Joined: Thu Sep 07, 2006 4:35 am
Posts: 9
We are using Hibernate 3 and are using the jdbcconfiguration task to autogenerate our hbm files and later on using hbm2java task in Ant to generate the java files. Things work fine when the hbms and java files are generated for "tables" in the schema. However, our schema even contains views and we generate the hbms and the java files using the same tools. The hbm/java files that are generated for these "views" look weird.

1) The hbm for the view has a id/composite-id defined for it

I am not great at databases, but as far as i know, views do not have something like an id. So, why are these ids generated?

2) If my view returns around 5 columns, then *all* these columns are included as part of the composite-id. Why is this?


Top
 Profile  
 
 Post subject: Re: Reverse Engineering "views" using Ant tasks
PostPosted: Tue Jan 09, 2007 6:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
jai@hibernate wrote:
1) The hbm for the view has a id/composite-id defined for it

I am not great at databases, but as far as i know, views do not have something like an id. So, why are these ids generated?


hibernate still needs to know what identify an object/row thus it needs an id defined for the entities.

Quote:
2) If my view returns around 5 columns, then *all* these columns are included as part of the composite-id. Why is this?


see #1 answer.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Reverse Engineering "views" using Ant tasks
PostPosted: Tue Jan 09, 2007 6:23 am 
Newbie

Joined: Thu Sep 07, 2006 4:35 am
Posts: 9
max wrote:
hibernate still needs to know what identify an object/row thus it needs an id defined for the entities.


Agreed.

max wrote:
2) If my view returns around 5 columns, then *all* these columns are included as part of the composite-id. Why is this?

see #1 answer.


But shouldn't there be a way through which we can say which columns need to be a part of the id(s). Currently, all the columns which dont make any sense being part of the id are getting included in the composite-id.


Top
 Profile  
 
 Post subject: Re: Reverse Engineering "views" using Ant tasks
PostPosted: Tue Jan 09, 2007 6:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
jai@hibernate wrote:
But shouldn't there be a way through which we can say which columns need to be a part of the id(s). Currently, all the columns which dont make any sense being part of the id are getting included in the composite-id.


sure - did you try and read the docs ? :)

http://www.hibernate.org/hib_docs/tools ... ngineering

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 7:09 am 
Newbie

Joined: Thu Sep 07, 2006 4:35 am
Posts: 9
Hmmm.... I did read those docs, but did not pay much attention to the finer details :-) Blame my laziness for that ;-) Thanks for leading me to the docs. This is what we are talking about, right (Just to make sure i read the right configurations) :

Code:
<!-- table allows you to override/define how reverse engineering
     are done for a specific table -->
<table name="ORDERS">
<primary-key>
   <!-- setting up a specific id generator for a table -->
  <generator class="sequence">
    <param name="table">seq_table</param>
  </generator>
   <column name="CUSTID"/>
</primary-key>
<column name="NAME" property="orderName" type="string" />
<!-- control many-to-one and set names for a specific named foreign key constraint -->
<foreign-key constraint-name="ORDER_CUST">
   <many-to-one property="customer"/>
   <set property="orders"/>
</foreign-key>
</table>


I will have to specify the id columns using the <primary-key> element above, isn't it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 7:13 am 
Hibernate Team
Hibernate Team

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

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 7:14 am 
Newbie

Joined: Thu Sep 07, 2006 4:35 am
Posts: 9
Thanks Max for the help :-)


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