File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes How to use Hibernate JPA annotation when extending HibernateDaoSupport? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to use Hibernate JPA annotation when extending HibernateDaoSupport?" Watch "How to use Hibernate JPA annotation when extending HibernateDaoSupport?" New topic
Author

How to use Hibernate JPA annotation when extending HibernateDaoSupport?

Maya Pillai
Ranch Hand

Joined: Jul 17, 2008
Posts: 60
How to use Hibernate JPA annotation when extending HibernateDaoSupport?
The below code throws an exception - Unknown entity:
-------------
public class CustomerDaoHibernateImpl extends HibernateDaoSupport implements CustomerDao {


public void saveAccount(User user) {
System.out.println("CustomerDaoHibernateImpl save");

this.getHibernateTemplate().save(user);

}
---------------------

@Entity
@Table (name="User")
public class User {
private long id;
private String password;
@Id
@GeneratedValue
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Column (name="password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 475
    
    3
Hi,

I'm not sure you can mix the two. Since you're using JPA, you're better of using it throughout - so extend JpaDaoSupport, not HibernateDaoSupport. Also ensure that the LocalSessionFactoryBean's configurationClass field is set to AnnotationConfiguration.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use Hibernate JPA annotation when extending HibernateDaoSupport?
 
Similar Threads
Hibernate
how to use Xdoclet in standalone application
when is Transaction used in hibernate?
hbm file version working but annotation not
How to Set Primary / Foreign Keys or Relationships with Hibernate 3 / JPA Tables?