I'm attempting to update an Entity called User and although the changes are made to the user object successfully, when I attempt to save the user (via the update method) to the database it does not persist. Other functions of this class work such as get(). No exceptions appear.
-----------------------------AbstractDAOImpl.class-----------------------------------
@Transactional
@Repository
public abstract class AbstractDaoImpl<T> {
private static final Logger LOG = Logger.getLogger(StockController.class);
private Class currentClass;
@PersistenceContext(type = PersistenceContextType.EXTENDED)
protected EntityManager entityManager;
protected void setThisClass(Class currentClass) {
this.currentClass = currentClass;
}
@SuppressWarnings("unchecked")
public T get(String id) {
return (T) entityManager.find(currentClass, id);
}
public void delete(String id) {
entityManager.remove(get(id));
}
public void update(T t) {
entityManager.merge(t);
entityManager.flush();
}
@SuppressWarnings("unchecked")
public List list(String tableName) {
return entityManager.createQuery("from " + tableName, currentClass).getResultList();
}
}
------------------------Application.properties------------------------
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.username=SYSTEM
spring.datasource.password=password
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:XE
spring.jpa.database-platform=Oracle11gDialect
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle8iDialect
spring.resources.static-locations=file:src/main/resources/
spring.resources.cache-period=0
spring.thymeleaf.cache=false
spring.http.converters.preferred-json-mapper=jackson
security.basic.enabled=false
security.headers.content-type=true
security.enable-csrf=true
security.basic.path=/**
I have made various attempts to implement other fixes listed on here with no luck, including getting the transaction from the entity manager beginning and ending it with the current contents of update() in between. If other information is needed such as the entity classes please let me know and I'll edit my post.