- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用以下代码来初始化我的 Hibernate 搜索索引:
EntityManager em = ...
FullTextEntityManager fullTextEM = Search.getFullTextEntityManager(em);
fullTextEM.createIndexer().startAndWait();
现在,当我执行这段代码时,出现以下异常:
ERROR: HSEARCH000058: HSEARCH000116: Unexpected error during MassIndexer operation
org.hibernate.TransientObjectException: cannot lock an unsaved transient instance: com.example.hs.model.Division
at org.hibernate.event.internal.DefaultLockEventListener.onLock(DefaultLockEventListener.java:75)
at org.hibernate.internal.SessionImpl.fireLock(SessionImpl.java:724)
at org.hibernate.internal.SessionImpl.fireLock(SessionImpl.java:717)
at org.hibernate.internal.SessionImpl.access$1700(SessionImpl.java:170)
at org.hibernate.internal.SessionImpl$LockRequestImpl.lock(SessionImpl.java:2276)
at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.indexAllQueue(EntityConsumerLuceneWorkProducer.java:130)
at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.run(EntityConsumerLuceneWorkProducer.java:102)
at org.hibernate.search.batchindexing.impl.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:112)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
在这种情况下,com.example.hs.model.Division
类确实有两个 @Transient
注释用于从 计算返回值的方法 HashMap
。 HashMap
通过 Hibernate 检索如下:
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "division_id", referencedColumnName = "id")
@MapKey(name = "language")
@Field(name="name")
@FieldBridge(impl = com.example.hs.search.LanguageDivisionTextBridge.class)
protected Map<Language, DivisionText> getDivisionTextMap() {
return divisionTextMap;
}
如您所见,我正在使用自定义 FieldBridge
来帮助映射。 DivisionText
类也标有 @Indexed
注释并已成功建立索引。
完整的源代码集可以在以下位置找到:
https://github.com/jsvazic/hibernate-search-example
如有任何帮助,我们将不胜感激。
最佳答案
您的问题与 Foo,
中的 @Transient
注释无关,而是与整个 Foo
相关。索引过程中的一些代码试图调用 Session.lock(foo),
但此时 foo
仍然只是一个普通对象,在被分配给使用 Session.save
或 Session.persist
的 session 。如 here 所述,将 cascade=PERSIST
参数添加到父对象中 foo
字段的注释中可能会有所帮助.
关于hibernate - 创建初始索引时出现 TransientObjectException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10035825/
我正在使用以下代码来初始化我的 Hibernate 搜索索引: EntityManager em = ... FullTextEntityManager fullTextEM = Search.get
这与this post有关,您将在其中找到许多我的配置。 ldap用户被映射到数据库用户表,并且条目创建良好。然后,userDetails尝试从主用户类获取权限,从而导致以下异常: 2014-01-3
我试图在 Tridion 中发布一个页面,并在“提交部署”阶段不断收到以下 NHibernate 异常: Retried 10 times to commit and failed, org.hibe
我有一个错误让我发疯。当我尝试创建新对象时,Hibernate 返回错误: object references an unsaved transient instance - save the tra
当我尝试更新对象时出现以下异常: org.hibernate.TransientObjectException: object references an unsaved transient inst
我有两个类: Employee.java @Entity @Table public class Employee { @Id @GeneratedValue private
每当我进行连续保存时,我都会收到 TransientObjectException;我在第一次保存或刷新屏幕/页面时没有收到此错误。这让我很困惑,因为一旦对象被成功保存,它就不应该是暂时的,因为它在我
简单的Groovy \ Grails代码: def start = { source.save() def result = getJson(hotelSite, en
当我尝试保留对象 Municipio 时,出现异常。Municipio 与 Provincia 具有多音关系,与 Sector 具有多对一关系。Provincia 不能为 null,但 Sector
我有一个像这样的对象层次结构(忽略所有字段,如 id、setters/getters 等): @Entity class A { @OneToOne(cascade=CascadeType.A
我使用的是 Hibernate 4.1,每当我尝试存储已添加到对象集合中的临时标记列表时,我都会收到以下异常。 org.hibernate.TransientObjectException: obje
我有两个名为学生和类(class)的实体,它们具有多对多关系。正如我在this中读到的那样文章中我们可以调用 save 方法来保存事务中的相关实体,或者一旦 session 被刷新它就会被保存。我也明
@Entity @Table(name = "PE_HOME") @Cacheable public class Home extends DefEntity implements IHome {
我的应用程序通过套接字连接接收频繁的远程事件,每次都启动一个新线程,后续操作通常每次都会触发相同的对象图进行保存,并带有一个锁定的静态 session 。但是在执行保存时,有时会收到新的更新,这会将新
我正在将 jpa 与 play 框架一起使用。我有一个实体 JobseekerDetails @Entity public class JobseekerDetails { @Id @
使用 spring-boot (2.1.8.RELEASE),我有一个看起来像这样的测试: @Test @Transactional public void myTest()
在使用 hibernate 更新记录时,我不断收到以下异常,我对 hibernate 非常陌生,请查看该异常跟踪 java.lang.IllegalStateException: org.hibern
我在一个使用 Hibernate Entity Manager 的项目中工作,一切都很好,直到我开始在我们的实体中实现乐观锁。 例如,我们有以下命名查询返回一个人的地址: @NamedQuery(na
我在 hibernate 状态下有一对多关系,如下所示: class Container { @OneToMany( cascade = {CascadeType.ALL}, mappedBy
我有 2 个类 Employe(id,Nom,solde...) 和 Conge(id,duree,...) 我使用注释,并在我的测试类中放置此代码来更新员工的“solde”: Employe p=n
我是一名优秀的程序员,十分优秀!