-->
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: Insert data at time of schema generation
PostPosted: Thu Jan 13, 2005 12:04 pm 
Newbie

Joined: Thu Jan 13, 2005 11:48 am
Posts: 4
Is their any way we can specify the insert statement to insert data into table after they have been created using hibernate

This is very useful in case of tables which store the constant values

_________________
Thanks,
Ritu


Top
 Profile  
 
 Post subject: SQL-Insert to insert data into lookup tables
PostPosted: Fri Feb 04, 2005 1:30 pm 
Newbie

Joined: Thu Jan 13, 2005 11:48 am
Posts: 4
For my lookup table, I tried to create the hbm.xml file with sql-insert statements , but at the time of object creation , I get the error <sql-insert> not allowed within <class> tag. Why is this happening ? How can I do this ?



Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

        <class name="Status" table="Status">
                <id name="StatusId" column="StatusId" type="long" >
                        <generator class="assigned"/>
                </id>               
                <property name="Description" column="Description" type="string"/>
                <set name="accounts" cascade="all" inverse="true" lazy="true">
               <key column="StatusId"/>
              <one-to-many class="MWAccounts"/>
                </set>
                <set name="orderItems" cascade="all" inverse="true" lazy="true">
               <key column="StatusId"/>
                <one-to-many class="MWOrderItems"/>
                </set>
            <set name="orders" cascade="all" inverse="true" lazy="true">
               <key column="StatusId"/>
                <one-to-many class="MWOrders"/>
                </set>
<sql-insert>insert into status (StatusId,Description) values(1,'Active')</sql-insert>
<sql-insert>insert into status (StatusId,Description) values(2,'Removed')</sql-insert>

         </class>

</hibernate-mapping>

_________________
Thanks,
Ritu


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.