re: Struts2.1.6+Spring2.5.6+Hibernate3.3.1全注解實(shí)例詳解(二)[未登錄]
2012-03-11 14:31 |
我自己搭了一個(gè)框架:用Sping3.1.0 和hibernate 1.5.6 Model注解我寫好了
package com.test.service;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.warrior.model.SySUser;
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private SessionFactory sessionFactory;
public boolean checkLogin(String userName, String password) {
if("warrior".equals(userName) && "123456".equals(password))
return true;
else
return false;
}
public void save(SySUser user) {
Session s = sessionFactory.openSession();
try{
Transaction t = s.beginTransaction();
t.begin();
s.save(user);
t.commit();
} catch(Exception e){
e.printStackTrace();
}finally{
s.close();
}
}
}
SessionFactory 的配置:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.test.model.SySUser</value>
</list>
</property>
</bean>
服務(wù)器啟動(dòng)沒有錯(cuò),但保存對(duì)象的時(shí)候就報(bào)錯(cuò)
org.hibernate.MappingException: Unknown entity
Email : sky402100@126.com
求指導(dǎo)
回復(fù) 更多評(píng)論