好吧,我有一个带有@MappedSupperClass
注释的外部JAR,我试图从这个外部JAR扩展一个类。见下文:
@Entity
@NamedQueries(value = {
@NamedQuery(name = "AgendaDentista.findByDentista", query = "SELECT c FROM AgendaDentista c "
+ "JOIN FETCH c.diaSemana "
+ "JOIN FETCH c.dentista "
+ "WHERE c.dentista.id = :idDentista"),
@NamedQuery(name = "AgendaDentista.findByDentistaWhereDiaSemanaAndHora", query = "SELECT c FROM AgendaDentista c "
+ "JOIN FETCH c.diaSemana "
+ "JOIN FETCH c.dentista "
+ "WHERE c.dentista.id = :idDentista "
+ "AND c.diaSemana.codigo = :diaSemana "
+ "AND :hora BETWEEN c.horaInicio AND c.horaFim") })
@Table(name = "agenda_dentista")
public class AgendaDentista extends AbstractBean {
我的AbstractBean
类位于另一个包中(在外部jar中)。但是我在@Entity
注释中遇到以下错误:
实体没有定义主键属性
我已经在构建路径中导入JAR并将其放入Deployment Assembly(Eclipse)中。
我尝试在persistence.xml中使用jar文件,但是我收到错误:jar文件无法解析。
<persistence-unit name="odontonewPU">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jar-file>jwebbuild-1.0.jar</jar-file>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.cache.use_second_level_cache" value="false" />
<property name="hibernate.cache.use_query_cache" value="false" />
<property name="hibernate.jdbc.batch_size" value="50" />
</properties>
</persistence-unit>
解
经过大量搜索,我得到了解决方案。这看起来像是一个Eclipse BUG,因为我必须将我的AbstractBean类放在persistence.xml中并强制eclipse找到它。
请参阅:
<class>br.com.jwebbuild.bean.AbstractBean</class>
所以,现在eclipse停下来说我的班级没有定义主键属性