I m having this strange problem where my merge() or my persist() functions are not being reflected in the database. My JdbcProductDao.java:
@Repository("productDao")
public class JdbcProductDao implements ProductDao {
@PersistenceContext
private EntityManager entityManager;
public JdbcProductDao(){
}
public Product getReference(Product product){
return getEntityManager().getReference(product.getClass(),product.getId());
}
public void persist(Product product){
getEntityManager().persist(product);
}
public EntityManager getEntityManager(){
return entityManager;
}
public void setEntityManager(EntityManager entityManager){
this.entityManager = entityManager;
}
@SuppressWarnings("unchecked")
public List<Product> getProductList(){
return getEntityManager().createQuery("from Product").getResultList();
}
public void saveProduct(Product product){
persist(product);
}
}
My getProductList()
works fine however my saveProduct doesn t do anything to the database.
Can you think of any reasons why this would be happening?
I ll post my Product.java file:
@Entity
@Table(name="products")
public class Product implements Serializable {
@Id
@Column(name = "id")
private int id;
@Column(name = "description")
private String description;
@Column(name = "price")
private Double price;
public void setId(int i) {
id = i;
}
public int getId() {
return id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("Description: " + description + ";");
buffer.append("Price: " + price);
return buffer.toString();
}
}