簡體   English   中英

Hibernate: Unknown mappingBy in: ,引用的屬性未知:

[英]Hibernate: Unknown mappedBy in: , referenced property unknown:

我正在嘗試映射我的表以使用 Hibernate,但是當我啟動測試時出現此錯誤。

    Nov 04, 2015 5:17:40 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager 
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
Nov 04, 2015 5:17:41 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.8.Final}
Nov 04, 2015 5:17:41 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Nov 04, 2015 5:17:41 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Nov 04, 2015 5:17:41 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Nov 04, 2015 5:17:41 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Nov 04, 2015 5:17:41 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Nov 04, 2015 5:17:41 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Nov 04, 2015 5:17:41 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Nov 04, 2015 5:17:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [oracle.jdbc.OracleDriver] at URL [jdbc:oracle:thin:@example.com:1521/c0fspost0]
Nov 04, 2015 5:17:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=user, password=****}
Nov 04, 2015 5:17:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
Nov 04, 2015 5:17:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
Nov 04, 2015 5:17:44 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
SessionFactory creation failed.org.hibernate.AnnotationException: Unknown mappedBy in: it.addvalue.mam.fpk.alertengine.mapping.TEvents.TEventsDetails, referenced property unknown: it.addvalue.mam.fpk.alertengine.mapping.TEventsDetails.tEvents

這是我的映射類

package it.addvalue.mam.fpk.alertengine.mapping; // default package
// Generated Nov 4, 2015 3:02:28 PM by Hibernate Tools 3.4.0.CR1

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * TEvents generated by hbm2java
 */
@Entity
@Table(name = "T_EVENTS")
public class TEvents implements java.io.Serializable {

    private BigDecimal eventId;
    private Timestamp tsEvent;
    private String object;
    private String objectFase;
    private String tipoEvento;
    private Set<TEventsSent> TEventsSents = new HashSet<TEventsSent>(0);
    private TEventsDetails TEventsDetails;

    public TEvents() {
    }

    public TEvents(BigDecimal eventId, Timestamp tsEvent, String object,
            String objectFase, String tipoEvento) {
        this.eventId = eventId;
        this.tsEvent = tsEvent;
        this.object = object;
        this.objectFase = objectFase;
        this.tipoEvento = tipoEvento;
    }

    public TEvents(BigDecimal eventId, Timestamp tsEvent, String object,
            String objectFase, String tipoEvento,
            Set<TEventsSent> TEventsSents, TEventsDetails TEventsDetails) {
        this.eventId = eventId;
        this.tsEvent = tsEvent;
        this.object = object;
        this.objectFase = objectFase;
        this.tipoEvento = tipoEvento;
        this.TEventsSents = TEventsSents;
        this.TEventsDetails = TEventsDetails;
    }

    @Id
    @Column(name = "EVENT_ID", unique = true, nullable = false, scale = 0)
    public BigDecimal getEventId() {
        return this.eventId;
    }

    public void setEventId(BigDecimal eventId) {
        this.eventId = eventId;
    }

    @Column(name = "TS_EVENT", nullable = false)
    public Timestamp getTsEvent() {
        return this.tsEvent;
    }

    public void setTsEvent(Timestamp tsEvent) {
        this.tsEvent = tsEvent;
    }

    @Column(name = "OBJECT", nullable = false, length = 100)
    public String getObject() {
        return this.object;
    }

    public void setObject(String object) {
        this.object = object;
    }

    @Column(name = "OBJECT_FASE", nullable = false, length = 100)
    public String getObjectFase() {
        return this.objectFase;
    }

    public void setObjectFase(String objectFase) {
        this.objectFase = objectFase;
    }

    @Column(name = "TIPO_EVENTO", nullable = false, length = 3)
    public String getTipoEvento() {
        return this.tipoEvento;
    }

    public void setTipoEvento(String tipoEvento) {
        this.tipoEvento = tipoEvento;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "TEvents")
    public Set<TEventsSent> getTEventsSents() {
        return this.TEventsSents;
    }

    public void setTEventsSents(Set<TEventsSent> TEventsSents) {
        this.TEventsSents = TEventsSents;
    }

    @OneToOne(fetch = FetchType.LAZY, mappedBy = "tEvents")
    public TEventsDetails getTEventsDetails() {
        return this.TEventsDetails;
    }

    public void setTEventsDetails(TEventsDetails TEventsDetails) {
        this.TEventsDetails = TEventsDetails;
    }

}

另一個

package it.addvalue.mam.fpk.alertengine.mapping; // default package
// Generated Nov 4, 2015 3:02:28 PM by Hibernate Tools 3.4.0.CR1

import java.math.BigDecimal;
import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * TEventsDetails generated by hbm2java
 */
@Entity
@Table(name = "T_EVENTS_DETAILS")
public class TEventsDetails implements java.io.Serializable {

    private BigDecimal eventId;
    private TEvents TEvents;
    private Blob detail;

    public TEventsDetails() {
    }

    public TEventsDetails(TEvents TEvents, Blob detail) {
        this.TEvents = TEvents;
        this.detail = detail;
    }

    @GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "TEvents"))
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "EVENT_ID", unique = true, nullable = false, scale = 0)
    public BigDecimal getEventId() {
        return this.eventId;
    }

    public void setEventId(BigDecimal eventId) {
        this.eventId = eventId;
    }

    @OneToOne(fetch = FetchType.LAZY)
    @PrimaryKeyJoinColumn
    public TEvents getTEvents() {
        return this.TEvents;
    }

    public void setTEvents(TEvents TEvents) {
        this.TEvents = TEvents;
    }

    @Column(name = "DETAIL", nullable = false)
    public Blob getDetail() {
        return this.detail;
    }

    public void setDetail(Blob detail) {
        this.detail = detail;
    }

}

有什么建議可以解決這個問題嗎? 對我來說,映射是正確的,也是因為它是由休眠自動生成的

好吧! 我認為這是一個Hibernate BUG。 我找到了這個

https://hibernate.atlassian.net/browse/HHH-5695

您應該將 TEvents 變量名稱從 TEvents 更改為 tEvents :

public class TEventsDetails implements java.io.Serializable {

.....

private TEvents tEvents;

public TEvents getTEvents() {
    return this.tEvents;
}

public void setTEvents(TEvents TEvents) {
    this.tEvents = TEvents;
}
.....

}

請在class TEventsDetails以下行中定義列的名稱,因為您已經定義了 TEventsDetails 表的哪些列與 TEvents 表相關聯。

@JoinColumn(name = "EVENT_ID")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM