Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use Hibernate JPA annotation when extending HibernateDaoSupport?

 
Maya Pillai
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Pie
Posts: 1058
24
Android C++ Java Linux PHP Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic