如果我正在打印会话对象,则所需的输出不正确,即-
SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=org.hibernate.engine.spi.ExecutableList@7164ee40 updates=org.hibernate.engine.spi.ExecutableList@2d80b7f deletions=org.hibernate.engine.spi.ExecutableList@560d3d76 orphanRemovals=org.hibernate.engine.spi.ExecutableList@10fbc8b2 collectionCreations=org.hibernate.engine.spi.ExecutableList@463b2203 collectionRemovals=org.hibernate.engine.spi.ExecutableList@47a5a48 collectionUpdates=org.hibernate.engine.spi.ExecutableList@3b23213c collectionQueuedOps=org.hibernate.engine.spi.ExecutableList@75d3c0b2 unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])
如果这样打印,我认为很有价值-
SessionImpl(PersistenceContext[entityKeys=[EntityKey[com.mode
l.Entity#1]],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[
] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
我的Shop课程是-
@Entity
@Table(name = "shops")
public class Shop {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "shop_domain")
private String shopDomain;
@JsonFormat(pattern="dd-MM-yyyy")
private Timestamp orderSyncDate;
@OneToOne(mappedBy = "shop", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JsonManagedReference
private NetsuiteConfig netsuiteConfig;
我只是将一些数据设置为shop类对象,尝试保存到DB中 ,对象保留ID,即DB中已经存在,查询为- 会话factory.getCurrentSession()。update(shop); 这实际上不会更新db中的值,我不知道原因,为什么?
答案 0 :(得分:1)
您必须提交更新,以使更改传播到数据库:
loadPosition
参考文献: