最近在做一个维护项目,想启用他们之前的类库,在实体类层定义了相同的实体类(当然,包路径是不相同的),在启动项目的时候报错:
Use of the same entity name twice
解决该报错的方法很简单:
比如我的类名是CarSource,我再该类名下的@Entity新增命名name即可
@Entity(name="new.CarSource")
查询的时候注意下就行了代码如下
...createQuery("from new.CarSource")...
这样就解决了Use of the same entity name twice的问题了,而且可以不用去动之前的类