首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

应该是一个Spring多个配置文件有关问题,访问Hibernate的映射文件时报错

2012-07-16 
应该是一个Spring多个配置文件问题,访问Hibernate的映射文件时报错我有多个Spring配置文件公共的配置文件

应该是一个Spring多个配置文件问题,访问Hibernate的映射文件时报错
我有多个Spring配置文件公共的配置文件添加Hibernate的映射文件
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
destroy-method="destroy">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_sql">true</prop>
</props>
</property>
<!-- mappingLocations属性用来列出指定路经的全部映射文件 -->
<property name="mappingLocations">
<value>cn\jboa\entity\*.hbm.xml</value>
</property>
</bean>

这是它报的错
org.springframework.orm.hibernate3.HibernateQueryException: SysEmployee is not mapped [from SysEmployee as s where s.sn=?]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: SysEmployee is not mapped [from SysEmployee as s where s.sn=?]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)

org.hibernate.hql.ast.QuerySyntaxException: SysEmployee is not mapped [from SysEmployee as s where s.sn=?]

这是我写的JUnit并测试通过 
private static SysEmployeeDao sysEmployeeDao;
@AfterClass
public static void testDownAfterClass() throws Exception {
SysEmployee sysEmployee = new SysEmployee();
sysEmployee.setSn("100001");
sysEmployee.setPassword("123");
System.out.println(sysEmployeeDao.login(sysEmployee));
}

@Before
public void setUp() throws Exception {
String[] string = {"applicationContext.xml","jBOASpringContext1.xml"};
ApplicationContext context = new ClassPathXmlApplicationContext(string);
sysEmployeeDao = (SysEmployeeDao)context.getBean("sysEmployeeDao");
}
它能通过是不是也就说明Spring可以通过mappingLocations <value>cn\jboa\entity\*.hbm.xml</value> 找见对应的映射文件



[解决办法]
恩 !这个写法很不错啊!顶

热点排行