簡體   English   中英

如何在休眠注釋中實現組件映射

[英]How to implement Component mapping in hibernate annotations

嗨,我在這里嘗試將hbm文件映射轉換為休眠注釋,在這里我發現了類似

<component name="timeSlot" class="model.calendar.TimeSlot">
  <property name="startTime" column="app_start_time" />
  <property name="endTime" column="app_end_time" />
</component>

appointment.hbm.xml文件中。

和我的appointment.java類的模態類

public class Appointment extends BaseDo implements Delivery {
  private TimeSlot timeSlot;       
}

我的timeslot.java模態看起來像

public class TimeSlot extends BaseDo {

  Date startTime;
  Date endTime;
}

因此,在這里,我不了解如何在我搜索過的約會中對約會中的時區進行注釋,並且我理解我需要使用@Embedded@Embeddable標簽,但不確定如何使用,任何人都可以建議我這樣做。

你嘗試過這樣的事情嗎?

public class Appointment extends BaseDo implements Delivery {
    private TimeSlot timeSlot;   

    @Embedded
    public TimeSlot getTimeSlot() {
        return timeSlot;
    }

    public void setTimeSlot (TimeSlot timeSlot) {
        this.timeSlot= timeSlot;
    }
}

@Embeddable
public class TimeSlot extends BaseDo {

  Date startTime;
  Date endTime;

  @Column 
  public Date getStartTime(){
      return startTime
  }

  public void setStartTime(Date startTime){
      this.startTime = startTime;
  } 

  @Column 
  public Date getEndTime(){
      return endTime
  }

  public void setEndTime(Date endTime){
      this.endTime = endTime;
  } 

}

暫無
暫無

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

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