I made some progress, but have another exception :
Quote:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.MappingException: Unknown entity: com.stockdomain.domain.Stock
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Meanwhile, I'll post the changes I did.
I added "<property name="annotatedClasses">" into the session bean Id.
the context xml
Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.stockdomain.domain.Stock</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
I also removed @Transactional annotation on the method in StockDAOImpl.java.
the class looks like this now.
Code:
package com.stockdomain.domain.stock;
import java.util.HashMap;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.stockdomain.util.DbUtilities;
@Repository("stockDao")
@Transactional
public class StockDAOImpl implements StockDAO {
@Autowired
SessionFactory sessionFactory;
@SuppressWarnings("unchecked")
@Transactional
public List<Stock> getRecord() {
String sql = "SELECT * FROM stock ";
Query query = sessionFactory.getCurrentSession().createSQLQuery(sql).addEntity(Stock.class);
return query.list();
}
}
I'll post a new thread for this new exception.