简体   繁体   中英

Hibernate session not working in spring

I have a very strange issue with Spring and Hibernate. I have everything configured, my database.properties, the hibernate.xml and datasource.xml as I saw in the tutorials, but connection isn't working.

When I change the connection properties it does not change anything.

My hibernate.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- Hibernate session factory -->
<bean id="sessionFactory" 
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

    <property name="dataSource">
      <ref bean="dataSource"/>
    </property>

    <property name="hibernateProperties">
       <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
         <prop key="hibernate.show_sql">true</prop>
       </props>
    </property>

    <property name="packagesToScan">
        <list>
            <value>pl.devell.model</value>
        </list>
    </property>

</bean>

My Dao classes are working but not returning any results.

I figured it out.

pl.devell.model was not the correct name of the package to scan.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM