-->
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.  [ 2 posts ] 
Author Message
 Post subject: Fake primary key for database view in reveng.xml
PostPosted: Mon Oct 12, 2009 6:29 pm 
Newbie

Joined: Fri Jul 17, 2009 9:33 am
Posts: 3
Hi all,

can I add a 'fake' primary key for a field that belongs to a view?
My view has a column that could be used as primary key but
when i tell hbm2java something like this in the reveng.xml:

Code:
<table name="MY_VIEW_XY">
   <primary-key>
     <key-column name="XP_PK"/>
   </primary-key>
</table>


hibernate tool says:
Quote:
[hibernatetool] CONSOLE> 13.10.2009 00:04:56 WARN main org.hibernate.cfg.reveng.JDBCReader - Rev.eng
. strategy did not report any primary key columns for MY_VIEW_XY.


Or maybe someone has a better idea? The reason I want to define the
primary key is to avoid having the view rows generated as @Embeddable
MY_VIEW_XY_Id classes. Can I tell hbm2java that it's only a view that
I don't want to update anyway?


Top
 Profile  
 
 Post subject: Re: Fake primary key for database view in reveng.xml
PostPosted: Mon Oct 26, 2009 7:22 am 
Newbie

Joined: Fri Jul 17, 2009 9:33 am
Posts: 3
I found a solution: with Oracle you can specify a primary key for
views:

Code:
create view V_XY( XY_PK primary key disable novalidate, OTHER, COLUMNS, .. ) as ...


When I define my View that way, the primary key is detected and everything
works as expected. Of course it's also safer that way.

The base question remains for databases without this feature.
-> can I make Hibernate 'assume' that XY_PK is a primary key even
when that constraint is not present in the database?


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