-->
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: Mapping View from database table
PostPosted: Mon Apr 03, 2006 10:15 am 
Newbie

Joined: Tue Dec 27, 2005 2:55 pm
Posts: 18
Hi!

Can anyone explain me or post here an example code of a .hbm.xml file that maps a table view from a DB table, plz? It would be quite helpful. Thank you!

P.S: I have created one with Hibernate Tools and I got a mapping file the looks like this. (I don't like the idea of all fields being a composite-id...is it possible to be just simple properties so I can select by criteria?)

Code:
<hibernate-mapping>
    <class name="persistenceLayer.ListSensors" table="list_sensors" catalog="kobas_maintenance">
        <composite-id name="id" class="persistenceLayer.ListSensorsId">
            <key-property name="sensorId" type="string">
                <column name="SensorID" length="20" />
            </key-property>
            <key-property name="name" type="string">
                <column name="Name" length="20" />
            </key-property>           
            <key-property name="zeroScale" type="double">
                <column name="ZeroScale" precision="22" scale="0" />
            </key-property>
            <key-property name="fullScale" type="double">
                <column name="FullScale" precision="22" scale="0" />
            </key-property>
            <key-property name="physicalZs" type="double">
                <column name="PhysicalZS" precision="22" scale="0" />
            </key-property>
            <key-property name="physicalFs" type="double">
                <column name="PhysicalFS" precision="22" scale="0" />
            </key-property>
        </composite-id>
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 03, 2006 4:12 pm 
Regular
Regular

Joined: Tue Mar 07, 2006 11:18 am
Posts: 54
Location: Berlin
You can treat your View just like a ordinary db table.

Just map the id as the key and you should be fine!

simon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 4:32 am 
Newbie

Joined: Tue Dec 27, 2005 2:55 pm
Posts: 18
Ok simon, I'll check it a bit later, thank you for your reply!


Top
 Profile  
 
 Post subject: Views and relationships
PostPosted: Fri May 05, 2006 4:45 pm 
Newbie

Joined: Fri May 05, 2006 4:41 pm
Posts: 3
Location: California
Given that you can use the same mapping as a table, can you have a relationship to a view in Hibernate?


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.