-->
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: How to generate hinernate mapping for db view?
PostPosted: Mon Oct 03, 2005 7:30 pm 
Newbie

Joined: Mon Oct 03, 2005 7:16 pm
Posts: 1
I am using hibernate tools version 3.1.0.alpha5 to generate the artifacts of a database view defined as following:

create view TDV_ProductOrderItem as
select
TD_OrderItem.UNITPRICE as Price,
TD_ORDERS.ORDERTYPE as Type,
TD_ORDERS.PURCHASEORDERNUMBER as OrderNumber,
TD_PRODUCT.DESCRIPTION as Description,
TD_PRODUCT.SKUID as SKU,
TD_OrderItem.ORG_ID as orgId
from
TD_OrderItem,
TD_ORDERS,
TD_PRODUCT
where
TD_OrderItem.ORDER_TBL_ID=TD_ORDERS.ORDER_TBL_ID AND
TD_OrderItem.PRODUCT_TBL_ID=TD_PRODUCT.PRODUCT_TBL_ID
WITH CHECK OPTION;

Where the TD_xxx are the tables defined in the same schema.
The problem is that the mapping file (hbm.xml is generated as the following:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.tdemand.generated.pojo.TdvProductorderitem" table="TDV_PRODUCTORDERITEM" schema="APPS">
<composite-id name="id" class="com.tdemand.generated.pojo.TdvProductorderitemId">
<key-property name="price" type="double">
<column name="PRICE" precision="126" scale="0" />
</key-property>
<key-property name="type" type="big_decimal">
<column name="TYPE" precision="22" scale="0" />
</key-property>
<key-property name="ordernumber" type="string">
<column name="ORDERNUMBER" length="20" />
</key-property>
<key-property name="description" type="string">
<column name="DESCRIPTION" />
</key-property>
<key-property name="sku" type="big_decimal">
<column name="SKU" precision="22" scale="0" />
</key-property>
<key-property name="orgId" type="long">
<column name="ORG_ID" precision="18" scale="0" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>

The problem here is that it groups all the fields in the view as a composit ID. My question here is : How to eleminate the composit Id effect? I just want it be generated as a plain mapping without any composit id.

BTW I un-checked the "generate compisit id" box when I was generating the artifacts.

Thanks for your help




Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 7:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
A view has no primary key thus it generates the mapping making all fields members of the key.


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.