-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping an Entity without Table
PostPosted: Mon Aug 27, 2007 5:45 am 
Newbie

Joined: Tue Jan 24, 2006 12:04 pm
Posts: 12
Hi all,

i have written a hibernate mapping which builds an object from SQL resultset. it is actually read only. i dont need an extra DB-table to store this mapped entity.

it works fine till now.
now i need use hibernate.hbm2ddl.auto=update in my application.
this tool create all the missing tables including my readonly-entity table.

how can I tell hbm to omit such mappings for schema exporting?


Code:
<hibernate-mapping>
    <class name="MyMappingObject">
        <id name="id" column="id"
            type="java.lang.Integer">
        </id>   
       
        <property name="name"
                column="name"
                type="java.lang.String" />                 
               
   <set name="childIds"
            table="REL_TABLEA_TABLEB"
            lazy="false"
            batch-size="50"
             cascade="none" fetch="join">
        <key column="TABLEA_ID"></key>
       <element type="java.lang.Integer" column="TABLEB_ID"></element>
        </set>
     </class>
</hibernate-mapping>

class MyMappingObject {
    Integer id;
    String name;
    Set<Integer> childIds
}
...
session.createSQL("select id, name from tableA").addEntity(MyMappingObject .class).list()
...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 9:52 am 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
Look at Hibernate Reference Documentation Chapter 5. Basic O/R Mapping / 5.1.3. class for the "subselect" attribute.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 11:26 am 
Newbie

Joined: Tue Jan 24, 2006 12:04 pm
Posts: 12
thank for ur reply.

Actually the purpose i write the hibernate mapping for this object is to map my sql-resultset (only the sql-resultset) into java-object.

but hibernate subselect creates a whole view for my entire db. that will be too much and unnecessary.


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