Я не нашел ответов на этот вопрос, который также задают на многих других форумах.Хотя у меня есть таблицы IAS_FORM_BKT_BAYI и IAS_FORM_BKT_BAYI_SO, представленные в базе данных, с аннотированным классом сущностей (исходный код ниже исключения), я получаю это исключение в моем приложении на основе JSF и Hibernate:
org.hibernate.AnnotationException: Cannot find the expected secondary table: no IAS_FORM_BKT_BAYI available for net.ozar.bpm.entity.bkt.Bayi
org.hibernate.cfg.Ejb3Column.getJoin(Ejb3Column.java:293)
org.hibernate.cfg.Ejb3Column.getTable(Ejb3Column.java:272)
org.hibernate.cfg.annotations.SimpleValueBinder.make(SimpleValueBinder.java:222)
org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1898)
org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1279)
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226)
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
net.ozar.bpm.util.EntityUtil.getEntityManagerFactory(EntityUtil.java:13)
net.ozar.bpm.util.EntityUtil.getEntityManager(EntityUtil.java:21)
net.ozar.bpm.servisler.CalisanJpaController.getEntityManager(CalisanJpaController.java:31)
net.ozar.bpm.servisler.CalisanJpaController.getPersonId(CalisanJpaController.java:120)
net.ozar.bpm.web.jsfmanaged.LoginBean.oturumAc(LoginBean.java:122)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.el.parser.AstValue.invoke(AstValue.java:191)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
javax.faces.component.UICommand.broadcast(UICommand.java:387)
org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
net.ozar.bpm.web.filters.RestrictPageFilter.doFilter(RestrictPageFilter.java:180)
Bayi.java
@Entity
@Table(name = "IAS_FORM_BKT_BAYI")
@SecondaryTable(name="IAS_FORM_BKT_BAYI_SO", pkJoinColumns = @PrimaryKeyJoinColumn(name="CUSTOMER_ID"))
public class Bayi implements Serializable {
private static final long serialVersionUID = 8681843504687728382L;
@Id
@Basic(optional = false)
@NotNull
@Column(table="IAS_FORM_BKT_BAYI", name = "CUSTOMER_ID", nullable = false)
private Integer customerId;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 30)
@Column(table="IAS_FORM_BKT_BAYI", name = "CUSTOMER_NUMBER", nullable = false, length = 30)
private String customerNumber;
@Size(max = 50)
@Column(table="IAS_FORM_BKT_BAYI", name = "CUSTOMER_NAME", length = 50)
private String customerName;
@Size(max = 50)
@Column(table="IAS_FORM_BKT_BAYI", name = "VERGI_DAIRESI", length = 50)
private String vergiDairesi;
@Size(max = 20)
@Column(table="IAS_FORM_BKT_BAYI", name = "VERGI_NO", length = 20)
private String vergiNo;
@Size(max = 150)
@Column(table="IAS_FORM_BKT_BAYI", name = "OPERATOR", length = 150)
private String operator;
@Column(table="IAS_FORM_BKT_BAYI_SO", name = "SOZLESME", length = 5)
private String sozlesme;
@Column(table="IAS_FORM_BKT_BAYI_SO", name = "SOZLESME_UYGUN", length = 5)
private String sozlesmeUygun;
@Column(table="IAS_FORM_BKT_BAYI_SO", name = "KEFIL_IMZA", length = 5)
private String kefilImza;
@Column(table="IAS_FORM_BKT_BAYI_SO", name = "ACIKLAMA", length = 2000)
private String aciklama;
public Bayi() {
}
// getters and setters
// ...
}
Что я действительно пытаюсь добиться, так это получить набор результатов, который я получаю, выполнив следующий запрос, сопоставленный с объектом Bayi (entity):
SELECT B.CUSTOMER_ID, B.CUSTOMER_NUMBER, B.CUSTOMER_NAME, B.VERGI_DAIRESI,
B.VERGI_NO, C.SOZLESME, C.SOZLESME_UYGUN, C.KEFIL_IMZA, C.ACIKLAMA FROM
IAS_FORM_BKT_BAYI B LEFT JOIN IAS_FORM_BKT_BAYI_SO C ON B.CUSTOMER_ID =
C.CUSTOMER_ID WHERE ORG_ID = 102