this is my UserDAO
Code:
package org.innolab.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.innolab.entity.User;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class UserDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(UserDAO.class);
public void save(User transientInstance) {
log.debug("saving User instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
}
and here is my UserServiceImpl
Code:
package org.innolab.service.impl;
import java.util.List;
import org.innolab.dao.UserDAO;
import org.innolab.entity.User;
import org.innolab.service.UserService;
public class UserServiceImpl implements UserService {
public UserDAO userDAO;
public void saveUser(User user) {
this.userDAO.save(user);
}
}
and here is my UserActioncode
Code:
User user = new User(username, password, email);
userService.saveUser(user);
and here is my User entity
Code:
package org.innolab.entity;
import java.util.HashSet;
import java.util.Set;
/**
* User entity. @author MyEclipse Persistence Tools
*/
public class User implements java.io.Serializable {
// Fields
private Integer id;
private String name;
private String password;
private String email;
private String photo;
private Set blogs = new HashSet(0);
// Constructors
/** default constructor */
public User() {
}
/** minimal constructor */
public User(String name, String password, String email) {
this.name = name;
this.password = password;
this.email = email;
}
/** full constructor */
public User(String name, String password, String email, String photo,
Set blogs) {
this.name = name;
this.password = password;
this.email = email;
this.photo = photo;
this.blogs = blogs;
}
// Property accessors
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoto() {
return this.photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public Set getBlogs() {
return this.blogs;
}
public void setBlogs(Set blogs) {
this.blogs = blogs;
}
}
and here is my console
Code:
Hibernate: select user0_.id as id0_, user0_.name as name0_, user0_.password as password0_, user0_.email as email0_, user0_.photo as photo0_ from innolab.user user0_ where user0_.name=?
Hibernate: insert into innolab.user (name, password, email, photo) values (?, ?, ?, ?)
can anbody help me out with this ? thanks