-->
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.  [ 1 post ] 
Author Message
 Post subject: work around for saving collections in stateless session??
PostPosted: Thu Sep 24, 2009 8:58 am 
Regular
Regular

Joined: Fri May 22, 2009 4:50 am
Posts: 59
Hi all,

I want to use stateless session to insert an object Quote, having a map collection, in databse.
I know that collections are ignored in stateless sessions but can there be any work around for this???
As i don't really want to use JDBC for just this one when I am using hibernate through out my application.

Following is my code:

Code:
Class Quote{
    String source;
    SortedMap bids = new TreeMap();
}


mapping file is :

Code:
<class name="Quote" table="QUOTE">
      <id name="id" column="QUOTE_ID">
         <generator class="sequence">
            <param name="sequence">seq1</param>
         </generator>
      </id>     
      <property name="source" column="source"/>
      <map name="bids" table="BIDS" sort="natural">
                <key column="quote_id"/>
                 <index column="price"/>   
         <property name="type"/>
               </map>           
</class>   


problem is there are no records corressponding to bids map in BIDS table. Only QUOTE table is getting populated with records.

following is my code to save the object:

Code:
void writeQuote(Quote quote) {
      StatelessSession session = sessionFactory.openStatelessSession();
      Transaction tx = session.beginTransaction();     
      session.insert(quote);     
      tx.commit();
      session.close();   
    }


Any bright ideas???

Any help appreciated.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.