1
我有使用JPA合併對象的問題。我的代碼是這樣的。jpa合併不起作用
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();
我的實體是
@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;
當我運行我的測試情況下,合併不更新我的FILTERNAME對象以及JPA不火在控制檯中的任何查詢。
任何人都可以請諮詢我做錯了什麼?