修复Hibernate错误“使用相同的实体名称两次” [英] Fix for Hibernate error "Use of the same entity name twice"
本文介绍了修复Hibernate错误“使用相同的实体名称两次”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是使用相同的实体名称两次。
解决方案
当有多个具有相同类名或明确名称的@Entity时,会发生此异常。
要解决这个问题,您必须为每个实体设置不同的显式名称。
错误案例示例:
package A;
@实体
class单元格{
...
}
程序包B;
@Entity
class Cell {
...
}
解决方案示例:
package A;
@Entity(name =a。 Cell)
class Cell {
...
}
软件包B;
@Entity(name =b.Cell)
class Cell {
...
}
因此,要在HQL中使用它们,您必须编写
... createQuery(from aCell)...
How you fix the following Hibernate error:
What does "Use of the same entity name twice".
解决方案
This exception occures when you have more then one @Entity with the same class's name or explicit name. To fix the issue you have to set different explicit names for each entity.
Example of error case:
package A;
@Entity
class Cell{
...
}
package B;
@Entity
class Cell{
...
}
Solution example: package A;
@Entity(name="a.Cell")
class Cell{
...
}
package B;
@Entity(name="b.Cell")
class Cell{
...
}
So, to use them in HQL you have to write
...createQuery("from a.Cell")...
这篇关于修复Hibernate错误“使用相同的实体名称两次”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文