[hibernate-dev] Spring + Hibernate Shards
    Imtiyaz S 
    imtiyaz.s at gmail.com
       
    Sun Jan  8 15:31:58 EST 2012
    
    
  
Has anybody had luck using Spring with Hibernate Shards?
I have implemented a sample in the spring environment. But the data
does not get committed. (Sample project attached)
I figured the issue is with transactions.
in my Dao.save() if i add transaction code then i see the entries in DB.
This does not seem right, we cannot commit on each save...
Code:
 public PK save (E e) {
    	
    	Session s = this.getSessionFactory().openSession();
    	s2.flush();
	Transaction tx =s2.beginTransaction();
		
	Object o = s2.save(e);
	tx.commit();
			
	s2.flush();
        s2.close();
	return (PK) o;
Also getCurrentSession() on SharededSessionFactory throws
"UnsupportedOperationException"
Without Sharding, my configuration in XML was:
Code:
<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="mappingResources">
                  ....
</bean>
Now, for sharding, i am using my own ShardedSessionFactoryBuilder class as
described in:
http://www.ibm.com/developerworks/ja...j-javadev2-11/<http://www.ibm.com/developerworks/java/library/j-javadev2-11/>
So there is no "LocalSessionFactoryBean". Is this needed for Transactions?
thanks in advance.
    
    
More information about the hibernate-dev
mailing list