小编mwa*_*ter的帖子

在一个方法中调用persist()flush()和refresh()以正确的方式持久化实体吗?

我的目的是在同一个业务调用中将一个新持久化的实体返回给客户端,以获得进一步业务逻辑所需的生成主键.调用finder方法再次按名称或某些已知属性查找实体将导致我想避免的第二次服务器往返(时间就是金钱;-).所以我创建了以下方法:

public Entity persist(Entity entity) {
    em.persist(entity);
    em.flush();
    em.refresh(entity);
    // now the entity has an id
    return entity;
}
Run Code Online (Sandbox Code Playgroud)

但现在我想知道这是否是正确的方法.某种程度上感觉"奇怪".JPA规范对此非常清楚:EntityManager的persist()方法返回void - 对我来说听起来像"火与忘".但我的客户端依赖于主键.我的方法有替代解决方案吗?这是我的最佳做法吗?你怎么看?

persistence jpa

11
推荐指数
1
解决办法
2万
查看次数

为什么在WebSphere Liberty Profile启动时找不到清单类路径条目?

使用WebSphere Liberty Profile(版本2013.11.0.0 - 8.5.5.Next Alpha和扩展内容)启动我的应用程序时,会出现很多警告:

W SRVE9967W: The manifest class path dhbcore.jar can not be found in jar file wsjar:file:[blablabla] or its parent.
W SRVE9967W: The manifest class path jms.jar can not be found in jar file wsjar:file:[blablabla] or its parent.
W SRVE9967W: The manifest class path com.ibm.mq.jmqi.jar can not be found in jar file wsjar:file:[blablabla] or its parent.
W SRVE9967W: The manifest class path dhbcore.jar can not be found in jar file wsjar:file:[blablabla] or its parent.
W SRVE9967W: …
Run Code Online (Sandbox Code Playgroud)

manifest classpath websphere-liberty

6
推荐指数
1
解决办法
8077
查看次数