This is the full code:
Code:
package org.fao.fenix.domain;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity
@MappedSuperclass
@Indexed
public abstract class Resource implements VisitableResource {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
Long resourceId;
@Field(index = Index.TOKENIZED, store = Store.YES)
String title;
String abstractAbstract;
String[] keywords;
// Organization provider;
// Organization source;
// Contact contact;
Date startDate;
Date dateLastUpdate;
/**
* Validity period of the data. Valid values are Day, Week, Month and Year.
* The validity period starts from dateLastUpdate.
*/
String periodTypeCode;
/**
* Is this Public and Protected?
*
*/
String sharingCode;
@Field(index = Index.TOKENIZED, store = Store.YES)
public String getPeriodTypeCode() {
return periodTypeCode;
}
public void setPeriodTypeCode(String periodTypeCode) {
this.periodTypeCode = periodTypeCode;
}
@Field(index = Index.TOKENIZED, store = Store.YES)
public String getSharingCode() {
return sharingCode;
}
public void setSharingCode(String sharingCode) {
this.sharingCode = sharingCode;
}
@DocumentId
public Long getResourceId() {
return resourceId;
}
public void setResourceId(Long resourceId) {
this.resourceId = resourceId;
}
@Field(index = Index.TOKENIZED, store = Store.YES)
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Field(index = Index.TOKENIZED, store = Store.YES)
public String getAbstractAbstract() {
return abstractAbstract;
}
public void setAbstractAbstract(String abstractAbstract) {
this.abstractAbstract = abstractAbstract;
}
public String[] getKeywords() {
return keywords;
}
public void setKeywords(String[] keywords) {
this.keywords = keywords;
}
@Field(index = Index.TOKENIZED, store = Store.YES)
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
@Field(index = Index.TOKENIZED, store = Store.YES)
public Date getDateLastUpdate() {
return dateLastUpdate;
}
public void setDateLastUpdate(Date dateLastUpdate) {
this.dateLastUpdate = dateLastUpdate;
}
}
Code:
package org.fao.fenix.domain;
/**
*
*/
public interface VisitableResource {
public void accept(ResourceVisitor resourceVisitor);
}
About what you said:
having @MappedSuperclass and @Entity on the same bean does not make senseWe have Resource as an attribute to User:
Code:
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Resource> resources = new ArrayList<Resource>();
Hibernate complains when Resource is not an entity and therefore I added @Entity. I agree with you that it makes no sense but I did not know another solution. Do you have a suggestion?