-->
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: How to store list of objects using hibernate
PostPosted: Tue Jan 13, 2009 9:18 am 
Newbie

Joined: Thu Apr 19, 2007 12:47 am
Posts: 6
Hi,

How i can store collection of objects directly using hibernate? I do not want to iterate through list and store object one by one. Is there any way to store list of objects directly in database?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 10:00 am 
Newbie

Joined: Thu Jan 15, 2009 9:54 am
Posts: 12
Even i m facing with the same problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 2:25 pm 
Beginner
Beginner

Joined: Sun Jan 16, 2005 5:45 pm
Posts: 24
Location: Atlanta
If by List, you mean that you want to maintain an order then use Use "List". If you don't need to maintain order use Set.

Note index element with column attribute.

The mapping file below is used to create a Flight object with a "list" of Airport (Leg) objects.

Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
        <class name="com.xxxx.wab.entities.masterflight.MasterFlightImpl" table="MasterFlight" lazy="false">
      <id name="id" column="id" type="integer" unsaved-value="0">
         <generator class="native">
         </generator>
      </id>
      <version name="ver" column="ver" type="integer"/>

      <property name="airlineDesignator" column="airlineDesignator" index="idxFlight" type="string" length="3" not-null="true" lazy="false"/>
      <property name="flightNumber" column="flightNumber" index="idxFlight" type="integer" length="4" not-null="true" lazy="false"/>
      <property name="operationalSuffix" column="operationalSuffix" index="idxFlight" type="string" length="1" not-null="false" lazy="false"/>
      <property name="flightDate" column="flightDate" index="idxFlight" type="date" not-null="true" lazy="false"/>
      <property name="lastUpdate" column="lastUpdate" type="timestamp" not-null="false" lazy="false"/>
      <property name="emergencyLock" column="emergencyLock" type="boolean" length="1" not-null="false" lazy="false"/>
      <property name="scheduleChange" column="scheduleChange" type="boolean" length="1" not-null="false" lazy="false"/>
                <many-to-one name="subscriber" cascade="lock" column="Subscriberid" index="idxFlight" class="com.xxxx.wab.entities.airline.SubscriberImpl" not-null="true" lazy="false">
      </many-to-one>
      <list name="MasterFlightLegs" lazy="false" cascade="save-update,lock" inverse="false">
         <key column="MasterFlightid" not-null="true"/>
         <index column="MasterFlightIndex" type="integer"/>
                        <one-to-many class="com.xxxx.wab.entities.masterflight.MasterFlightLegImpl"/>
      </list>
   </class>
</hibernate-mapping>


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.