1
我有一個數據庫表,它有兩個colums一起指定一個事件的開始時間和結束時間。Joda時間間隔不能通過休眠索引
我使用Hibernate來訪問數據庫並檢索和存儲數據。
這個表的hibernate Model類看起來像這樣。
public class EstateViewing implements Comparable<EstateViewing> {
private Long id;
private Estate estate;
private Interval timeInterval;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "estate_viewing_generator")
@SequenceGenerator(sequenceName = "estate_viewing_sequence", name = "estate_viewing_generator")
public Long getId() {
return id;
}
protected void setId(Long id) {
this.id = id;
}
@ManyToOne
public Estate getEstate() {
return estate;
}
public void setEstate(Estate estate) {
this.estate = estate;
}
@Columns(columns = { @Column(name = "timeIntervalStart"), @Column(name = "timeIntervalEnd") })
@Type(type = "org.joda.time.contrib.hibernate.PersistentInterval")
public Interval getTimeInterval() {
return timeInterval;
}
public void setTimeInterval(Interval timeInterval) {
this.timeInterval = timeInterval;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
@Override
/*
* Time not defined is conceptually thought of as an unlimited high value
* -1 Time is earlier than other (lower value)
* 0 Time is equal
* 1 Time is later than other (higher value)
*/
public int compareTo(EstateViewing otherViewing) {
if (this.getTimeInterval() == null && otherViewing == null)
return 1;
// Not defined, so in the future at some point
if (this.getTimeInterval() == null && (otherViewing != null && otherViewing.getTimeInterval() != null))
return 1;
if (this.getTimeInterval() != null && (otherViewing == null || otherViewing.getTimeInterval() == null))
return -1;
if (this.getTimeInterval() != null) {
// Before
if (this.getTimeInterval().getEnd().isBefore(otherViewing.getTimeInterval().getEnd())) {
return -1;
}
if (this.getTimeInterval().getEnd().isAfter(otherViewing.getTimeInterval().getEnd())) {
return 1;
}
}
return 0;
}
但是,當我給太陽能指數這個類,它不索引喬達時間間隔。
的方式我問Solr的索引此類是
solrServer.addBean(房地產);
此房地產對象包含我上面提到的EstateViewings對象列表。
Solr索引存儲在Estate Estate對象中的其他數據,但EstateViewings列表除外。
我想知道這是否是因爲我使用喬達時間間隔。
誰能幫我提前找到了這個problem.Thanx解決方案的任何幫助