I have a problem with merging of objects using JPA. My code goes like this.
EntityTransaction entr = em.getTransaction();
entr.begin();
Query q = em
.createQuery("SELECT filterName FROM IbFilterName filterName where"
+ " filterName.filterId = 42352 ");
List<IbFilterName> filterNameList = q.getResultList();
for(IbFilterName filterName : filterNameList){
String values = filterName.getFilterValues();
filterName.setFilterValues(values+"Saranya");
em.merge(filterName);
}
entr.commit();
And my entity is
@Id
@SequenceGenerator(name = "IB_FILTER_NAMES_FILTERID_GENERATOR", sequenceName = "IB_LOGIN_HISTORY_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "IB_FILTER_NAMES_FILTERID_GENERATOR")
@Column(name = "FILTER_ID")
protected long filterId;
@Column(name = "EXTERNAL_USER")
protected String externalUser;
@Column(name = "FILTER_NAME")
protected String filterName;
@Column(name = "FILTER_VALUES")
protected String filterValues;
// bi-directional many-to-one association to IbPortfolioFilterMapping
@OneToMany(mappedBy = "ibFilterName")
private Set<IbPortfolioFilterMapping> ibPortfolioFilterMappings;
When I run my test case, merge doesn't update my filtername object as well JPA does not fire any query in the console.
Can any one please advice what am I doing wrong??