-->
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: AnnotationSessionFactoryBean and LocalSessionFactoryBean pro
PostPosted: Tue May 15, 2007 1:18 pm 
Newbie

Joined: Tue May 15, 2007 1:13 pm
Posts: 2
I have a problem with LocalSessionFactoryBean and AnnotationSessionFactoryBean,first I use LocalSessionFactoryBean as sessionFactory, and there are many hbm.xml files.like this:

Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean ">
<property name="mappingDirectoryLocations">
<list>
<value>classpath*:/XX/common/domain/hbm</value>
</list>
</property>


and now i am using AnnotationSessionFactoryBean ,and do not want modify so many java files,and want to use these hibernate xml files.and the sessionFactory like below:

Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>         
<value>XX.XX.model.Resource</value>
</list>
</property>
      
<property name="mappingDirectoryLocations">
<list>                  
<value>classpath*:/XX/common/domain/hbm</value>
</list>
</property>


but in origin manager files there is a method
Code:
public List getAllItemcat(Integer provinceId){
    return getHibernateTemplate().find(" from XX.common.domain.Itemcat
where provinceId="+provinceId+" order by itemcatId desc");
  }


the hibernate sql become:

Code:
select itemcat0_.ITEM_CAT_ID as ITEM1_2_, itemcat0_.ITEM_CAT_NAME as ITEM2_2_,
itemcat0_.PROVINCE_ID as PROVINCE3_2_, itemcat0_.LANG_ID as LANG4_2_, itemcat0_.ZJ_ID as ZJ5_2_
from t_item_cat itemcat0_
where (provinceId=19 ) order by  itemcatId desc


just said in the clause the provinceId and itemcatId can not become the table colunm name province_id and item_cat_it,and
in LocalSessionFactoryBean style it work correctly!

what is wrong with it?how should i do??

thanks a lot


ps:

when give alias to the entity,and the clause add the alias,it can run correctly

public List getAllItemcat(Integer provinceId){
return getHibernateTemplate().find(" from XX.common.domain.Itemcat a
where a.provinceId="+provinceId+" order by a.itemcatId desc");
}

but
"select new XX.domain.entity(a.id,a.name) from XX.common.domain.Itemcat a"
can not run correctly,I really do not know what is the wrong with it


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.